我已经实现了双击缩放使用以下代码。
CLLocation* currentLocation = [myArray objectAtIndex:5];
MKMapPoint annotationPoint = MKMapPointForCoordinate(currentLocation.coordinate);
MKMapRect zoomRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0.1, 0.1);
[mapView setVisibleMapRect:zoomRect animated:YES];当我第一次双击时,缩放到特定的引脚位置不工作,下一次工作正常。
如果从离引脚位置很远的不同位置双击,那么同样的问题,即缩放到特定引脚位置不起作用。
有谁能有个主意吗?
谢谢
发布于 2016-08-26 13:16:24
要使地图以坐标居中并缩小以显示坐标两侧的某些经度和纬度,请创建一个MKCoordinateRegion对象并更新MKMapView以显示新区域:
CLLocation* currentLocation = [myArray objectAtIndex:5];
// Create a span covering 0.1 degrees east to west and north to south
MKCoordinateSpan degreeSpan = MKCoordinateSpanMake(0.1, 0.1);
// Create a region that centers the span on currentLocation
MKCoordinateRegion region = MKCoordinateRegionMake(currentLocation.coordinate, degreeSpan);
// Update the map to show the new region
[mapView setRegion:region animated:YES];要进一步放大,请缩小度数范围的大小,例如:
MKCoordinateSpan degreeSpan = MKCoordinateSpanMake(0.05, 0.05);您还可以创建以米为单位的区域,这可以更容易地推断。下面创建了一个1000 x 1000米的区域:
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(currentLocation.coordinate, 1000, 1000);若要进一步放大,请减少米的数量。
https://stackoverflow.com/questions/38991899
复制相似问题