我有一个纬度和经度:“-27.0000,133.0000”。我想在此基础上制作一张地图。

我试着去这个链接

https://maps.googleapis.com/maps/api/geocode/json?latlng= 27.0000, 133.0000关键= * * * * * *

我一直在浏览器上得到这个错误

{
   "error_message" : "This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console",
   "results" : [],
   "status" : "REQUEST_DENIED"
}

但我想我已经启用了那个API。我登录到我的谷歌控制台,并再次检查。

当我去:https://console.developers.google.com/project/75423435770063/apiui/apis/enabled

我明白了:

启用地理编码+地理定位。

我现在有点卡住了。还有什么我没注意到的吗?


当前回答

也可以通过云SDK启用api。https://developers.google.com/maps/documentation/geocoding/cloud-setup#enabling_apis

gcloud services enable \
    --project "PROJECT" \
    "geocoding-backend.googleapis.com"

https://cloud.google.com/sdk/gcloud/reference/services/enable

其他回答

你需要从link启用api:

https://console.cloud.google.com/apis/library?

也可以通过云SDK启用api。https://developers.google.com/maps/documentation/geocoding/cloud-setup#enabling_apis

gcloud services enable \
    --project "PROJECT" \
    "geocoding-backend.googleapis.com"

https://cloud.google.com/sdk/gcloud/reference/services/enable

如果使用get方法获取位置,则需要启用

谷歌放置API Web服务

我也遇到过同样的问题,在启用它后解决了。

编辑:根据https://developers.google.com/places/web-service/get-api-key

注意:谷歌Places API Web服务不适用于Android 或iOS限制API密钥。

因此,您必须创建新的密钥,如果或删除现有密钥的限制访问,以正常工作。

我在Drupal网站上遇到了同样的问题。在谷歌云平台上启用地理编码API后,为我工作。在我的设置,我需要两个api,地理编码和地图Javascript api。

您忘记在开发人员控制台中启用服务。