On Dec 4, 9:52 am, philipp <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> i tried to get the Coordinates using the getLocations method.
> Works fine, but i can't get the coordinates back.
> Even saving in a global variable doesn't work, after the getLocations
> method
> the global variable is empty like before.

Think about what's going on.

You call getGeoFromAddress(fromtxt) which is supposed to geocode the
from address. That is done asynchronously, in the background, so your
function immediately gets to the line return(returnval) which is still
null. The same thing happens with the next getGeoFromAddress(). When
your code gets to setDirections(), from and to are both null.

At some point, callback_getlocation() will be run and returnval will
be set. Even then, there is no guarantee that the results will be
returned in the order in which you requested them.

You need to make sure that everything is chained together in the right
order, so that requests are sent from the callback functions once the
previous result is returned.

geocode fromtxt
--> callback function handles result and geocodes totxt
     --> callback function handles result and sets directions request
          --> callback function handles result and processes
directions object

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