I have a question regarding to the default points of interest.
I can show the default POIs using mapView.showsPointsOfInterest = true
But I cannot tap on /select those POIs (restaurant, hotel, etc ..). All I want is that when I tap on it, I can get its info (long/lat, name ...)
I tried different delegate methods, such as func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) and func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?but none of those give me the right result
Can anyone help me with it? Thanks :)
Figured it out. You need to set a configuration on the mapView to make points of interest selectable
mapView.selectableMapFeatures = [.pointsOfInterest]
and then you can listen to when these points are selected by the user using the mapView delegate method
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
print("did select: \(view.description)")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With