UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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.

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.