在iPhone MKMapView中获取触摸式地图的当前位置 [英] Getting current location of map on touch in iphone mkmapview
本文介绍了在iPhone MKMapView中获取触摸式地图的当前位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何根据用户在其iPhone上触摸地图上的位置来获取mkmapview中的位置坐标?
How can I get the location coordinates in mkmapview according to user touching a location on the map on their iphone?
推荐答案
func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
let touchPoint = touch.location(in: mapView)
let location = mapView.convert(touchPoint, toCoordinateFrom: mapView)
print ("\(location.latitude), \(location.longitude)")
}
}
这篇关于在iPhone MKMapView中获取触摸式地图的当前位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文