Center Map in SwiftUI to specific latitude and longitude.

I have a Map in SwiftUI using MapKit and the map has several annotations and MapCircles added to it. I need to have the ability to center the map on a specific latitude and longitude. The issue is that the map instead is centering so that all annotations and MapCircles etc. are visible.

How can I have it disregard items added to the map and center the map at a specific latitude and longitude and ideally, control the zoom level of the map also?

Answered by DTS Engineer in 812554022

You can use the position binding in the Map initializer to a bind to a MapCameraPosition. You can create a MapCamera with a center coordinate. Alternatively, you can bind the position to an MKCoordinateRegion.

— Ed Ford,  DTS Engineer

Accepted Answer

You can use the position binding in the Map initializer to a bind to a MapCameraPosition. You can create a MapCamera with a center coordinate. Alternatively, you can bind the position to an MKCoordinateRegion.

— Ed Ford,  DTS Engineer

Center Map in SwiftUI to specific latitude and longitude.
 
 
Q