TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Display annotation Map View with offset

Forums > SwiftUI

Hello everyone,

I want to use a map view to display an annotation but when I place it on the view it always stays in at the center of the map view.

I want to give it some offset so that it goes a little bit upwards.

This is the code I have so far. Could you please help me?

let span = MKCoordinateSpan(latitudeDelta: CLLOcationDegrees, longitudeDelta: CLLOcationDegrees)
let region = MKCoordinateRegion(center: observationCoordinates, span: span)

let annotation =  MKPointAnnotation()
annotation.coordinate = observationCoordinate

uiView.setRegion(region, animated: true)
uiView.addAnnotation(annotation)

Thank you for your help.

3      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your 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.