Search code examples
swiftannotationsmapkitmkmapviewrefresh

Swift MapKit : need to move map to show annotations after using addAnnotations()


After adding an annotation array using addAnnotations(), I need to move the map (using the mouse) for the annotations to appear! This is very annoying. lol

Does someone have an idea how to fix this?


Solution

  • It is recommended to do UI Changes on the main thread, are you adding the annotations on the main thread?

    When you add the annotations, try this:

    DispatchQueue.main.async {  
    
         yourMapView.addAnnotation(annotation)
    }
    

    Let me know if you have any more questions or if that resolved your issue