2
votes

I'm using MKMapView to display some assets on a map. These asset can be clustered. When the user taps on a cluster I calculate a MKCoordinateRegion based on the location of the assets in the cluster then zoom the map in:

- (void)collectionView:(UICollectionView *)cv didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    NSIndexSet *indexSet = self.aggregates[indexPath.section];
    NSArray *assets = [self.assetsFetchResults objectsAtIndexes:indexSet];

    if(assets.count == 1){
        [self performSegueWithIdentifier:VWWSegueCollectionToFull sender:indexPath];
    } else {
        MKCoordinateRegion region = [self calculateRegionFromAssets:assets];
        NSLog(@"Current mapView.region: %f,%f", self.mapView.region.span.latitudeDelta, self.mapView.region.span.longitudeDelta);
        NSLog(@"Calculated map  region: %f,%f", region.span.latitudeDelta, region.span.longitudeDelta);
        [self.mapView setRegion:region animated:YES];
    }
}

Even though my function calculates the region correctly, the map only zooms into a certain level. The user can pinch and zoom in further with no issues, but it wont' let me programmatically get closer. The minimum span seems to be around 0.008x0.008, programmatically.

Here is what my code outputs when the user is first zoomed out, then a cluster is tapped:

2014-07-01 12:26:46.123 [6090:1074617] Current mapView.region: 0.407665,0.412912
2014-07-01 12:26:46.124 [6090:1074617] Calculated map  region: 0.000750,0.000755

The code then fails to zoom into a span of size 0.000750, 0.000750.

2014-07-01 12:26:50.330 [6090:1074617] Current mapView.region: 0.008123,0.008240
2014-07-01 12:26:50.331 [6090:1074617] Calculated map  region: 0.000750,0.000755

And trying again, same.

2014-07-01 12:26:53.349 [6090:1074617] Current mapView.region: 0.008123,0.008240
2014-07-01 12:26:53.350 [6090:1074617] Calculated map  region: 0.000750,0.000755

I slowly increased the minimum span that my function outputs, but it doesn't matter. The map just won't zoom in any closer.

If I can't find a way to get this to work I will take a look at setting the MKCamera

1

1 Answers

1
votes

It has been answered by others, but fairly hard to find on SO. Using MKMapCamera you can zoom down to 100 foot span, or less.

MKMapCamera *myCamera = [MKMapCamera cameraLookingAtCenterCoordinate:newLocation
                                                 fromEyeCoordinate:newLocation eyeAltitude:50];
[_appleMap setCamera:myCamera animated:false];