Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change zoom programmatically with MKUserTrackingModeFollowWithHeading

Tags:

ios

ios7

mapkit

I want to zoom out to include the nearest annotations while the map view is in MKUserTrackingModeFollowWithHeading mode.

I've tried to set the region like this:

MKCoordinateRegion currentRegion = self.mapView.region;
currentRegion.span.latitudeDelta *= 4;
currentRegion.span.longitudeDelta *= 4;
[self.mapView setRegion:currentRegion];

This zooms out the map 4x, but with the user tracking enabled, iOS automatically zooms back into the original zoom level with animation. I can't get any region to stick. I assume a MapRect would have the same behavior, but I haven't tried it.

Does anyone know of another way to do this?

According to the documentation on setUserTrackingMode:

If the map is zoomed out, the map view automatically zooms in on the user’s location, effectively changing the current visible region.

So I realize that this might be impossible. However, the user can pinch to zoom out, and the user tracking mode remains enabled without zooming back in. Any creative ideas are greatly appreciated.

like image 370
dmzza Avatar asked Nov 12 '22 21:11

dmzza


1 Answers

You can't control the zooming behavior when using the built-in tracking modes. You might want to check out something like the MapBox iOS SDK which has the same look and behavior as MapKit, but would allow you to customize this behavior.

like image 178
incanus Avatar answered Nov 15 '22 06:11

incanus