Google Geocode Status Always Empty
I am new to geocode. I am getting the zip code from the user finding the lat and long and comparing it with a set of nearby locations who latitude and longitude are present in a JS
Solution 1:
geocoder.geocode
works asyncronously, so you need to wait untill its response will be delivered from google's servers,and only then use reponded data.Put your loop inside of callback:
geocoder.geocode( { 'address': zip }, function(results, status) { // status is empty
if (status == google.maps.GeocoderStatus.OK) {
var userLat = results[0].geometry.location.lat();
var userLng = results[0].geometry.location.lng();
userLatLng = results[0].geometry.location;
for (var i = data.length-1; i--;) {
//loop body
}
}
});//end geocode
Post a Comment for "Google Geocode Status Always Empty"