How to get to the max zoomlevel on iOS MKMapView

核能气质少年 提交于 2019-11-30 08:40:08

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/19658329/how-to-get-to-the-max-zoomlevel-on-ios-mkmapview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!