简体   繁体   English

如何在地图上一起显示iOS 8上的当前位置和所有注释图钉

[英]How to show current location and all annotation pin on map together iOS 8

How will I show all added annotation and current location blue dot together on map visible rect? 如何在地图可见区域一起显示所有添加的注释和当前位置的蓝点?

That user can see all pins and his current location when map will load without dragging the map initially. 加载地图时,该用户可以看到所有图钉及其当前位置,而无需先拖动地图。 Code for ios8 and ios7.0. ios8和ios7.0的代码。

I am using MKMapKit of apple. 我正在使用苹果的MKMapKit。

try this 尝试这个

 MKMapRect zoomRect = MKMapRectNull;
 for (id <MKAnnotation> annotation in mapView.annotations) {
    MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
if (MKMapRectIsNull(zoomRect)) {
    zoomRect = pointRect;
} else {
    zoomRect = MKMapRectUnion(zoomRect, pointRect);
 }
}
[mapView setVisibleMapRect:zoomRect animated:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM