谷歌地图附近的API在ios中不起作用



当我发布以下API时:

let str11 = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"

使用以下参数:

params = ["location":"-33.8670522,151.1957362",
"radius":"500",
"name":"harbour",
"language" : "en-IN",
"types":"food",
"key":kMapsAPIKey,
]

我有以下问题:

{
"error_message" = "This service requires an API key.";
"html_attributions" =     (
);
results =     (
);
status = "REQUEST_DENIED";
}

您需要有一个 API 密钥才能使用此服务 这里有一个获取 API 密钥的链接

https://developers.google.com/maps/documentation/javascript/get-api-key

您在参数中使用的密钥不是有效的密钥

在 swift 3.0 中,尝试使用此函数以查找附近的点

func nearbysearchWithTypeApiCall(){
key = "Your_Map_API_Key"
location = "22.2082,70.3807"
type = "food"
url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=(location)&radius=5000&key=(key)&type=(type)"
Alamofire.request(url, method: .post, parameters: nil,encoding: JSONEncoding.default, headers: nil).responseJSON {
response in
switch response.result {
case .success:
let dicData  = response.result.value as! NSDictionary
self.arrData = dicData["results"] as! NSArray
print(self.arrData)
print(self.arrData.count)
break
case .failure(let error):
print(error)
}
}
}

相关内容

  • 没有找到相关文章

最新更新