将字符串(位置)转换为坐标时。地标中的坐标指向的方向与我作为参数提供的字符串不同。
让地址=“中央邦印多尔南图科甘吉南坎巴格大道16/1”
let geoCoder = CLGeocoder()
geoCoder.geocodeAddressString(address) { (placemarks, error) in
guard
let placemarks = placemarks,
let location = placemarks.first?.location.coordinates
else {
// handle no location found
return
}
// Use your location
}
结果lat:22.7438068和long:75.8512509 预期结果lat:22.7203646和long:75.88234569999997。
因此,Google地图上的标记指向错误的方向。
任何帮助将不胜感激。 在此先感谢
答案 0 :(得分:0)
使用如下图所示
//implementation
getPositionFromAddress(strAdress:"Rajendra Kamble Road, Yashwant Nagar, Santacruz East, Mumbai, Maharashtra. India")
//Function
func getPositionFromAddress(strAdress:String){
let address = strAdress
let geoCoder = CLGeocoder()
geoCoder.geocodeAddressString(address) { (placemarks, error) in
guard let placemarks = placemarks, let location =
placemarks.first?.location else {
// handle no location found
return
}
print(location)
}