反向地理编码位置:比范围更准确
Reverse Geocode Location: more accuracy than range
我想获得比函数
中的地址范围更准确的地址(来自坐标)
geoCoder.reverseGeocodeLocation(location, completionHandler: {} )
在 google 地图 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 ...
})
如果您想在 link 编辑时使用 Google Maps API
,您需要向 API 发送 HTTP 请求(使用 API Key
从 Google 获得)。 reverseGeocodeLocation
用的是Apple的MapAPI,肯定不能接受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)"
根据您指定的 link,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.
我想获得比函数
中的地址范围更准确的地址(来自坐标)geoCoder.reverseGeocodeLocation(location, completionHandler: {} )
在 google 地图 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 ...
})
如果您想在 link 编辑时使用 Google Maps API
,您需要向 API 发送 HTTP 请求(使用 API Key
从 Google 获得)。 reverseGeocodeLocation
用的是Apple的MapAPI,肯定不能接受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)"
根据您指定的 link,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.