summaryrefslogtreecommitdiff
path: root/platform/macos/src
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-01-26 17:56:46 -0800
committerMinh Nguyễn <mxn@1ec5.org>2017-01-26 17:56:46 -0800
commita662508ddde4043ece36d8ea9b424368891d892c (patch)
treea6d7b857d59a2d9ea638bd68fe2b4b38392ef576 /platform/macos/src
parent00598432b0cc7b8aefd63b5162ad317917eb1154 (diff)
parent042831604bab0983262146047d6be0e453b0d55d (diff)
downloadqtlocation-mapboxgl-a662508ddde4043ece36d8ea9b424368891d892c.tar.gz
Merge branch 'release-ios-v3.4.0' into 1ec5-release-ios-v3.4.1-master
Diffstat (limited to 'platform/macos/src')
-rw-r--r--platform/macos/src/MGLMapView.h15
-rw-r--r--platform/macos/src/MGLMapView.mm14
2 files changed, 24 insertions, 5 deletions
diff --git a/platform/macos/src/MGLMapView.h b/platform/macos/src/MGLMapView.h
index efe83d1573..7440ffe793 100644
--- a/platform/macos/src/MGLMapView.h
+++ b/platform/macos/src/MGLMapView.h
@@ -45,6 +45,21 @@ NS_ASSUME_NONNULL_BEGIN
your Mapbox account. They also deter other developers from using your styles
without your permission.
+ Adding your own gesture recognizer to `MGLMapView` will block the corresponding
+ gesture recognizer built into `MGLMapView`. To avoid conflicts, define which
+ gesture recognizer takes precedence. For example, you can subclass
+ `NSClickGestureRecognizer` and override `-[NSGestureRecognizer shouldRequireFailureOfGestureRecognizer:]`,
+ so that your subclass will be invoked only if the default `MGLMapView` click
+ gesture recognizer fails:
+
+ ```swift
+ class MapClickGestureRecognizer: NSClickGestureRecognizer {
+ override func shouldRequireFailure(of otherGestureRecognizer: NSGestureRecognizer) -> Bool {
+ return otherGestureRecognizer is NSClickGestureRecognizer
+ }
+ }
+ ```
+
@note You are responsible for getting permission to use the map data and for
ensuring that your use adheres to the relevant terms of use.
*/
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index e93e4a40c5..6755c5de62 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -231,7 +231,11 @@ public:
- (void)awakeFromNib {
[super awakeFromNib];
- self.styleURL = nil;
+ // If the Style URL inspectable was not set, make sure to go through
+ // -setStyleURL: to load the default style.
+ if (_mbglMap->getStyleURL().empty()) {
+ self.styleURL = nil;
+ }
}
+ (NSArray *)restorableStateKeyPaths {
@@ -1250,7 +1254,7 @@ public:
- (MGLMapCamera *)cameraForCameraOptions:(const mbgl::CameraOptions &)cameraOptions {
CLLocationCoordinate2D centerCoordinate = MGLLocationCoordinate2DFromLatLng(cameraOptions.center ? *cameraOptions.center : _mbglMap->getLatLng());
double zoomLevel = cameraOptions.zoom ? *cameraOptions.zoom : self.zoomLevel;
- CLLocationDirection direction = cameraOptions.angle ? -MGLDegreesFromRadians(*cameraOptions.angle) : self.direction;
+ CLLocationDirection direction = cameraOptions.angle ? mbgl::util::wrap(-MGLDegreesFromRadians(*cameraOptions.angle), 0., 360.) : self.direction;
CGFloat pitch = cameraOptions.pitch ? MGLDegreesFromRadians(*cameraOptions.pitch) : _mbglMap->getPitch();
CLLocationDistance altitude = MGLAltitudeForZoomLevel(zoomLevel, pitch,
centerCoordinate.latitude,
@@ -1340,7 +1344,7 @@ public:
// the illusion that it has stayed in place during the entire gesture.
CGPoint cursorPoint = [self convertPoint:startPoint toView:nil];
cursorPoint = [self.window convertRectToScreen:{ startPoint, NSZeroSize }].origin;
- cursorPoint.y = [NSScreen mainScreen].frame.size.height - cursorPoint.y;
+ cursorPoint.y = self.window.screen.frame.size.height - cursorPoint.y;
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cursorPoint);
CGDisplayShowCursor(kCGDirectMainDisplay);
}
@@ -1825,7 +1829,7 @@ public:
}
// Opt into potentially expensive tooltip tracking areas.
- if (annotation.toolTip.length) {
+ if ([annotation respondsToSelector:@selector(toolTip)] && annotation.toolTip.length) {
_wantsToolTipRects = YES;
}
}
@@ -2360,7 +2364,7 @@ public:
for (MGLAnnotationTag annotationTag : annotationTags) {
MGLAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag];
id <MGLAnnotation> annotation = [self annotationWithTag:annotationTag];
- if (annotation.toolTip.length) {
+ if ([annotation respondsToSelector:@selector(toolTip)] && annotation.toolTip.length) {
// Add a tooltip tracking area over the annotation image’s
// frame, accounting for the image’s alignment rect.
NSImage *image = annotationImage.image;