1

I have code to drop a pin on the map when a long press occur.

But I can't seem to create an annotation that included the name, address, city and state of the place using the latitude and longitude values:

    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)
    }
Emeka Obianom
  • 1,736
  • 3
  • 17
  • 36

0 Answers0