I'm trying to retrieve an array ([latitude,longitude])
from Google Maps' API by returning the said array and putting it in variable 'latlong'.
However, nothing seems to be returned by the function. What am I doing wrong here? I realize the function is called in a and of embedded way, but being new to Js, I find the whole thing is confusing.
This code:
// Withing another function:
var latlong = geocoder.geocode( { 'address': 'London, UK'}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
}
return [latitude,longitude];
});
console.log(latlong);
returns 'undefined'