This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios] Fix dequeue view variable scope #7423
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4745,8 +4745,8 @@ - (void)updateAnnotationViews | |
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,17 @@ - (void)updateAnnotationViews | |
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]; | ||
|
||
|
||
CGFloat largestHeight = _largestAnnotationViewSize.height; | ||
CGFloat largestWidth = _largestAnnotationViewSize.width; | ||
CGFloat viewHeight = CGRectGetHeight(self.frame); | ||
CGFloat viewWidth = CGRectGetWidth(self.frame); | ||
CLLocationCoordinate2D southwestCoordinate = [self convertPoint:{-largestWidth, viewHeight + largestHeight} | ||
toCoordinateFromView:self]; | ||
CLLocationCoordinate2D northeastCoordinate = [self convertPoint:{viewWidth + largestWidth, -largestHeight} | ||
toCoordinateFromView:self]; | ||
MGLCoordinateBounds coordinateBounds = {southwestCoordinate, northeastCoordinate}; | ||
|
||
// Enqueue (and move if required) offscreen annotation views | ||
for (id<MGLAnnotation> annotation in offscreenAnnotations) | ||
{ | ||
|
@@ -4795,17 +4798,16 @@ - (void)updateAnnotationViews | |
// 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(adjustedFrame) * 10.0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain this formula? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the concern is that a view might have a layer that overshoots the official bounds of the view and would thus peek out from the top edge of the map view, you could perhaps move the view so that its |
||
annotationView.frame = adjustedFrame; | ||
[self enqueueAnnotationViewForAnnotationContext:annotationContext]; | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code could use
UIEdgeInsetsInsetRect()
to apply a slop area around the map view’s bounds, then convert it using-convertRect:toCoordinateBoundsFromView:
.