Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android Zoom-to-Fit All Markers on Google Map v2 [closed]

How to zoom in/out the map view such a way that it cover all markers?

i am reviewing sample code of gmap V2 given in sdk. It lays on sdk\extras\google\google_play_services\samples\maps.

Thanks in advance.

like image 625
Dhrupal Avatar asked May 07 '13 08:05

Dhrupal


People also ask

How do I fix zoom on Google Maps?

To fix Google maps zooming problems, for Google maps default zoom you want to know how to change the zoom level on Google Maps. You can change the zoom level by going to the Edit map page and then selecting 'default zoom level' in the map information section and then clicking save map.

How do I change the max zoom level in Google Maps?

Setting up the minimum or maximum Zoom value for Google Maps can be done by adding the shortcode attribute with Store Locator Shortcode. Furthermore, the maximum value of Google Maps Zoom level is 22. Therefore, the defined maximum value must be below or equal to 22, which is the default.

Can you use Google Maps and zoom at the same time?

Google Maps - cannot zoom and move at the same time with animateCamera, but can with moveCamera. Bookmark this question. Show activity on this post. I am using Google Maps for Android.


1 Answers

Try using LatLngBounds :

LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(Latlng1);
builder.include(Latlng2);
LatLngBounds bounds = builder.build();
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 20));
like image 59
Emil Adz Avatar answered Oct 02 '22 18:10

Emil Adz