Instance Method

setRegion:animated:

Changes the currently visible region and optionally animates the change.

Declaration

- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated;

Parameters

region

The new region to display in the map view.

animated

Specify YES if you want the map view to animate the transition to the new region or NO 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 setCenterCoordinate:animated: 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 regionThatFits: method to determine the region that will actually be set by the map.)

See Also

Manipulating the Visible Portion of the Map

region

The area currently displayed by the map view.

centerCoordinate

The map coordinate at the center of the map view.

- setCenterCoordinate:animated:

Changes the center coordinate of the map and optionally animates the change.

- showAnnotations:animated:

Sets the visible region so that the map displays the specified annotations.

visibleMapRect

The area currently displayed by the map view.

- setVisibleMapRect:animated:

Changes the currently visible portion of the map and optionally animates the change.

- setVisibleMapRect:edgePadding:animated:

Changes the currently visible portion of the map, allowing you to specify additional space around the edges.