我的最终目标是让按钮在地图上放大和缩小,但我找不到一种方法来保持中心坐标与缩放相同。我应该怎么做呢?
答案 0 :(得分:1)
您可以执行以下操作,抓取地图的当前区域,保持中心不变,但调整span
:
- (IBAction)zoomIn:(id)sender {
MKCoordinateRegion region = self.mapView.region;
region.span.latitudeDelta /= 2.0;
region.span.longitudeDelta /= 2.0;
[self.mapView setRegion:region animated:YES];
}
- (IBAction)zoomOut:(id)sender {
MKCoordinateRegion region = self.mapView.region;
region.span.latitudeDelta = MIN(region.span.latitudeDelta * 2.0, 180.0);
region.span.longitudeDelta = MIN(region.span.longitudeDelta * 2.0, 180.0);
[self.mapView setRegion:region animated:YES];
}