如何创建包含地址城市和丢弃引脚状态的注释

时间:2017-07-04 21:16:53

标签: ios swift annotations maps

我有代码在长时间按下时将地图上的图钉放下。

但我似乎无法使用纬度和经度值创建包含地点的名称,地址,城市和州的注释:

    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)
    }

0 个答案:

没有答案