| 1 comments ]

How we can move into last changed position on info window close event On google map

Hi,

I have issue with the markers. When I clicked the marker the info
window is opening and the map positions are redrawing because the
info window is little bit larger. So I need to redraw the back to its
old position(markers) where clicked last time, In order to to get a
good user experience.

How can we achieve that ..

Is this possible in google map. if yes Please help me to solve this
issue

Thanks
JJ
http://phpqa.blogspot.com


****************************
Mike Williams wrote
****************************

Subject: Re: How we move into last changed position on info window close event


You could take a copy of map.getCenter() into a global variable just
before you open the info window, and perform a map.setCenter() to put it
back when you see an infowindowclose event. However, I reckon that that
provides a significantly worse user experience.

--
http://econym.org.uk/gmap
The Blackpool Community Church Javascript Team

****************************
jj wrote
****************************

Thanks Mike.

Can we use the "Return to last Result", the centered control between
Pan up , Pan right, Pan Bottom, Pan Left. in the map control named
GLargeMapControl. is It seems to be work here or not.

Do you have any idea that which function is used there?
jj
http:phaqa.blogspot.com

****************************
Esa wrote..
****************************

map.savePosition() saves the position

map.returnToSavedPosition() recalls the position

It is a good idea to trigger returnToSavedPosition() by
'infowindowclose' event. I been using it often. I quess this is the
first one:
http://esa.ilmari.googlepages.com/hellocolorswitch.htm

What if the user wants to see behind the info window. That is why
'closeclick' event of GInfoWindow might be better alternative.

The first setCenter saves the position. That is often forgotten by
those who are using just any initial setCenter() like (0,0) and a
function that setCenters the map by marker bounds. savePosition()
should also be triggered by that function.


try this out
****************

var marker = new GMarker(point, markerOptions);

GEvent.addListener(marker, "click", function() {
map.savePosition();
marker.openInfoWindowHtml('<div
class="nome">phpqa.blogspot.com</div>', {maxWidth:300});
});

GEvent.addListener(marker, "infowindowclose", function() {
map.returnToSavedPosition();
});

1 comments

C├ędric said... @ Friday, October 9, 2009 at 4:08:00 PM GMT+1

Thanks Esa, I had the same problem and I used your script and it works great.

Post a Comment

Please put your comments here. your questions, your suggestions, also what went wrong with me.