获取地点信息

时间:2018-10-17 12:06:05

标签: ios swift google-maps cllocationmanager

我正在从纬度,经度获取城市和国家/地区信息。但是我需要附近餐馆,医院等的列表,即here列出的地点的完整列表,以便可以在表格视图中显示它们。

我又如何在地图上获得仅餐馆(例如)的列表??

1 个答案:

答案 0 :(得分:1)

这里是一个示例,它返回URL中指定位置附近的餐馆列表。

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=YOUR_LATITUDE,YOUR_LONGITUDE&radius=1500&type=restaurant&keyword=cruise&key=YOUR_API_KEY

您可以从Google控制台获取密钥。如需更多帮助,您可以参考google文档

https://developers.google.com/places/web-service/search

  

您的Alamofire请求将类似于:

let headers = [
                "Accept": "application/json",
                "Content-Type": "application/json"
            ]

let req = Alamofire.request(url, method: .post, parameters: nil, encoding: JSONEncoding.default, headers: headers).responseJSON
            {
                (responseData:DataResponse<Any>) in
                //Handle your response Here
            }