本文介绍了如何在iOS MKMapView上获得最大缩放级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个应用程序在非常高(最大)的zoomLevel(高细节地图)上使用MKMapView
随着iOS7的推出,我几乎不能像以前那样接近地图。

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.

我正在使用mapView setRegion:方法。

I am using the mapView setRegion: method for this.

我一直在运行测试,结果如下:

I have been running tests and these are the results:

在全屏纵向模式mapview中横跨iOS版本:

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

有没有办法在iOS 7.0.3上以编程方式实现160米(最大缩放级别)

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)

推荐答案

此解决方案的积分可在Apple Developer foru的主题中转到YUF m:

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

它使用确定缩放级别,而不是setRegion。

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];

如果你保持centerCoordinate和eyeCoordinate相同,相机将直视下方。
高度可让您控制变焦。它不会一直降到零,但它会提供与之前iOS版本相同的缩放级别。

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.

这篇关于如何在iOS MKMapView上获得最大缩放级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:24