summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-12-14 10:24:06 -0800
committerGitHub <noreply@github.com>2016-12-14 10:24:06 -0800
commitafd14cbfe5dea97c66e53da7ac2adaa16d969356 (patch)
tree7d0d5e98f3ae22fb8025c3547ac8de984d32fcec /platform
parent0eac5ea91e5f00807b566508d231f587293a9549 (diff)
downloadqtlocation-mapboxgl-afd14cbfe5dea97c66e53da7ac2adaa16d969356.tar.gz
[ios] Fix dequeue view variable scope (#7423)
Fix a bug where an annotation view variable was incorrectly re-declared which caused annotation views to not appear in some cases. This also refactors the guard that spot checks that annotation view are or are not visible.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/src/MGLMapView.mm28
1 files changed, 11 insertions, 17 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 14f17dab8c..b01ab09fb4 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -4745,8 +4745,8 @@ public:
if (!annotationView)
{
// This will dequeue views if the delegate implements the dequeue call
- MGLAnnotationView *annotationView = [self annotationViewForAnnotation:annotationContext.annotation];
-
+ annotationView = [self annotationViewForAnnotation:annotationContext.annotation];
+
if (annotationView)
{
annotationView.mapView = self;
@@ -4765,14 +4765,9 @@ public:
annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
}
}
-
- CGPoint upperLeft = {_largestAnnotationViewSize.width,_largestAnnotationViewSize.height};
- CGPoint lowerRight = {CGRectGetWidth(self.bounds) + _largestAnnotationViewSize.width,
- CGRectGetHeight(self.bounds) + _largestAnnotationViewSize.height};
-
- CLLocationCoordinate2D upperLeftCoordinate = [self convertPoint:upperLeft toCoordinateFromView:self];
- CLLocationCoordinate2D lowerRightCoordinate = [self convertPoint:lowerRight toCoordinateFromView:self];
-
+
+ MGLCoordinateBounds coordinateBounds = [self convertRect:viewPort toCoordinateBoundsFromView:self];
+
// Enqueue (and move if required) offscreen annotation views
for (id<MGLAnnotation> annotation in offscreenAnnotations)
{
@@ -4795,17 +4790,16 @@ public:
// moved and the enqueue operation is avoided. This allows us to keep the performance benefit of
// using the mbgl query result. It also forces views that have just gone offscreen to be cleared
// fully from view.
- if ((coordinate.latitude > upperLeftCoordinate.latitude || coordinate.latitude < lowerRightCoordinate.latitude) ||
- (coordinate.longitude < upperLeftCoordinate.longitude || coordinate.longitude > lowerRightCoordinate.longitude))
+ if (MGLCoordinateInCoordinateBounds(coordinate, coordinateBounds))
{
- CGRect adjustedFrame = annotationView.frame;
- adjustedFrame.origin.x = -CGRectGetWidth(adjustedFrame) * 2.0;
- annotationView.frame = adjustedFrame;
- [self enqueueAnnotationViewForAnnotationContext:annotationContext];
+ annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
}
else
{
- annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
+ CGRect adjustedFrame = annotationView.frame;
+ adjustedFrame.origin.x = CGRectGetWidth(annotationView.layer.presentationLayer.frame) * -2.0;
+ annotationView.frame = adjustedFrame;
+ [self enqueueAnnotationViewForAnnotationContext:annotationContext];
}
}
}