Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get to the max zoomlevel on iOS MKMapView

One of my apps uses the MKMapView at a very high (max) zoomLevel (high detail map) With the introduction of iOS7, I can't come nearly as close to the map as before.

I am using the mapView setRegion: method for this.

I have been running tests and these are the results:

spans across iOS versions in full screen portrait mode mapview:

 iOS 5.1:   140 meters
 iOS 6.1:    70 meters
 iOS 7.0.3: 281 meters
 iOS 7.0.3: 160 meters (if pinched manually!!)

Is there a way to achieve the 160 meters (the max zoomlevel) programmatically on iOS 7.0.3

(I know the horizontal span depends on the lattitude, so the number of meters is just an indication of proportion)

like image 679
Joris van Liempd iDeveloper Avatar asked Oct 29 '13 12:10

Joris van Liempd iDeveloper


1 Answers

Credits for this solution go to YUF in this thread on the Apple Developer forum:

It uses MKMapCamera to determine the zoom level, not setRegion.

MKMapCamera* camera = [MKMapCamera 
cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
              fromEyeCoordinate:(CLLocationCoordinate2D)eyeCoordinate
                    eyeAltitude:(CLLocationDistance)eyeAltitude];
[mapView setCamera:camera animated:NO];

If you keep centerCoordinate and eyeCoordinate the same, the camera will look straight down. The altitude will give you control over the zoom. It won't go all the way down to zero, but it will give equivalent zoom levels as on previous iOS versions.

like image 118
Joris van Liempd iDeveloper Avatar answered Sep 23 '22 15:09

Joris van Liempd iDeveloper