我有一個使用MapKit的應用程序。
我在調整地圖大小後計算當前的縮放比例。
通過(從MKGeometry.h
文件)調整MKMapView的縮放比例在繪製MKOverlay時不等於zoomScale
MKZoomScale provides a conversion factor between MKMapPoints and screen points.
When MKZoomScale = 1, 1 screen point = 1 MKMapPoint. When MKZoomScale is
0.5, 1 screen point = 2 MKMapPoints.
所以定義,我想這在這樣:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
CGSize screenSize = mapView.bounds.size;
MKMapRect mapRect = mapView.visibleMapRect;
MKZoomScale zoomScale = screenSize.width * screenSize.height/(mapRect.size.width * mapRect.size.height);
}
計算的zoomScale
符合定義(我檢查)。
我也得出一個覆蓋在我的MapView的方法
-(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context
的問題是,我的計算zoomScale
不等於一體,是傳遞給此方法的系統。我期望它們是平等的,因爲drawMapRect:
只是在調整大小後調用(實際上,調整大小會導致調用此方法)。
這裏有什麼問題?
我還試圖用
currentZoomScale = mapView.bounds.size.width/mapView.visibleMapRect.size.width;
,建議here,但這currentZoomScale
不等於傳遞給drawMapRect:
爲好。
我遇到了與您同樣的問題,而且我還沒有尚未找到解決方案... –
我也沒有:( – Anastasia