Reputation: 13890
I can animate adding RMAnnotation to map box mapView:
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation{
//create a new annotation marker
RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"pin"]];
marker.anchorPoint = CGPointMake(0.5, 1);
RestaurantAnnotation *restAnnotation = (RestaurantAnnotation *)annotation;
CLLocationCoordinate2D actualCoordinate = restAnnotation.coordinate;
CLLocationCoordinate2D containerCoordinate = restAnnotation.clusterAnnotation.coordinate;
[CATransaction begin];
[CATransaction setAnimationDuration:0.30];
[CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
CABasicAnimation *spreadOutAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
spreadOutAnimation.fromValue = [NSValue valueWithCGPoint:[self.mapView coordinateToPixel:containerCoordinate]];
spreadOutAnimation.toValue = [NSValue valueWithCGPoint:[self.mapView coordinateToPixel:actualCoordinate]];
[marker addAnimation:spreadOutAnimation forKey:@"spreadOut"];
[CATransaction commit];}
but I have a problem for animating removed RMAnnotation from Mapbox mapView. in the below delegate method I try to animate annotation.layer
spread in to cluster but annotation.layer
suddenly become nil and annotation.layer
gets removed from map. so no animation occur!
- (void)mapView:(RMMapView *)mapView willHideLayerForAnnotation:(RMAnnotation *)annotation
what's your idea? how should I animate removed RMAnnotation objects?
Upvotes: 1
Views: 296