geocode return REQUEST_DENIED

有些话、适合烂在心里 提交于 2019-12-24 08:04:47

问题


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:

  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.



来源:https://stackoverflow.com/questions/57810233/geocode-return-request-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!