On Nov 5, 12:34 am, Rob <[email protected]> wrote: > Thanks for helping out, so I followed your suggestion of doing a > reverse geocode when dropping the marker, such as: > > markerLocation = reverseGeocode(marker.getPosition()); > alert(markerLocation.city); > > However, markerLocation is always null, even though within the > reverseGeocode function, the city is being populated properly. I am > assuming this is because JS doesn't wait for the AJAX request to be > completed, and just continues executing the rest of the code. Any > idea on how to solve this?
the reverse geocoder is asynchronous, you can't return a value from it like that. set the position of the marker in the callback routine. -- Larry > > On Nov 4, 6:46 pm, Rossko <[email protected]> wrote: > > > > > > > > > > I have a map where I drop a number of markers. > > > That would be the time to do reverse gecoding? > > > > I need to save the > > > location of the markers to a database, along with the city and country > > > that the marker was placed in. > > > Beware the terms of use for storing Google's data > > > > Any way I can do this synchronously? > > > No, but you can write code that simulates it e.g. execute one request, > > when response comes execute the next, when all complete do whatever > > else. The next pitfall will be the limited rate of request allowed, > > to prevent abuse. -- 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.
