问题
google.maps.Geocoder().geocode always return REQUEST_DENIED with all the APIs enabled in a commercial google map account
We tried to use a key of a paid commercial account with all the APIs (15 of them) enabled but still got REQUEST_DENIED when calling google.maps.Geocoder().geocode
new google.maps.Geocoder().geocode( { 'address': site.address}, function(results, status) {
//console.log('address:'+ site.address)
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
site.latitude = latitude
site.longitude = longitude
if (callback) {
callback(site)
}
} else {
if (errorHandler) {
errorHandler.call(self, "Invalide address")
}
}
});
回答1:
The REQUEST_DENIED error status code usually means there is an issue with your project setup or api key. Besides enabling billing, to use Google's Geocoder:
- You need to use an API key.
- The Geocoding API and the Javascript API must be enabled.
- The API key must be properly restricted.
Hope this helps you and anyone else who encounters this error.
来源:https://stackoverflow.com/questions/57810233/geocode-return-request-denied