summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
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];
}
}
}