I have implemented double tap to zoom using following code.
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];
When i double tap first time, zoom to particular pin location not working, next time onwards working fine.
and if double tap from different location very far from pins locations,then same issue i.e. zoom to particular pin location not working.
Can any one have an idea Please?
To center the map on a coordinate and zoom out to show some longitude and latitude either side of the coordinate, create an
MKCoordinateRegion object and update the
MKMapView to show the new region:
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];
To zoom in further, reduce the size of the degree span, e.g.:
MKCoordinateSpan degreeSpan = MKCoordinateSpanMake(0.05, 0.05);
You can also create regions in meters, which can be easier to reason about. The following creates a 1000 x 1000 meter region:
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(currentLocation.coordinate, 1000, 1000);
To zoom in further, reduce the number of meters.