Answer the question
In order to leave comments, you need to log in
Why does the response from google maps come, but there is no result in the callback?
Hello! I want to get the coordinates of the city entered by the user. For this I use the google maps api "Geocoding Service" function. The answer from google comes and there are coordinates, but the variable is empty.
Here is the code (taken from documentation):
function geocodeAddress(address) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status === "OK") {
console.log(results[0].geometry.location);
return results[0].geometry.location;
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question