0

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.

I am using MKMapKit of apple.

Ajay_Kumar
  • 1,381
  • 10
  • 34
  • 62
  • Take a look at this question: http://stackoverflow.com/questions/4680649/zooming-mkmapview-to-fit-annotation-pins – Glorfindel May 14 '15 at 11:49
  • I am using showAnnotation function but it is not rendinering blue dots and when I am sending current location coordinate in showAnnotaion array it is working fine but pin is coming on blue dot and sometimes blue dot is also not see, only ping showing at current location location coordinate. And why Map is showing grid (not able to see street or country geo).? – Ajay_Kumar May 14 '15 at 11:58

1 Answers1

1

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];
Shruti
  • 1,849
  • 1
  • 13
  • 21
  • @Ajay_Kumar chekc this...http://stackoverflow.com/questions/21912339/ios-mkmapview-showannotationsanimated-with-padding – Shruti May 14 '15 at 11:51