diff --git a/Sources/Annotations/MKMapAnnotationView.swift b/Sources/Annotations/MKMapAnnotationView.swift index f65d9ab..c612c23 100644 --- a/Sources/Annotations/MKMapAnnotationView.swift +++ b/Sources/Annotations/MKMapAnnotationView.swift @@ -21,6 +21,8 @@ class MKMapAnnotationView: MKAnnotationView { func setup(for mapAnnotation: ViewMapAnnotation) { annotation = mapAnnotation.annotation clusteringIdentifier = mapAnnotation.clusteringIdentifier + displayPriority = mapAnnotation.displayPriority + collisionMode = mapAnnotation.collisionMode let controller = NativeHostingController(rootView: mapAnnotation.content) addSubview(controller.view) diff --git a/Sources/Annotations/ViewMapAnnotation.swift b/Sources/Annotations/ViewMapAnnotation.swift index 38fc01b..afd12ef 100644 --- a/Sources/Annotations/ViewMapAnnotation.swift +++ b/Sources/Annotations/ViewMapAnnotation.swift @@ -42,6 +42,8 @@ public struct ViewMapAnnotation: MapAnnotation { public let annotation: MKAnnotation let clusteringIdentifier: String? + let displayPriority: MKFeatureDisplayPriority + let collisionMode: MKAnnotationView.CollisionMode let content: Content // MARK: Initialization @@ -51,20 +53,28 @@ public struct ViewMapAnnotation: MapAnnotation { title: String? = nil, subtitle: String? = nil, clusteringIdentifier: String? = nil, + displayPriority: MKFeatureDisplayPriority = .required, + collisionMode: MKAnnotationView.CollisionMode = .rectangle, @ViewBuilder content: () -> Content ) { self.annotation = Annotation(coordinate: coordinate, title: title, subtitle: subtitle) self.clusteringIdentifier = clusteringIdentifier + self.displayPriority = displayPriority + self.collisionMode = collisionMode self.content = content() } public init( annotation: MKAnnotation, clusteringIdentifier: String? = nil, + displayPriority: MKFeatureDisplayPriority = .required, + collisionMode: MKAnnotationView.CollisionMode = .rectangle, @ViewBuilder content: () -> Content ) { self.annotation = annotation self.clusteringIdentifier = clusteringIdentifier + self.displayPriority = displayPriority + self.collisionMode = collisionMode self.content = content() }