Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After trying different ways of limited MKMapView I've concluded that using mapDidChange, and resetting if you're center point goes outside of the boundaries works best, with animated: YES</p> <p>Here's how I do it (Using the New Zealand lat/Long span/center).</p> <pre><code>- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{ if ((mapView.region.span.latitudeDelta &gt; 15.589921 ) || (mapView.region.span.longitudeDelta &gt; 175.836914) ) { CLLocationCoordinate2D centerCoord = CLLocationCoordinate2DMake(-41.162114, 172.836914); MKCoordinateSpan spanOfNZ = MKCoordinateSpanMake(13.589921, 14.062500 ); MKCoordinateRegion NZRegion = MKCoordinateRegionMake(centerCoord, spanOfNZ); [mapView setRegion: NZRegion animated: YES]; } if (abs(abs(mapView.region.center.latitude) - 41.162114) &gt; (13.589921 / 2) ) { CLLocationCoordinate2D centerCoord = CLLocationCoordinate2DMake(-41.162114, 172.836914); MKCoordinateSpan spanOfNZ = MKCoordinateSpanMake(13.589921, 14.062500 ); MKCoordinateRegion NZRegion = MKCoordinateRegionMake(centerCoord, spanOfNZ); [mapView setRegion: NZRegion animated: YES]; } if (abs(abs(mapView.region.center.longitude) - 172.836914) &gt; (14.062500 / 2) ) { CLLocationCoordinate2D centerCoord = CLLocationCoordinate2DMake(-41.162114, 172.836914); MKCoordinateSpan spanOfNZ = MKCoordinateSpanMake(13.589921, 14.062500 ); MKCoordinateRegion NZRegion = MKCoordinateRegionMake(centerCoord, spanOfNZ); [mapView setRegion: NZRegion animated: YES]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload