gpt4 book ai didi

swift - 反向地理编码位置 : more accuracy than range

转载 作者:行者123 更新时间:2023-11-28 06:28:06 24 4
gpt4 key购买 nike

我想获得比函数中的地址范围更准确的地址(来自坐标)

geoCoder.reverseGeocodeLocation(location, completionHandler: {} )

在谷歌地图 API 指南 ( https://developers.google.com/maps/documentation/geocoding/intro#Results ) 中,他们指定我可以更改 location_type 以获得更准确的地址。如何指定这些参数?这是我的代码:

let geoCoder = CLGeocoder()
let location = CLLocation(latitude: center.latitude, longitude: center.longitude)
geoCoder.reverseGeocodeLocation(location, completionHandler: { (placemarks, error) -> Void in ...
})

最佳答案

如果您想使用 Google Maps API,在您链接时,您需要向 API 形成一个 HTTP 请求(使用您已经拥有的 API key 从谷歌获得)。 reverseGeocodeLocation 使用了 Apple 的 Map API,肯定无法接受 Google 的 location_type 参数。因此,您要发出的核心 HTTP 请求采用以下形式:

let url:String = "https://maps.googleapis.com/maps/api/geocode/json?latlng=\(center.latitude),\(center.longitude)&location_type=\(DESIRED_LOCATION_TYPE)&key=\(YOUR_API_KEY)"

在您指定的链接中,DESIRED_LOCATION_TYPE 可以是以下之一:

"ROOFTOP" restricts the results to addresses for which we have location information accurate down to street address precision.

"RANGE_INTERPOLATED" restricts the results to those that reflect an approximation (usually on a road) interpolated between two precise points (such as intersections). An interpolated range generally indicates that rooftop geocodes are unavailable for a street address.

"GEOMETRIC_CENTER" restricts the results to geometric centers of a location such as a polyline (for example, a street) or polygon (region).

"APPROXIMATE" restricts the results to those that are characterized as approximate.

关于swift - 反向地理编码位置 : more accuracy than range,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41208332/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com