Reputation: 8021
I want to display a google map in my application that shows one complete half of the globe, containing two markers that are about 20,000 km from one another in the same view.
I tried using the property getMinZoomLevel(), but it's not sufficient - it shows the first marker surrounded by an area only about the size of half a continent. Is there any way of getting the wide view that I want?
Code example for last known user location (one of the markers), where zoomLevel is getMinZoomLevel():
map.moveCamera(CameraUpdateFactory.newCameraPosition(getCameraPositionFromLocationWithZoom(UserLocation.getInstance(App.getInstance().getApplicationContext()).getLastKnownLocation(), zoomLevel)));
Upvotes: 0
Views: 74
Reputation: 630
Try something like.
private LatLngBounds bounds;
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(pointA);
builder.include(pointB);
//and other latlng points as you like...
bounds = builder.build();
map.animateCamera(CameraUpdateFactory.newLatLngBounds(
bounds, 20));
animateCamera animates the camera to specific point location. if you have more then one point (LatLngBounds) it will expand the map to be visible all points.
Hope to be helpful.
Upvotes: 1