[ios] Fix for user location annotation jittering (and view annotations lagging) (#12895)

This commit is contained in:
Julian Rex
2018-09-26 12:19:26 -04:00
committed by GitHub
parent e6111a888e
commit a995977312
3 changed files with 33 additions and 16 deletions

View File

@@ -3,3 +3,10 @@
#import <Foundation/Foundation.h>
#define MGL_EXPORT __attribute__((visibility ("default")))
/* Using a compound statement (GNU Extension, supported by clang) */
#define MGL_OBJC_DYNAMIC_CAST(object, type) \
({ \
__typeof__( object ) temp##__LINE__ = (object); \
(type *)([temp##__LINE__ isKindOfClass:[type class]] ? temp##__LINE__ : nil); \
})

View File

@@ -8,6 +8,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Added an `MGLSymbolStyleLayer.symbolZOrder` property for forcing point features in a symbol layer to be layered in the same order that they are specified in the layer’s associated source. ([#12783](https://github.com/mapbox/mapbox-gl-native/pull/12783))
* Fixed a crash when a style layer `*-pattern` property evaluates to nil for a particular feature. ([#12896](https://github.com/mapbox/mapbox-gl-native/pull/12896))
* Fixed an issue with view annotations (including the user location annotation) and the GL map lagging relative to each other. ([#12895](https://github.com/mapbox/mapbox-gl-native/pull/12895))
### Offline maps

View File

@@ -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;