summaryrefslogtreecommitdiff
path: root/platform/macos/src/MGLMapView.mm
diff options
context:
space:
mode:
authorFabian Guerra Soto <fabian.guerra@mapbox.com>2017-11-01 08:20:48 -0400
committerGitHub <noreply@github.com>2017-11-01 08:20:48 -0400
commit63f7963a93cb13ec9f7cc404b93bc874419f4624 (patch)
tree5787a0a198f67eeb75319c5df6285df6e537f09a /platform/macos/src/MGLMapView.mm
parent03d3aee6fc3a36e3b98b4692a33179dddeb50032 (diff)
downloadqtlocation-mapboxgl-63f7963a93cb13ec9f7cc404b93bc874419f4624.tar.gz
[ios, macos] Center shape annotation's callout when offscreen. (#10255)
* [ios, macos] Center annotation's anchor to tap point when coordinate center is offscreen. * [ios, macos] Update changelogs.
Diffstat (limited to 'platform/macos/src/MGLMapView.mm')
-rw-r--r--platform/macos/src/MGLMapView.mm14
1 files changed, 7 insertions, 7 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 1bb30cc464..8df6f4545d 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1488,7 +1488,7 @@ public:
if (hitAnnotationTag != _selectedAnnotationTag) {
id <MGLAnnotation> annotation = [self annotationWithTag:hitAnnotationTag];
NSAssert(annotation, @"Cannot select nonexistent annotation with tag %u", hitAnnotationTag);
- [self selectAnnotation:annotation];
+ [self selectAnnotation:annotation atPoint:gesturePoint];
}
} else {
[self deselectAnnotation:self.selectedAnnotation];
@@ -2216,11 +2216,11 @@ public:
- (void)selectAnnotation:(id <MGLAnnotation>)annotation
{
- // Only point annotations can be selected.
- if (!annotation || [annotation isKindOfClass:[MGLMultiPoint class]]) {
- return;
- }
+ [self selectAnnotation:annotation atPoint:NSZeroPoint];
+}
+- (void)selectAnnotation:(id <MGLAnnotation>)annotation atPoint:(NSPoint)gesturePoint
+{
id <MGLAnnotation> selectedAnnotation = self.selectedAnnotation;
if (annotation == selectedAnnotation) {
return;
@@ -2235,10 +2235,10 @@ public:
[self addAnnotation:annotation];
}
- // The annotation can’t be selected if no part of it is hittable.
+ // The annotation's anchor will bounce to the current click.
NSRect positioningRect = [self positioningRectForCalloutForAnnotationWithTag:annotationTag];
if (NSIsEmptyRect(NSIntersectionRect(positioningRect, self.bounds))) {
- return;
+ positioningRect = CGRectMake(gesturePoint.x, gesturePoint.y, positioningRect.size.width, positioningRect.size.height);
}
self.selectedAnnotation = annotation;