diff options
Diffstat (limited to 'platform/macos/src/MGLMapView.mm')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 92aa0a6c6b..0db059dcf2 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -19,6 +19,7 @@ #import "MGLAnnotationImage.h" #import "MGLMapViewDelegate.h" +#import <mbgl/map/map.hpp> #import <mbgl/map/view.hpp> #import <mbgl/annotation/annotation.hpp> #import <mbgl/map/camera.hpp> @@ -597,6 +598,10 @@ public: #pragma mark Style ++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyle { + return [NSSet setWithObject:@"styleURL"]; +} + - (nonnull NSURL *)styleURL { NSString *styleURLString = @(_mbglMap->getStyleURL().c_str()).mgl_stringOrNilIfEmpty; return styleURLString ? [NSURL URLWithString:styleURLString] : [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion]; @@ -618,10 +623,8 @@ public: } styleURL = styleURL.mgl_URLByStandardizingScheme; - [self willChangeValueForKey:@"style"]; - _style = [[MGLStyle alloc] initWithMapView:self]; + self.style = nil; _mbglMap->setStyleURL(styleURL.absoluteString.UTF8String); - [self didChangeValueForKey:@"style"]; } - (IBAction)reloadStyle:(__unused id)sender { @@ -630,6 +633,10 @@ public: self.styleURL = styleURL; } +- (mbgl::Map *)mbglMap { + return _mbglMap; +} + #pragma mark View hierarchy and drawing - (void)viewWillMoveToWindow:(NSWindow *)newWindow { @@ -922,11 +929,7 @@ public: } case mbgl::MapChangeDidFinishLoadingStyle: { - [self.style willChangeValueForKey:@"name"]; - [self.style willChangeValueForKey:@"sources"]; - [self.style didChangeValueForKey:@"sources"]; - [self.style willChangeValueForKey:@"layers"]; - [self.style didChangeValueForKey:@"layers"]; + self.style = [[MGLStyle alloc] initWithMapView:self]; if ([self.delegate respondsToSelector:@selector(mapView:didFinishLoadingStyle:)]) { [self.delegate mapView:self didFinishLoadingStyle:self.style]; @@ -2274,28 +2277,11 @@ public: } } -#pragma mark - Runtime styling - -- (mbgl::Map *)mbglMap -{ - return _mbglMap; -} - #pragma mark MGLMultiPointDelegate methods - (double)alphaForShapeAnnotation:(MGLShape *)annotation { - // The explicit -mapView:alphaForShapeAnnotation: delegate method is deprecated - // but still used, if implemented. When not implemented, call the stroke or - // fill color delegate methods and pull the alpha from the returned color. if (_delegateHasAlphasForShapeAnnotations) { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" return [self.delegate mapView:self alphaForShapeAnnotation:annotation]; -#pragma clang diagnostic pop - } else if ([annotation isKindOfClass:[MGLPolygon class]]) { - return [self fillColorForPolygonAnnotation:(MGLPolygon *)annotation].a ?: 1.0; - } else if ([annotation isKindOfClass:[MGLShape class]]) { - return [self strokeColorForShapeAnnotation:annotation].a ?: 1.0; } return 1.0; } @@ -2492,7 +2478,7 @@ public: if (menuItem.action == @selector(giveFeedback:)) { return YES; } - return [super validateMenuItem:menuItem]; + return NO; } #pragma mark Interface Builder methods |