4

我在地图(某些点)上显示了一些注释,地图放大或缩小以适合所有点 - 请参阅下面的工作代码。

MKPolygon *poly = [MKPolygon polygonWithPoints:somepoints count:i];
[self.mapView setRegion:MKCoordinateRegionForMapRect([poly boundingMapRect]) animated:NO];

:我想稍微扩大这个多边形以留出一些边距,我怎样才能扩大这个区域?

4

1 回答 1

11

您可以增加区域的跨度以增加一些边距:

MKCoordinateRegion region = MKCoordinateRegionForMapRect([poly boundingMapRect]);
region.span.latitudeDelta *= 1.2;   // Increase span by 20% to add some margin
region.span.longitudeDelta *= 1.2;
[self.mapView setRegion:region animated:YES];
于 2014-03-11T22:55:06.287 回答