MKMapViewprevent用户缩小超出一定范围

时间:2012-03-02 08:45:28

标签: iphone objective-c ios delegates mkmapview

我的应用程序中的MKMapView上有很多引脚注释,当它们中的很多都在地图上时,iPhone变得非常慢并且没有响应。我希望用户能够缩放,但不能超过某个级别,例如2平方公尺或其他东西。

这就是我所拥有的:

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

}

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

提前致谢!

1 个答案:

答案 0 :(得分:0)

跨度定义给定点的地图应该可见多少,以及设置缩放级别的方式。 您可以使用

访问它
region.span.latitute=0.5;
region.span.longitude=0.6;

检查地图的缩放级别,然后设置zoomEnabled属性NO。

mapView.zoomEnabled=NO;