coordinateRegion in map is deprecated in iOS 17.0

what we must to use we need to take the user show on map to take the location and get some data or what we must to do with map is it become only to show our data and the user just move around and see data with MapCameraPosition that heavy work i wish there is another way ? i need to take the cunterly location on map

Replies

You can extract the current MKCoordinateRegion from the camera by adding this to the Map view. Store visibleRegion in a @State variable in your view and anytime your Map camera changes, the region variable will update and you can use it as needed.

.onMapCameraChange(frequency: .continuous) { context in
    visibleRegion = context.region
}