将字符串(位置(转换为坐标时。占位符中的坐标指向的方向与我作为参数提供的字符串不同。
let address="16/1,Kanchan Bagh Main Road,South Tukoganj,Indore,Madhya Pradesh">
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
}
结果纬度:22.7438068&长:75.8512509预期结果纬度:22.7203646&长:75.88234569999997。
正因为如此,谷歌地图上的标记指向了错误的方向。
如有任何帮助,我们将不胜感激。提前感谢
如下所示使用
//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)
}