Я создал Mapview, где отображается UserLocation. Я также добавил аннотации на карту, например, «Аннотация 1».
Мне нужно найти способ щелкнуть аннотацию, открыть Apple Maps и дать указания для аннотации. Я думал о чем-то вроде распознавателя жестов ..
Я ценю любую помощь
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
//MapView
@IBOutlet weak var map: MKMapView!
let manager = CLLocationManager()
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
let location = locations[0]
//Zoom in the map to the location
let span:MKCoordinateSpan = MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)
let myLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)
let region: MKCoordinateRegion = MKCoordinateRegion(center: myLocation, span: span)
map.setRegion(region, animated: true)
//Show Blue dot
self.map.showsUserLocation = true
}
override func viewDidLoad()
{
super.viewDidLoad()
let annotation1 = MKPointAnnotation()
annotation1.title = "Annotation One"
annotation1.coordinate = CLLocationCoordinate2D(latitude: 43.732872, longitude: 7.424620)
map.addAnnotation(annotation1)
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
}
}