I am using Geocode API on a project, where users have a text input to enter an address. This address is found using Google Maps API, however, Geocode API cannot find the address. The strange part is that it works for some addresses, but for some others it doesn't.
For example, the address Courchevel, Saint-Bon-Tarentaise, France can be found on Google Maps, but not with the Geocode URL: https://maps-api-ssl.google.com/maps/api/geocode/json?address=Courchevel%2C%20Saint-Bon-Tarentaise%2C%20France&sensor=false&client=gme-kickzag&signature=MY_SIGNATURE=, where MY_SIGNATURE is given correctly.
On the other hand, the address Basel, Switzerland works correctly: https://maps-api-ssl.google.com/maps/api/geocode/json?address=Basel%2C%20Switzerland&sensor=false&client=gme-kickzag&signature=MY_SIGNATURE=
Any answer is very much appreciated!
You can use the Places Service and pass it a place ID. Only catch is you have to pass the service an instance of a map or an html element node. Here's an example:
// "map" is a google map you have created
var service = new google.maps.places.PlacesService(map);
var request = {
placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4'
};
service.getDetails(request, callback);
function callback(place, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
var lat = results.geometry.location.lat(),
long = results.geometry.location.lng();
console.log('lat & long', lat, long);
}
}
In my case since I am not using a map so I passed it an html node like
var details = document.getElementById('details');
var service = new google.maps.places.PlacesService(details);
To adhere to the terms, you cannot hide the element. However it appears the service doesn't augment it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With