私はosmdroidライブラリを使用して地図をレンダリングしています。私は断続的に変化する2つのジオポイントを持ち、org.osmdroid.views.MapViewにサイズ変更と翻訳を行い、両方のポイントが常に見えるようにします。 2つのポイントの中間点でマップを簡単に再センタリングできますが、2つのポイントが表示されるようにズームレベルを設定するにはどうすればよいですか?Osmdroid最大ズームレベルは2つの地理的位置を表示
UPDATE
//Getting pickup and destination latitude and longitude
GeoPoint pickupLocation = null;
if (tripRequest.getPickupLat() != null && tripRequest.getPickupLong() != null) {
pickupLocation = new GeoPoint(tripRequest.getPickupLat(), tripRequest.getPickupLong());
}
GeoPoint destinationLocation = null;
if (tripRequest.getDestinationLat() != null && tripRequest.getDestinationLong() != null) {
destinationLocation = new GeoPoint(tripRequest.getDestinationLat(), tripRequest.getDestinationLong());
}
if (destinationLocation != null && pickupLocation != null) {
//Adding destination marker to map
Marker destinationLocationMarker = new Marker(map);
destinationLocationMarker.setPosition(destinationLocation);
destinationLocationMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
destinationLocationMarker.setIcon(context.getResources().getDrawable(R.mipmap.pin_green_small));
map.getOverlays().add(destinationLocationMarker);
//Adding pickup marker to map
Marker pickupLocationMarker = new Marker(map);
pickupLocationMarker.setPosition(pickupLocation);
pickupLocationMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
pickupLocationMarker.setIcon(context.getResources().getDrawable(R.mipmap.pin_red_small));
map.getOverlays().add(pickupLocationMarker);
BoundingBox boundingBox = BoundingBox.fromGeoPoints(Arrays.asList(destinationLocation, pickupLocation));
mapController = map.getController();
mapController.setCenter(boundingBox.getCenter());
mapController.setZoom(10);// I need to set this zoom properly
touchListener = new TouchListener();
map.setOnTouchListener(touchListener);
提案をいただき、ありがとうございました。自分のコードを追加するように更新しました。私はバウンディングボックスに中心を置くことができますが、ズームにそのバウンディングボックスを使用することはできないようです。 –
私もmap.zoomToBoundingBox(boundingBox、false)を試しました。しかし、それは動作しません。 –