you can do this quite simply by passing your polygon to a function
that calculates and returns the bounds:
function getBoundsForPoly(poly) {
var bounds = new google.maps.LatLngBounds;
poly.getPath().forEach(function(latLng) {
bounds.extend(latLng);
});
return bounds;
}
with a function call like this (assuming your polygon is called poly):
bounds=getBoundsForPoly(poly)
and then a good ol'
map.fitBounds(bounds)
you can see it in action here http://www.xelawho.com/map/ on the
"Zones Info" dropdown
(and a belated thanks to whoever it was from the forum who I
"borrowed" the above code from)
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.