Question

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)

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top