使用 google places api in iOS 找不到的地方

places not found using google places api in iOS

我正在尝试显示具有所选类型的附近地点 类型 - 酒吧、咖啡馆、ATM 等

我已经在开发者控制台上创建了项目。 启用API(google地方api,google地图sdk,方向api)

我创建了 iOS api 键,但 Api 键不起作用。我收到此错误消息

This IP, site or mobile application is not authorized to use this API key. Request received from IP address 114.143.244.10, with empty referer

当我尝试使用浏览器 api 键时出现此错误

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

我正在使用这个 url

NSString *url = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=%@&types=%@&sensor=true&key=%@",
    currentCentre.latitude,
    currentCentre.longitude,
    [NSString stringWithFormat:@"%i", currenDist],
    googleType,
    kGOOGLE_API_KEY
    ];

我没明白是什么问题。

我想我现在知道你的问题了,你可能错过了一步..

步骤应该是:

1) 转到开发者控制台 https://code.google.com/apis/console/

2) 在凭据中,在 Public API 访问下,创建新密钥

3) Select 来自选项的服务器密钥。

4) 在字段中输入您的 IP 地址,如果您有更多 IP 地址,您可以在每个 IP 地址上添加 line.NOTE:仅当您要将 IP 地址用于测试目的时才输入 IP 地址.否则将 IP 地址部分留空。

5) 完成后,单击创建,将生成您的新服务器密钥,然后您可以将该服务器密钥添加到您的 URL。

像这样使用它:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=[lat],[lon]&radius=[radius]&key=kGOOGLE_API_KEY&sensor=true

或来自您正在使用的教程..

https://maps.googleapis.com/maps/api/place/search/json?location=[lat],[lon]&radius=[radius]&types=[type]&key=kGOOGLE_API_KEY&sensor=true

如你所见&sensor=true是最后一个参数..(不要相信互联网上的任何东西)..哈哈哈..

如果你仔细地遵循,一切都必须正常工作。我建议从顶部开始。哈哈哈。哈哈。你会知道并了解什么是 missing/forgotten,那将帮助你成为一个更好的人..哈哈..祝你好运先生..:)

对此启用 api Google 地点 API Web 服务 & Google 地点 [=在 API 控制台

中 iOS 的 27=]

参考这个文档....

Google 地点 API Web 服务

https://developers.google.com/places/webservice/search

尝试使用这个库 https://github.com/FuerteInternational/FTGooglePlacesAPI 用你的密钥告诉我。

请检查您的所有 API 是否已在 Google 开发者控制台上启用

第 1 步转到开发者控制台

步骤 2 API 经理 ==> API 图书馆 ==> Google 地图 APIs ==>更多

步骤 3 并启用 ==> Google 地点 API Web 服务 (自动完成和搜索)

第 4 步完成享受 (^_^) 全部完成!!!!

注意:- 确保您的 API KEY 正确且创建正确....