> It seems this function was called after the rest of all the code.
> Why?
Because it is asynchronous.
geocoder.geocode( {'address': address}, function( ... ) { ... }
only sends a request to Google. The callback function is NOT run at
this time.
The browser then carries on and executes the code that follows.
For example
geocoder.geocode( {'address': address}, function( ... ) { ... }
alert ('banana');
the alert will display BEFORE the results get back from Google.
Sometime later, the results come back and the callback function will
be run.
In the case of your code snippet, your callback refers to variables
'map' and 'addr' and 'userPosition' that may or may not be within the
scope of the callback function when it runs, you need to be careful
about that.
--
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.