Authored by Thomas Rasch

o Delegate callbacks for willHideLayerForAnnotation: and didHideLayerForAnnotation:

@@ -187,6 +187,9 @@ enum { @@ -187,6 +187,9 @@ enum {
187 BOOL _delegateHasAfterMapTouch; 187 BOOL _delegateHasAfterMapTouch;
188 BOOL _delegateHasShouldDragMarker; 188 BOOL _delegateHasShouldDragMarker;
189 BOOL _delegateHasDidDragMarker; 189 BOOL _delegateHasDidDragMarker;
  190 + BOOL _delegateHasLayerForAnnotation;
  191 + BOOL _delegateHasWillHideLayerForAnnotation;
  192 + BOOL _delegateHasDidHideLayerForAnnotation;
190 193
191 NSTimer *_decelerationTimer; 194 NSTimer *_decelerationTimer;
192 CGSize _decelerationDelta; 195 CGSize _decelerationDelta;
@@ -344,6 +344,10 @@ @@ -344,6 +344,10 @@
344 344
345 _delegateHasShouldDragMarker = [delegate respondsToSelector:@selector(mapView:shouldDragAnnotation:withEvent:)]; 345 _delegateHasShouldDragMarker = [delegate respondsToSelector:@selector(mapView:shouldDragAnnotation:withEvent:)];
346 _delegateHasDidDragMarker = [delegate respondsToSelector:@selector(mapView:didDragAnnotation:withEvent:)]; 346 _delegateHasDidDragMarker = [delegate respondsToSelector:@selector(mapView:didDragAnnotation:withEvent:)];
  347 +
  348 + _delegateHasLayerForAnnotation = [delegate respondsToSelector:@selector(mapView:layerForAnnotation:)];
  349 + _delegateHasWillHideLayerForAnnotation = [delegate respondsToSelector:@selector(mapView:willHideLayerForAnnotation:)];
  350 + _delegateHasDidHideLayerForAnnotation = [delegate respondsToSelector:@selector(mapView:didHideLayerForAnnotation:)];
347 } 351 }
348 352
349 - (id <RMMapViewDelegate>)delegate 353 - (id <RMMapViewDelegate>)delegate
@@ -1433,7 +1437,7 @@ double CubicEaseOut(double t, double start, double end) @@ -1433,7 +1437,7 @@ double CubicEaseOut(double t, double start, double end)
1433 { 1437 {
1434 [self correctScreenPosition:annotation]; 1438 [self correctScreenPosition:annotation];
1435 1439
1436 - if (annotation.layer == nil && [delegate respondsToSelector:@selector(mapView:layerForAnnotation:)]) 1440 + if (annotation.layer == nil && _delegateHasLayerForAnnotation)
1437 annotation.layer = [delegate mapView:self layerForAnnotation:annotation]; 1441 annotation.layer = [delegate mapView:self layerForAnnotation:annotation];
1438 if (annotation.layer == nil) 1442 if (annotation.layer == nil)
1439 continue; 1443 continue;
@@ -1448,8 +1452,10 @@ double CubicEaseOut(double t, double start, double end) @@ -1448,8 +1452,10 @@ double CubicEaseOut(double t, double start, double end)
1448 1452
1449 for (RMAnnotation *annotation in previousVisibleAnnotations) 1453 for (RMAnnotation *annotation in previousVisibleAnnotations)
1450 { 1454 {
  1455 + if (_delegateHasWillHideLayerForAnnotation) [delegate mapView:self willHideLayerForAnnotation:annotation];
1451 annotation.layer = nil; 1456 annotation.layer = nil;
1452 [visibleAnnotations removeObject:annotation]; 1457 [visibleAnnotations removeObject:annotation];
  1458 + if (_delegateHasDidHideLayerForAnnotation) [delegate mapView:self didHideLayerForAnnotation:annotation];
1453 } 1459 }
1454 1460
1455 // RMLog(@"%d annotations on screen, %d total", [[overlay sublayers] count], [annotations count]); 1461 // RMLog(@"%d annotations on screen, %d total", [[overlay sublayers] count], [annotations count]);
@@ -1467,7 +1473,7 @@ double CubicEaseOut(double t, double start, double end) @@ -1467,7 +1473,7 @@ double CubicEaseOut(double t, double start, double end)
1467 { 1473 {
1468 [self correctScreenPosition:annotation]; 1474 [self correctScreenPosition:annotation];
1469 if ([annotation isAnnotationWithinBounds:screenBounds]) { 1475 if ([annotation isAnnotationWithinBounds:screenBounds]) {
1470 - if (annotation.layer == nil && [delegate respondsToSelector:@selector(mapView:layerForAnnotation:)]) 1476 + if (annotation.layer == nil && _delegateHasLayerForAnnotation)
1471 annotation.layer = [delegate mapView:self layerForAnnotation:annotation]; 1477 annotation.layer = [delegate mapView:self layerForAnnotation:annotation];
1472 if (annotation.layer == nil) 1478 if (annotation.layer == nil)
1473 continue; 1479 continue;
@@ -1482,8 +1488,10 @@ double CubicEaseOut(double t, double start, double end) @@ -1482,8 +1488,10 @@ double CubicEaseOut(double t, double start, double end)
1482 } 1488 }
1483 lastLayer = annotation.layer; 1489 lastLayer = annotation.layer;
1484 } else { 1490 } else {
  1491 + if (_delegateHasWillHideLayerForAnnotation) [delegate mapView:self willHideLayerForAnnotation:annotation];
1485 annotation.layer = nil; 1492 annotation.layer = nil;
1486 [visibleAnnotations removeObject:annotation]; 1493 [visibleAnnotations removeObject:annotation];
  1494 + if (_delegateHasDidHideLayerForAnnotation) [delegate mapView:self didHideLayerForAnnotation:annotation];
1487 } 1495 }
1488 } 1496 }
1489 // RMLog(@"%d annotations on screen, %d total", [[overlay sublayers] count], [annotations count]); 1497 // RMLog(@"%d annotations on screen, %d total", [[overlay sublayers] count], [annotations count]);
@@ -35,6 +35,8 @@ @@ -35,6 +35,8 @@
35 @optional 35 @optional
36 36
37 - (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation; 37 - (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation;
  38 +- (void)mapView:(RMMapView *)mapView willHideLayerForAnnotation:(RMAnnotation *)annotation;
  39 +- (void)mapView:(RMMapView *)mapView didHideLayerForAnnotation:(RMAnnotation *)annotation;
38 40
39 - (void)beforeMapMove:(RMMapView *)map; 41 - (void)beforeMapMove:(RMMapView *)map;
40 - (void)afterMapMove:(RMMapView *)map ; 42 - (void)afterMapMove:(RMMapView *)map ;