mapbox / DEPRECATED-mapbox-ios-sdk

REPLACED – use https://www.mapbox.com/ios-sdk instead
https://github.com/mapbox/mapbox-gl-native
Other
323 stars 8 forks source link

Animate annotations #660

Closed haashem closed 9 years ago

haashem commented 9 years ago

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?

screen shot 2015-07-23 at 2 08 22 pm
incanus commented 9 years ago

See https://github.com/mapbox/mapbox-ios-sdk/issues/379#issuecomment-124022322