2012-03-02 20 views
0

我在我的应用程序中的MKMapView上有很多pin注释,当它们中的很多视图在地图上时,iPhone变得非常慢并且没有响应。我希望用户能够缩放,但不能超过某个水平,例如2km平方或某物。MKMapViewprevent防止用户缩小超过一定范围

下面是我得到了什么:

-(void)viewWillAppear:(BOOL)animated{ 

[super viewWillAppear:YES]; 

[[BicycleLDNService sharedService] requestLocationForClient:self]; 

CLLocationCoordinate2D zoomLocation; 

CLLocation *deviceLocation = [[BicycleLDNService sharedService] deviceLocation]; 

zoomLocation.latitude = deviceLocation.coordinate.latitude; 
zoomLocation.longitude = deviceLocation.coordinate.longitude; 

MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*kMetresPerKilometre, 0.5*kMetresPerKilometre); 

MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:viewRegion];     

[self.mapView setRegion:adjustedRegion animated:YES]; 

self.mapView.zoomEnabled = YES; 

}

是否有某种属性或委托方法我可以使用吗?找不到在谷歌或这里有用的东西!

在此先感谢!

回答

0

跨度定义给定点上的地图的多少应该是可见的,也是如何设置缩放级别。 您可以通过使用

region.span.latitute=0.5; 
region.span.longitude=0.6; 

检查地图的缩放级别访问此再设置zoomEnabled物业NO。

mapView.zoomEnabled=NO;