Post

Replies

Boosts

Views

Activity

How to handle a tap on MapAnnotation in MapKit/SwiftUI?
I just want to handle a tap on MapAnnotation - https://developer.apple.com/documentation/mapkit/mapannotation in Map - https://developer.apple.com/documentation/mapkit/map. I've already tried to use usual .onTap modifier, but it didn't work on content passed into MapAnnotation initializer. Also, as I understand, there is no modifier to do something like MKMapViewDelegate.mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) - https://developer.apple.com/documentation/mapkit/mkmapviewdelegate/1452393-mapview does. So, is there a convenient way to handle a tap, or should I create my own UIViewRepresentable - https://developer.apple.com/documentation/swiftui/uiviewrepresentable for MKMapView - https://developer.apple.com/documentation/mapkit/mkmapview with its own coordinator and do whatever I want with it by interfacing with UIKit?
4
1
2.3k
Aug ’20