summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/app/MBXAnnotationView.m13
-rw-r--r--platform/ios/src/MGLAnnotationView.mm2
-rw-r--r--platform/ios/src/MGLMapView.mm18
3 files changed, 29 insertions, 4 deletions
diff --git a/platform/ios/app/MBXAnnotationView.m b/platform/ios/app/MBXAnnotationView.m
index c181211431..82af15314a 100644
--- a/platform/ios/app/MBXAnnotationView.m
+++ b/platform/ios/app/MBXAnnotationView.m
@@ -51,6 +51,7 @@
case MGLAnnotationViewDragStateCanceling:
break;
case MGLAnnotationViewDragStateEnding: {
+ self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 2, 2);
[UIView animateWithDuration:.4 delay:0 usingSpringWithDamping:.4 initialSpringVelocity:.5 options:UIViewAnimationOptionCurveLinear animations:^{
self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1, 1);
} completion:nil];
@@ -60,5 +61,17 @@
}
+- (nullable id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event
+{
+ if (([event isEqualToString:@"transform"] || [event isEqualToString:@"position"])
+ && self.dragState == MGLAnnotationViewDragStateNone)
+ {
+ CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:event];
+ animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
+ animation.speed = 0.1;
+ return animation;
+ }
+ return [super actionForLayer:layer forKey:event];
+}
@end
diff --git a/platform/ios/src/MGLAnnotationView.mm b/platform/ios/src/MGLAnnotationView.mm
index a1e93de108..494253b561 100644
--- a/platform/ios/src/MGLAnnotationView.mm
+++ b/platform/ios/src/MGLAnnotationView.mm
@@ -243,7 +243,7 @@
- (id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event
{
// Allow mbgl to drive animation of this view’s bounds.
- if ([event isEqualToString:@"bounds"])
+ if ([event isEqualToString:@"bounds"] || [event isEqualToString:@"position"])
{
return [NSNull null];
}
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 5c0d8d2a59..d7115d0a56 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1773,11 +1773,18 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
{
const mbgl::Point<double> point = MGLPointFromLocationCoordinate2D(annotation.coordinate);
- NSString *symbolName;
+ MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(annotationTag);
+ if (annotationContext.annotationView)
+ {
+ // Redundantly move the associated annotation view outside the scope of the animation-less transaction block in -updateAnnotationViews.
+ annotationContext.annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
+ }
+
MGLAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag];
- symbolName = annotationImage.styleIconIdentifier;
+ NSString *symbolName = annotationImage.styleIconIdentifier;
- _mbglMap->updateAnnotation(annotationTag, mbgl::SymbolAnnotation { point, symbolName.UTF8String});
+ // Update the annotation’s backing geometry to match the annotation model object. Any associated annotation view is also moved by side effect. However, -updateAnnotationViews disables the view’s animation actions, because it can’t distinguish between moves due to the viewport changing and moves due to the annotation’s coordinate changing.
+ _mbglMap->updateAnnotation(annotationTag, mbgl::SymbolAnnotation { point, symbolName.UTF8String });
if (annotationTag == _selectedAnnotationTag)
{
[self deselectAnnotation:annotation animated:YES];
@@ -4556,6 +4563,9 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
return;
}
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+
for (auto &pair : _annotationContextsByAnnotationTag)
{
CGRect viewPort = CGRectInset(self.bounds,
@@ -4592,6 +4602,8 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
}
}
+
+ [CATransaction commit];
}
- (void)enqueueAnnotationViewForAnnotationContext:(MGLAnnotationContext &)annotationContext