summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJordan Kiley <jmkiley@users.noreply.github.com>2017-04-12 11:30:28 -0700
committerGitHub <noreply@github.com>2017-04-12 11:30:28 -0700
commit258ac8219a741476965581a6c6ab866ab8c57fe5 (patch)
tree4c0d1f585a5b39d02df1273a413fbd0c73203c06 /platform
parent8926d3a791d9f291db5aa52d0db504ccc65485a9 (diff)
downloadqtlocation-mapboxgl-258ac8219a741476965581a6c6ab866ab8c57fe5.tar.gz
[ios] added check for annotation view animation (#8565)
Addressed #8489
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/app/MBXAnnotationView.m13
-rw-r--r--platform/ios/app/MBXViewController.m22
-rw-r--r--platform/ios/src/MGLMapView.mm3
3 files changed, 25 insertions, 13 deletions
diff --git a/platform/ios/app/MBXAnnotationView.m b/platform/ios/app/MBXAnnotationView.m
index 5b8011c55e..6877c5cd3d 100644
--- a/platform/ios/app/MBXAnnotationView.m
+++ b/platform/ios/app/MBXAnnotationView.m
@@ -49,17 +49,4 @@
}
-- (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/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 7aeb2042df..a7bab2108a 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -44,6 +44,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsAnnotationsRows) {
MBXSettingsAnnotations100Sprites,
MBXSettingsAnnotations1000Sprites,
MBXSettingsAnnotations10000Sprites,
+ MBXSettingsAnnotationAnimation,
MBXSettingsAnnotationsTestShapes,
MBXSettingsAnnotationsCustomCallout,
MBXSettingsAnnotationsQueryAnnotations,
@@ -314,6 +315,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
@"Add 100 Sprites",
@"Add 1,000 Sprites",
@"Add 10,000 Sprites",
+ @"Animate an Annotation View",
@"Add Test Shapes",
@"Add Point With Custom Callout",
@"Query Annotations",
@@ -498,6 +500,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
case MBXSettingsAnnotations10000Sprites:
[self parseFeaturesAddingCount:10000 usingViews:NO];
break;
+ case MBXSettingsAnnotationAnimation:
+ [self animateAnnotationView];
+ break;
case MBXSettingsAnnotationsTestShapes:
[self addTestShapes];
break;
@@ -713,6 +718,23 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
});
}
+- (void)animateAnnotationView
+ {
+ MGLPointAnnotation *annot = [[MGLPointAnnotation alloc] init];
+ annot.coordinate = self.mapView.centerCoordinate;
+ [self.mapView addAnnotation:annot];
+
+ // Move the annotation to a point that is offscreen.
+ CGPoint point = CGPointMake(self.view.frame.origin.x - 200, CGRectGetMidY(self.view.frame));
+
+ CLLocationCoordinate2D coord = [self.mapView convertPoint:point toCoordinateFromView:self.view];
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ [UIView animateWithDuration:10 animations:^{
+ annot.coordinate = coord;
+ }];
+ });
+ };
+
- (void)addTestShapes
{
// Pacific Northwest triangle
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 2476ec3e97..b4c9e9d2a7 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -5053,6 +5053,9 @@ public:
}
else
{
+ if (annotationView.layer.animationKeys.count > 0) {
+ continue;
+ }
CGRect adjustedFrame = annotationView.frame;
if (annotationView.layer.presentationLayer) {
adjustedFrame.origin.x = -CGRectGetWidth(annotationView.layer.presentationLayer.frame) * 10.0;