I tried using some ajax to save the placement in my application and stumbled upon the following code when 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 that when I call the function, it returns nothing, and when I debug and set breakpoints in chrome, it breaks down on the return result before it breaks the result [lat] = results [0] .geometry. location.Pa;
I know that an array should be declared as an array of types, but even when I just returned the results [0] .geometry.location object nothing was returned
what can i do to return lat / long from location so that i can store in my db?
javascript jquery google-maps-api-3 geocoding
Chris Mccabe Jan 10 2018-12-12T00: 00Z
source share