diff options
author | Julian Rex <julian.rex@gmail.com> | 2018-09-26 12:19:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-26 12:19:26 -0400 |
commit | a9959773128f57e05f278d4d67ea167b8b6f73f5 (patch) | |
tree | 145b749e37b3af6d9f94697124704f6b279960b9 /platform/ios/src/MGLMapView.mm | |
parent | e6111a888e780789830daeae6634b90624fdb1e5 (diff) | |
download | qtlocation-mapboxgl-a9959773128f57e05f278d4d67ea167b8b6f73f5.tar.gz |
[ios] Fix for user location annotation jittering (and view annotations lagging) (#12895)
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 92d3724b03..d550a086cb 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -636,6 +636,9 @@ public: _glView.layer.opaque = _opaque; _glView.delegate = self; + CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer); + eaglLayer.presentsWithTransaction = YES; + [_glView bindDrawable]; [self insertSubview:_glView atIndex:0]; _glView.contentMode = UIViewContentModeCenter; @@ -985,8 +988,6 @@ public: if ( ! self.dormant || ! _rendererFrontend) { _rendererFrontend->render(); - - [self updateUserLocationAnnotationView]; } } @@ -1117,6 +1118,11 @@ public: { _needsDisplayRefresh = NO; + // Update UIKit elements, prior to rendering + [self updateUserLocationAnnotationView]; + [self updateAnnotationViews]; + [self updateCalloutView]; + [self.glView display]; } @@ -5709,8 +5715,7 @@ public: _isChangingAnnotationLayers = NO; [self.style didChangeValueForKey:@"layers"]; } - [self updateAnnotationViews]; - [self updateCalloutView]; + if ([self.delegate respondsToSelector:@selector(mapViewDidFinishRenderingFrame:fullyRendered:)]) { [self.delegate mapViewDidFinishRenderingFrame:self fullyRendered:fullyRendered]; @@ -5767,9 +5772,6 @@ public: return; } - [CATransaction begin]; - [CATransaction setDisableActions:YES]; - // If the map is pitched consider the viewport to be exactly the same as the bounds. // Otherwise, add a small buffer. CGFloat largestWidth = MAX(_largestAnnotationViewSize.width, CGRectGetWidth(self.frame)); @@ -5864,8 +5866,6 @@ public: } } } - - [CATransaction commit]; } - (void)updateCalloutView @@ -5951,12 +5951,8 @@ public: { // Smoothly move the user location annotation view and callout view to // the new location. - [UIView animateWithDuration:duration - delay:0 - options:(UIViewAnimationOptionCurveLinear | - UIViewAnimationOptionAllowUserInteraction | - UIViewAnimationOptionBeginFromCurrentState) - animations:^{ + + dispatch_block_t animation = ^{ if (self.selectedAnnotation == self.userLocation) { UIView <MGLCalloutView> *calloutView = self.calloutViewForSelectedAnnotation; @@ -5965,7 +5961,20 @@ public: userPoint.y - annotationView.center.y); } annotationView.center = userPoint; - } completion:NULL]; + }; + + if (duration > 0) { + [UIView animateWithDuration:duration + delay:0 + options:(UIViewAnimationOptionCurveLinear | + UIViewAnimationOptionAllowUserInteraction | + UIViewAnimationOptionBeginFromCurrentState) + animations:animation + completion:NULL]; + } + else { + animation(); + } _userLocationAnimationCompletionDate = [NSDate dateWithTimeIntervalSinceNow:duration]; annotationView.hidden = NO; |