Changes the currently visible region and optionally animates the change.
SDKs
- iOS 3.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.2+
Framework
- Map
Kit
Declaration
func setRegion(_ region: MKCoordinate Region, animated: Bool)
Parameters
region
The new region to display in the map view.
animated
Specify
true
if you want the map view to animate the transition to the new region orfalse
if you want the map to center on the specified region immediately.
Discussion
Changing just the center coordinate of the region can still cause the span values to change implicitly. The span values might change because that the distances represented by a span change at different latitudes and longitudes and the map view may need to adjust the span to account for the new location. If you want to change the center coordinate without changing the zoom level, use the set
instead.
When setting a new region, the map may adjust the value in the region
parameter so that it fits the visible area of the map precisely. This adjustment is normal and is done to ensure that the value in the region
property always reflects the visible portion of the map. However, it does mean that if you get the value of that property right after calling this method, the returned value may not match the value you set. (You can use the region
method to determine the region that will actually be set by the map.)