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?
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)}