简单问题:
是否可以进行最大缩放级别? e.g。
region.span.latitudeDelta = 0.02;
region.span.longitudeDelta = 0.02;
我不想静态地做。考虑最大可能的缩放级别 我应该在哪里定义它?
答案 0 :(得分:1)
是的,只是实现委托方法mapView:regionDidChangeAnimated:
,我是这样做的:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
if (mapView.region.span.longitudeDelta < YOUR_VALUE) {
MKCoordinateRegion initialRegion;
initialRegion.center = mapView.region.center;
initialRegion.span.latitudeDelta = YOUR_VALUE;
initialRegion.span.longitudeDelta = YOUR_VALUE;
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:initialRegion];
[mapView setRegion:adjustedRegion animated:animated];
[mapView regionThatFits:adjustedRegion];
}
}