Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
416 views
in Technique[技术] by (71.8m points)

ios7 - 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)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...