2013-02-21 32 views

回答

0

我想设置中心注释的数组中的坐标之一将成为你的目的

[_mapView setCenterCoordinate:annotationCoOrd zoomLevel:_zoomLvl animated:YES]; 

其中,annotationCoOrd是你的数组中的坐标之一, _zoomLvl是你的当前缩放级别。

如果你在这里发布你的代码会更有帮助。

的缩放级别

- (double)getZoomLevel{ 
MKCoordinateRegion reg=self.region; // the current visible region 
MKCoordinateSpan span=reg.span; // the deltas 
CLLocationCoordinate2D centerCoordinate=reg.center; // the center in degrees 
// Get the left and right most lonitudes 
CLLocationDegrees leftLongitude=(centerCoordinate.longitude-(span.longitudeDelta/2)); 
CLLocationDegrees rightLongitude=(centerCoordinate.longitude+(span.longitudeDelta/2)); 
CGSize mapSizeInPixels = self.bounds.size; // the size of the display window 

// Get the left and right side of the screen in fully zoomed-in pixels 
double leftPixel=[self longitudeToPixelSpaceX:leftLongitude]; 
double rightPixel=[self longitudeToPixelSpaceX:rightLongitude]; 
// The span of the screen width in fully zoomed-in pixels 
double pixelDelta=abs(rightPixel-leftPixel); 

// The ratio of the pixels to what we're actually showing 
double zoomScale= mapSizeInPixels.width /pixelDelta; 
// Inverse exponent 
double zoomExponent=log2(zoomScale); 
// Adjust our scale 
double zoomLevel=zoomExponent+20; 
return zoomLevel; 

}

- (double)longitudeToPixelSpaceX:(double)longitude 
{ 
return round(MERCATOR_OFFSET + MERCATOR_RADIUS * longitude * M_PI/180.0); 
} 

- (double)latitudeToPixelSpaceY:(double)latitude 
{ 
return round(MERCATOR_OFFSET - MERCATOR_RADIUS * logf((1 + sinf(latitude * M_PI/180.0))/(1 - sinf(latitude * M_PI/180.0)))/2.0); 
} 

获取地图的缩放级别在你的MKMapView实现添加上面的代码(覆盖的MKMapView实现)。

与放大招
+0

我怎么能得到的MKMapView当前缩放级别? – 2013-02-21 06:55:20

+0

检查我的答案上的编辑。可能对其他实现有用。但是,Gaurav的代码行将做到这一点:) – Kamath5687 2013-02-21 07:08:37

+0

@ Kamath5687:[self longitudeToPixelSpaceX:rightLongitude];请您详细说明函数吗? – 2013-02-21 07:55:12

0

贝罗使用方法

[mapview setCenterCoordinate:cordinate animated:YES];