> Should I do it like this?

It's your code and there is always more than one way to do things.
However, bearing mind the way your page works - a marker might get
dragged or not etc. -
I'd do something like

      GEvent.addListener(marker, "dragend", getAddress)
             // when fired, passes a GLatLng to whatever function is
specified
.....

      function getAddress(latlng) {
                // needs to be passed a GLatLng
            document.getElementById("lat").value=latlng.lat();
            document.getElementById("lng").value=latlng.lng
            if (latlng != null) {
                 address = latlng;
                 geo.getLocations(latlng, showNewAddress);
            }
      }
// where showNewAddress takes the geocoder results (if any) and pastes
them in your form

The reason why I'd do it that way is so that I could re-use the same
getAddress function from other parts of my code.  If was built
directly in the listener, you can only ever use it on that one
listener.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to