NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Map Markers to Screen Coordinates

Forums > SwiftUI

I am experimenting with drawing markers on a SwiftUI Map to items in a list below it. Am I running up against a SwiftUI limitation with Map from MapKit where I cannot convert a location on the map into screen coordinates? It kinda looks like there is "a way" to do it in UIKit but unfortunately I do not speak UIKit (and I lost track of the link to where I saw that).

I can approximate the effect I want using linear interpolation across the map region (from lat delta, lon delta, and center) and it looks fine in longitude but the projection is causing some walking in the latitude direction. It goes from bad to horrible if I zoom out to see most of the world. I have also tried converting the MKMapRegion to MKMapRect so that I can do the interpolation with x an y from MKMapPoints converted to screen points by also knowing the Map view size but I get about the same result here.

   

Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.