Mark Qian
Mark Qian

Reputation: 89

geocode return REQUEST_DENIED

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")
          }
      } 
    });

Upvotes: 2

Views: 5731

Answers (2)

LIN999
LIN999

Reputation: 1

After setting API restrict, it still returns REQUEST_DENIED.

Then, I restart the bill account, and it works.

Upvotes: 0

evan
evan

Reputation: 5699

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:

  1. You need to use an API key.
  2. The Geocoding API and the Javascript API must be enabled.
  3. The API key must be properly restricted.

Hope this helps you and anyone else who encounters this error.

Upvotes: 3

Related Questions