Добавить удовольствие c mapView (_ mapView: MKMapView, viewFor аннотации: MKAnnotation) -> MKAnnotationView? в SwiftUI - PullRequest
0 голосов
/ 21 апреля 2020

Я пишу приложение с помощью SwiftUI и хочу сделать MapView с пользовательскими аннотациями

import SwiftUI
import MapKit
import CoreLocation

struct MapView: UIViewRepresentable {

    var center: CLLocationCoordinate2D

    func makeUIView(context: Context) -> MKMapView {
        let mapview = MKMapView(frame: .zero)
        mapview.mapType = .hybrid
        return mapview
    }

    func updateUIView(_ uiView: MKMapView, context: Context) {
        let span = MKCoordinateSpan(latitudeDelta: 0.02, longitudeDelta: 0.02)
        let region = MKCoordinateRegion(center: center, span: span)
        uiView.setRegion(region, animated: true)
    }
}

Как мне переопределить func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? в моей структуре?

...