GEvent.addListener(map, 'infowindowopen', function()
{ map.savePosition(); });
GEvent.addListener(map, 'infowindowclose', function()
{ map.returnToSavedPosition(); });
The code above was created in v2.
I'm trying to have the map revert back to its original position (centered) when the user closes the info window.
Help please.
Nat
function savePosition() {
savedLocation = map.getCenter();
}
function returnToSavedPosition() {
if (savedLocation)
map.setCenter(savedLocation);
}
When you open an infowindow, call savePosition(), ie wherver you call
a infowindow.open
and attach a eventListener to the same infowindow
google.maps.event.addListener(infowindow, 'closeclick', function() {
returnToSavedPosition();
});
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/ndwsJgSvdb4J.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
google.maps.event.addListener(infowindow, 'closeclick', function() {