MKMapView Zoom and Region

First of all, MKMapView does not use/have a predefined set of zoom levels like Google Maps does.

Instead, the visible area of a MKMapView is described using MKCoordinateRegion, which consists of two values:

  1. center (the center point of the region), and
  2. span (the size of the visible area around center).

The center point should be obvious (it’s the center point of the region.)

However, span (which is a MKCoordinateSpan) consists of:

  1. latitudeDelta (the vertical distance represented by the region), and
  2. longitudeDelta (the horizontal distance represented by the region).

A brief example. Here’s a toy MKCoordinateRegion:

  1. center:
    • latitude: 0
    • longitude: 0
  2. span:
    • latitudeDelta: 8
    • longitudeDelta: 6

The region could be described using its min and max coordinates as follows:

  1. min coordinate (lower left-hand point):
    • latitude: -4
    • longitude: -3
  2. max coordinate (upper right-hand point):
    • latitude: 4
    • longitude: 3

So, you can specify zoom levels around a center point by using an appropriately sized MKCoordinateSpan. As an approximation of Google’s numeric zoom levels, you could reverse engineer the span sizes that Google uses for a given zoom level and create a span, accordingly. (Google describes their view regions in the same way that MKMapView does, as a center + span, so you can pull these values out of Google Maps.)

As for restricting the region, you may play w/ this delegate method:

mapView:regionWillChangeAnimated

e.g. by resizing the region back into your allowed zoom levels. (Kind of like how table views will let you scroll past the edge, but will then rubber band back into place.) However, your mileage may vary, since I haven’t used it for this purpose.

btw, there are definite fixes/improvements in OS 3.1 to aspects of MapKit that were giving me trouble in 3.0.

Leave a Comment