diff options
author | Julian Rex <julian.rex@gmail.com> | 2018-04-24 11:01:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-24 11:01:04 -0400 |
commit | 5b5549d644d026e093243b13e0770b9d34172ef9 (patch) | |
tree | 58aa4bc9cbc7cd78f00f4b2aed38570a21568717 /platform/macos/src/MGLMapView.mm | |
parent | fa6c6a3733323e855c1b825c9546093200cf0d62 (diff) | |
download | qtlocation-mapboxgl-5b5549d644d026e093243b13e0770b9d34172ef9.tar.gz |
[ios, macos] Fix for camera movement when selecting visible annotations (#11731)
Diffstat (limited to 'platform/macos/src/MGLMapView.mm')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 9cab9a76da..9a9e19c363 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -2249,8 +2249,16 @@ public: // The annotation's anchor will bounce to the current click. NSRect positioningRect = [self positioningRectForCalloutForAnnotationWithTag:annotationTag]; + // Check for invalid (zero) positioning rect + if (NSEqualRects(positioningRect, NSZeroRect)) { + CLLocationCoordinate2D origin = annotation.coordinate; + positioningRect.origin = [self convertCoordinate:origin toPointToView:self]; + } + if (!moveOnscreen && NSIsEmptyRect(NSIntersectionRect(positioningRect, self.bounds))) { - positioningRect = CGRectMake(gesturePoint.x, gesturePoint.y, positioningRect.size.width, positioningRect.size.height); + if (!NSEqualPoints(gesturePoint, NSZeroPoint)) { + positioningRect = CGRectMake(gesturePoint.x, gesturePoint.y, positioningRect.size.width, positioningRect.size.height); + } } self.selectedAnnotation = annotation; @@ -2464,6 +2472,8 @@ public: if (callout) { NSRect rect = [self positioningRectForCalloutForAnnotationWithTag:_selectedAnnotationTag]; + NSAssert(!NSEqualRects(rect, NSZeroRect), @"Positioning rect should be non-zero"); + if (!NSIsEmptyRect(NSIntersectionRect(rect, self.bounds))) { // It's possible that the current callout hasn't been presented (since the original |