如何计算 MKMapView 的当前缩放比例?
How can I calculate the current zoomScale for an MKMapView?
使用以下代码:
#define MERCATOR_RADIUS 85445659.44705395 #define MAX_GOOGLE_LEVELS 20 - (double)getZoomLevel { CLLocationDegrees longitudeDelta = self.mapView.region.span.longitudeDelta; CGFloat mapWidthInPixels = self.mapView.bounds.size.width; double zoomScale = longitudeDelta * MERCATOR_RADIUS * M_PI / (180.0 * mapWidthInPixels); double zoomer = MAX_GOOGLE_LEVELS - log2( zoomScale ); if ( zoomer < 0 ) zoomer = 0; // zoomer = round(zoomer); return zoomer; }
getZoomLevel 方法的返回值将是 mapView 属性的当前缩放级别。
getZoomLevel
mapView
Use the following code:
The return value of the getZoomLevel method will be the current zoom level of your mapView property.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
使用以下代码:
getZoomLevel
方法的返回值将是mapView
属性的当前缩放级别。Use the following code:
The return value of the
getZoomLevel
method will be the current zoom level of yourmapView
property.