是否有可能获得更精确的反向地理编码?
Is it possible to get more precise reverse geocoding?
我发现一些反向地理编码方法比其他方法效果更好,我决定使用当前方法。
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
locationManager.stopUpdatingLocation()
if(locations.count > 0){
let location = locations[0] as! CLLocation
println(location.coordinate)
currLocation = location.coordinate
CLGeocoder().reverseGeocodeLocation(location, completionHandler: {(placemarks, error) -> Void in
println(location)
if error != nil {
println("Reverse geocoder failed with error" + error.localizedDescription)
return
}
if placemarks.count > 0 {
let pm = placemarks[0] as! CLPlacemark
self.lbutton.text="\(pm.locality)"
}
else {
println("Problem with the data received from geocoder")
}
})
} else {
alert("Cannot fetch your location")
}
}
毫无问题地发挥作用(但有时更新位置需要几分钟时间,但这是公平的),但是,我很好奇是否可以让它精确定位城镇,而不仅仅是整个州?例如,它会说 Bushwick 而不仅仅是 New York?
我知道最近(差不多)反向地理编码获取数据的方式发生了变化,但我想我会问一些更精通该主题的人。
我发现一些反向地理编码方法比其他方法效果更好,我决定使用当前方法。
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
locationManager.stopUpdatingLocation()
if(locations.count > 0){
let location = locations[0] as! CLLocation
println(location.coordinate)
currLocation = location.coordinate
CLGeocoder().reverseGeocodeLocation(location, completionHandler: {(placemarks, error) -> Void in
println(location)
if error != nil {
println("Reverse geocoder failed with error" + error.localizedDescription)
return
}
if placemarks.count > 0 {
let pm = placemarks[0] as! CLPlacemark
self.lbutton.text="\(pm.locality)"
}
else {
println("Problem with the data received from geocoder")
}
})
} else {
alert("Cannot fetch your location")
}
}
毫无问题地发挥作用(但有时更新位置需要几分钟时间,但这是公平的),但是,我很好奇是否可以让它精确定位城镇,而不仅仅是整个州?例如,它会说 Bushwick 而不仅仅是 New York?
我知道最近(差不多)反向地理编码获取数据的方式发生了变化,但我想我会问一些更精通该主题的人。