I've wrapped a MKMapView
in a ViewRepresentable
public struct MapView: UIViewRepresentable {
I want to create an action callback that works like this:
MapView().onAnnotationTapped { annotation in
}
In MapView
i have defined
@inlinable public func onAnnotationTapped(site: (AnnotationView) -> ()) -> some View {
return self
}
But how to provide the AnnotationView
from the coordinator?
public class MapViewCoordinator: NSObject, MKMapViewDelegate {
var mapView: MapView
init(_ control: MapView) {
self.mapView = control
}
public func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
/// How to send from here to the MapView function?
}
}