On Dec 25, 3:53 pm, sladda <cbe...@web.de> wrote: > > What am I doing wrong?
You are missing the point that geocoding takes a bit of time, which is why it's implemented as an asynchronous function. In this code, geocoder.getLatLng( address, function(point) { newPoint = point; alert(newPoint); }); return newPoint; The geocoder request is fired and [in the background] the function is set ready to receive the result. Meanwhile code execution goes on to "return newPoint" which is still undefined. At some point the geocoder returns the result and function(point){...} is executed. At that point, newPoint becomes defined. Everything which is dependent upon the result of the geocoder operation must be within the callback function. There is no synchronous (statement-by-statement) operation. To do what you want to do, you need the alert() statement inside the callback function -- that works, as you have found. You can't pass the result back in the way you want. 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 Google-Maps-API@googlegroups.com To unsubscribe from this group, send email to google-maps-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---