Google Maps JavaScript API - Automate Zoom Level?

后端 未结 5 901
执念已碎
执念已碎 2020-12-15 14:01

I\'m working with multiple map markers. Currently I use map.fitBounds(bounds); in my JavaScript to resize the map. bounds contains multiple LatLng

5条回答
  •  我在风中等你
    2020-12-15 14:30

    I have found the solution.

    Instead of doing a single

    bounds.extend(myLatLng)
    

    Everytime you add a myLatLng to your bounds, do these actions

    bounds = map.getBounds();
    bounds.extend(results[0].geometry.location);
    map.fitBounds(bounds);
    

    Hope this helps anyone!

提交回复
热议问题