Thanks, that did the trick :) On Tue, Oct 4, 2011 at 7:50 PM, [email protected] <[email protected]>wrote:
> On Oct 4, 11:43 am, Andy Newby <[email protected]> wrote: > > Hi, > > > > I'm trying to get a basic geocoder working, but can't seem to get the > values > > passed back. The main codes are: > > > > > > function codeAddress(address) { > > geocoder.geocode( { 'address': address}, function(results, status) { > > if (status == google.maps.GeocoderStatus.OK) { > > var test = results[0].geometry.location.lat() + "," + > > results[0].geometry.location.lng(); > > alert("TEST: " + test); > > } else { > > alert("Geocode was not successful for the following reason: " + > > status); > > } > > }); > > } > > > > The part: > > > > alert("TEST: " + test); > > > > prints out the value I'm expecting fine: > > > > TEST: 51.089816,-0.44929000000001906 > > > > ..yet the values here are undef: > > > > var lat_lng_vals = codeAddress("Rudgwick, UK"); > > alert("LAt: " + lat_lng_vals); > > > > What am I doing wrong? FF debugger doesn't show any errors, but it never > > seems to get the values? Does it maybe need running using async? > > Geocoding is asynchronous. You can't return the results that way, you > need to use them in the callback function. > > -- Larry > > > (cos the > > messages come up as "Lat:..." and THEN the "TEST:" alert) > > > > TIA > > -- > 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. > > -- Andy Newby [email protected] -- 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.
