I have a function, in an external .js file which is supposed to take address string and then return latitude and longitude. It returns nothing. Can someone help please?
I also would like to ask; in javascript, when you call an async function from within another function; does the async function terminate as soon as the outside function terminates?
Here is the code, could anyone shed light on why this does not return anything? Thanks.
function FindLatLong(address)
{
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
return { Status: "OK", Latitude: lat, Longitude: lng };
}
});
}
(I of course include the google maps js lib on top)
I basically do not get an OK result from geocoder; the same code works if I do not put it inside FindLatLong function, and instead just embed it in place where I call FindLatLong i.e. the code above does not work when put inside FindLatLong function, but works if I use it as part of the calling javascript code. The function does get called, Geocoder() does get called, but 'OK' result is not returned, in fact no result is resturned, not even error from google.
address string is "London, UK"