我可以动画添加RMAnnotation到地图框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];}
但我在从Mapbox mapView动画中删除了RMAnnotation时遇到了问题。在下面的委托方法中,我尝试动画annotation.layer
展开到群集,但annotation.layer
突然变为零,annotation.layer
从地图中删除。所以没有动画发生!
- (void)mapView:(RMMapView *)mapView willHideLayerForAnnotation:(RMAnnotation *)annotation
你的想法是什么?我该如何为移除的RMAnnotation对象设置动画?