Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continuous zooming with MKMapView?

I am working with a MKMapView thats visible area (zoom level) is set with a slider. I set the visible area with a MKCoordinateRegion and setRegion:animated:.

The problem is that I don't seem to be able to get extremely precise control over the visible area. It's as if the latitude\longitude deltas snap to the default ~21 zoom levels provided by Google.

What I really want is similar to the behavior of the Map.app when pinching to zoom. It scales the view until the threshold for a new zoom level is reached, and then it renders the new map level.

Is there a simple way to access\emulate this behavior? How does it work?

Code I'm using:

MKCoordinateRegion region;
MKCoordinateSpan span;
CLLocationCoordinate2D center = {45.475969,-73.64095};
region.center = center;
span.latitudeDelta = 0.01;
span.longitudeDelta = 0.01;
region.span = span;

[mapView setRegion:region animated:TRUE];

If I use a delta of 0.01 or 0.013, I get the exact same map.

like image 915
Mike A Avatar asked Mar 08 '26 06:03

Mike A


1 Answers

The simple answer is that MapKit does not allow you to programatically set a zoom level other than the default 21 levels supplied by google. The region span you set will always "snap" to the closest one.

like image 81
Mike A Avatar answered Mar 10 '26 19:03

Mike A



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!