【问题标题】:Google Places API Key for Android App适用于 Android 应用的 Google Places API 密钥
【发布时间】:2014-07-11 12:46:54
【问题描述】:

我为我的 Android 应用程序创建了一个API Key(适用于 Android 应用程序)。它是谷歌地图 API 所要求的。但现在相同的密钥不适用于 Google Places API。

我还尝试使用以下 URL 访问浏览器:

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&key=my_key

我明白了:

{
   "error_message" : "This IP, site or mobile application is not authorized to use this API key.",
   "html_attributions" : [],
   "status" : "REQUEST_DENIED"
}

当我用谷歌搜索答案时,我发现了这个:

https://developers.google.com/places/training/autocomplete-android

什么类型的 API 密钥?

您需要自己的 Google Places API 浏览器或服务器 API 密钥,然后才能开始使用 Place Autcomplete 服务。请注意,Android API 密钥不适用于 Place Autocomplete 服务。

这让我很困惑,因为我没有任何 Web 应用的 URL,也没有任何服务器 IP。因此,我对如何获得Browser keyServer key 感到困惑

谁能帮我弄清楚这里需要什么样的钥匙?另外,如果我必须创建Browser keyServer key,我该怎么做?

【问题讨论】:

  • 你必须已经生成了一个android api key,所以再次点击“Create Key”,你会得到options,server key,browser key,android key,ios key 首先点击server key,离开空白处点击创建,您的服务器密钥将生成,保存。

标签: android google-maps google-maps-api-3 google-play-services google-places-api


【解决方案1】:

请参阅this 文档以了解如何获取 google 地方 API 密钥

查看 this 集成 Google 地方的教程

【讨论】:

  • 精彩分享!很长一段时间以来一直在尝试了解这个 API!
【解决方案2】:

对于使用地方 api 生成浏览器密钥,因为该 android 密钥不起作用。 有同样的问题,但这解决了问题

【讨论】:

    【解决方案3】:

    你需要启用以下地方的api

    -Google Places API 网络服务

    并且您需要使用服务器密钥来获取地点的数据。

    要获取服务器密钥,请按照以下步骤操作:APIs & Auth -> Credentials -> 创建新密钥 -> 服务器密钥

    浏览器键不起作用。

    我遇到了同样的问题,我通过同样的方式解决了它。

    在这里你可以看看构建你的 Url

     StringBuilder googlePlacesUrl = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
                googlePlacesUrl.append("location=" + latitude + "," + longitude);
                googlePlacesUrl.append("&radius=" + PROXIMITY_RADIUS);
                googlePlacesUrl.append("&types=" + type);
                googlePlacesUrl.append("&sensor=true");
                googlePlacesUrl.append("&key=" + SERVER_KEY);
    

    【讨论】:

    • 这个问题是一年多以前提出的;虽然现在可能是正确答案,但原发帖者不太可能仍然遇到此问题。
    • 我为那些面临问题或将遇到同样问题的人发布了这个答案,因为在我没有找到原因并稍后解决时查看 SO 后,我认为它可能会有所帮助也给别人。
    • 我只是想确保您知道问题的年龄;发布知识供他人参考,只要它是这样呈现的,总是一件好事。
    【解决方案4】:

    如果你想在android项目中集成Google Place Api并且你需要一个key,那么只需点击下面的链接它会自动为你创建一个key 您只需将该密钥复制到您的项目中

    https://developers.google.com/places/android-api/start

    【讨论】:

      猜你喜欢
      • 2016-03-27
      • 2018-12-12
      • 2012-08-31
      • 2015-12-09
      • 2018-06-14
      • 2015-12-31
      • 1970-01-01
      • 1970-01-01
      • 2014-08-09
      相关资源
      最近更新 更多