I just created a dynamic google maps with WordPress.
Now I’m looking for a way, after I spawn all points on the google maps, to re-center/zoom the map to fit all spawned points into the container with, let’s say, a 10% margin on every side.
I searched the API and didn’t find something that looked like it could help.
Is there a way to do it or do I need a snippet?
PS: I’m using the API V3 with Javascript (populating the map via PHP).
You’ll have to loop an array of markers and extend the bounds. This example assumes a markers[] variable that you’ve populated previously with every marker added to the map.