diff options
Diffstat (limited to 'platform/macos/src/MGLMapView.mm')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 42fd24653e..bc9ac1e641 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -58,7 +58,7 @@ #import "NSURL+MGLAdditions.h" #import "NSColor+MGLAdditions.h" #import "NSImage+MGLAdditions.h" -#import "NSPredicate+MGLAdditions.h" +#import "NSPredicate+MGLPrivateAdditions.h" #import <QuartzCore/QuartzCore.h> #import <OpenGL/gl.h> @@ -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 |