Search code examples
iosswiftswiftuiannotationsmapkit

SwiftUI - MapAnnotation is showing up in wrong position


I am trying to display multiple map annotations to Apple Maps In SwiftUI, but the annotations are showing in some wrong perspective. All positions are displayed bellow their right coordinates. If I zoom in the map, annotations are "travelling" to their normal coordinates. Is there any "perspective" calculated by MapKit and is it possible to switch off this behaviour?

Marker displayed below normal position: Position of marker

Marker displayed on his coordinates after zoom in: Zoom in on the position, the marker is on his good coordinates

Thank you!


Solution

  • I had this issue and i fixed it by changing the y position of the annotation to 1.0 like so:

    MapAnnotation(coordinate: job.coordinates!, anchorPoint:.init(x:0.5, y:1.0))