Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i have been trying to use some ajax to save venue location in my application and stumbled across the following code on stack overflow

function getLatLong(address) 
{
    var geocoder = new google.maps.Geocoder();
    var result = "";
    geocoder.geocode( { 'address': address, 'region': 'uk' }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            result[lat] = results[0].geometry.location.Pa;
            result[lng] = results[0].geometry.location.Qa;
        } else {
            result = "Unable to find address: " + status;
        }
    });
    return result;
}

my problem is when i call the function it returns nothing and when i debug and set breakpoints in chrome it breaks on return result first before it breaks on the result[lat] = results[0].geometry.location.Pa;

I know the array should be declared as type array but even when i was just returning the results[0].geometry.location object nothing was being returned

what can i do to return the lat/long of the location so i can store in my db?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
391 views
Welcome To Ask or Share your Answers For Others

1 Answer

This is not the answer but don't use Pa and Qa always use the lng() and lat() functions:

 place.geometry.location
{...}
    Pa: 56.240477
    Qa: -0.902655999999979
    toString: function(){return"("+this.lat()+", "+this.lng()+")"}
    equals: function(a){return!a?k:Cd(this.lat(),a.lat())&&Cd(this.lng(),a.lng())}
    lat: function(){return this[a]}
    lng: function(){return this[a]}
    toUrlValue: function(a){a=Hd(a)?a:6;return $d(this.lat(),a)+","+$d(this.lng(),a)}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...