我有代码在长时间按下时将地图上的图钉放下。
但我似乎无法使用纬度和经度值创建包含地点的名称,地址,城市和州的注释:
func onLongPress(gesture: UILongPressGestureRecognizer){
if gesture.state == .ended {
let point = gesture.location(in: self.mapView)
let coordinate = self.mapView.convert(point, toCoordinateFrom: self.mapView)
print(coordinate)
//Now use this coordinate to add annotation on map.
let annotation = MKPointAnnotation()
annotation.coordinate = coordinate
//Set title and subtitle if you want
self.mapView.addAnnotation(annotation)
}