Wasn't it purescape who wrote:
>1) I have a space to input address and geocode/zoom to map.
>2) Then a marker is added in that point, and a window shows the
>address
>3) Then that point and anywhere on the map can be click for a input
>window to appear for extra information to be included in a database
That's true for "anywhere on the map", but it's not true for the
geocoded marker, if that's the only marker on the map, because when you
geocode it you create a local "marker" variable rather than using the
global one, so this line of saveData() fails
var latlng = marker.getLatLng();
You've actually got three variables called "marker". One is global, one
is local to showAddress() and one is help by function closure on your
"click" callbacks. Since code executed from a HTML "onclick" executes in
global context, it sees the global one
So the latlng you send to your server is the location of the last marker
to have been created by clicking on the map, which may well not be the
last marker that the user clicked on.
I tend to remember the last marker on which the info window was opened
in a global variable
var lastmarker; // global
...
marker.openInfoWindow(html); // the ones that display the form
lastmarker = marker;
...
var latlng = lastmarker.getLatLng();
And also change
marker.closeInfoWindow();
to map.closeInfoWindow();
--
http://econym.googlepages.com/index.htm
The Blackpool Community Church Javascript Team
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" 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-API?hl=en
-~----------~----~----~----~------~----~------~--~---