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 load() {
            geocoder = new google.maps.Geocoder();
            
            var latlng = new google.maps.LatLng(-34.397, 150.644);
            var myOptions = {
              zoom: 8,
              center: latlng,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            map = new google.maps.Map(document.getElementById("map"), 
myOptions);            
            
            var lat_lng_vals = codeAddress("Rudgwick, UK");
            
            alert("LAt: " + lat_lng_vals);
        
    }
  
  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? (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 view this discussion on the web visit 
https://groups.google.com/d/msg/google-maps-js-api-v3/-/1PiWbtgjVLUJ.
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.

Reply via email to