我想知道当我在mapview中设置蓝点(我的位置)和另一个引脚时,是否有办法进行动态缩放…当我加载mapview时,我想在同一帧中显示这两个点.. .可能吗?谢谢
解决方法
对的,这是可能的.添加第二个注释后.此示例代码应适用于任意数量的注释:
MKMapRect zoomRect = MKMapRectNull; NSArray *annotations = [mapView annotations]; for (MKAnnotation *annotation in annotations) { MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate); MKMapRect pointRect = MKMapRectMake(annotationPoint.x,annotationPoint.y,0); if (MKMapRectIsNull(zoomRect)) { zoomRect = pointRect; } else { zoomRect = MKMapRectUnion(zoomRect,pointRect); } } [mapView setVisibleMapRect:zoomRect animated:YES];