I have a map that dynamically shows annotations as the user moves around. I am using the method regionDidChangeAnimated to know when the map has been moved and then I get annotations based on the new latitude and longitude. If the user zooms out then I am clustering the annotations.
I want to have it so that when a user clicks on a 'zoomed' out clustered annotation that the map should centre them at this new location and zoom in the map. This works. The only problem is that after the zooming the map no longer fires regionDidChangeAnimated. It's like the map has been unwired from it's methods. It also stops firing regionWillChangeAnimated.
To further complicate matters I am performing the zoom action not from the main view where the map resides but from an subclass of MKAnnotationView which draws the pins on the map. The code to reset the zoom:-
MKCoordinateRegion region;
if (map.region.span.latitudeDelta > 0.035 && map.region.span.latitudeDelta < 0.091){
//cluster bathrooms by post code go to detail level zoom
//currZoom = 10;
region.span.latitudeDelta = 0.018f;
region.span.longitudeDelta = 0.018f;
}
else if (map.region.span.latitudeDelta > 0.091){
//cluster bathrooms by city go to post code level
//currZoom = 8;
region.span.latitudeDelta = 0.06f;
region.span.longitudeDelta = 0.06f;
}
region.center.latitude = place.latitude;
region.center.longitude = place.longitude;
region = [map regionThatFits:region];
[map setRegion:region animated:YES];
Does setting the region on the map from the subclass cause the map to loose it's delegate? Once the user rezooms the map it's all wired up again and goes back to firing regionDidChangeAnimated when they move the map around.
Does anyone have any ideas as to how to fix this problem? Thanks in advance Cheryl