map icon indicating copy to clipboard operation
map copied to clipboard

Auto-Center based on Marker Positions

Open naveendb92 opened this issue 6 years ago • 1 comments

How can I auto center or set zoom so that it covers all markers based on the positions of my markers.

naveendb92 avatar Mar 29 '18 04:03 naveendb92

You can make use of the fitBounds() method: https://developers.google.com/maps/documentation/javascript/reference/map#Map.fitBounds

You could iterate through your markers and call their getPosition() method and extend a LatLngBounds object: https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngBounds

Dinosaurleg avatar Oct 04 '18 20:10 Dinosaurleg