From 4903b19a599bafd5ea37eece818bbc7d2e2936f1 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Thu, 3 Nov 2016 16:46:23 -0700 Subject: [PATCH 1/5] [ios, macos wip] initial refactor for MGLFillStyleLayer --- platform/darwin/src/MGLFillStyleLayer.h | 3 +++ platform/darwin/src/MGLFillStyleLayer.mm | 20 +++++++++++++++++++- platform/darwin/src/MGLStyleLayer_Private.h | 11 +++++++++++ platform/ios/app/MBXViewController.m | 3 ++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/platform/darwin/src/MGLFillStyleLayer.h b/platform/darwin/src/MGLFillStyleLayer.h index 712bfea9980..87a21661779 100644 --- a/platform/darwin/src/MGLFillStyleLayer.h +++ b/platform/darwin/src/MGLFillStyleLayer.h @@ -96,6 +96,9 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *fillPattern; + +- (void)addToMapView:(MGLMapView *)mapView; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index e16e3b26522..9edeeadd2d5 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -2,6 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. #import "MGLSource.h" +#import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -16,15 +17,25 @@ @interface MGLFillStyleLayer () @end @implementation MGLFillStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::FillLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -118,4 +129,11 @@ - (void)setFillPattern:(MGLStyleValue *)fillPattern { return MGLStyleValueTransformer().toStyleValue(propertyValue); } +#pragma mark - + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLStyleLayer_Private.h b/platform/darwin/src/MGLStyleLayer_Private.h index 5fa01856eaf..bd2225ad049 100644 --- a/platform/darwin/src/MGLStyleLayer_Private.h +++ b/platform/darwin/src/MGLStyleLayer_Private.h @@ -5,9 +5,20 @@ #include +@class MGLMapView; + @interface MGLStyleLayer (Private) @property (nonatomic, readwrite, copy) NSString *identifier; @property (nonatomic) mbgl::style::Layer *layer; +/** + Adds the mbgl style layer that this object represents to the mbgl map. + + Once a mbgl style layer is added, ownership of the object is transferred to the + `mbgl::Map` and this object no longer has an active unique_ptr reference to the + `mbgl::style::Layer`. + */ +- (void)addToMapView:(MGLMapView *)mapView; + @end diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index a7ea4293008..519e4c863ef 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -768,7 +768,8 @@ - (void)styleGeoJSONSource MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"test" source:source]; fillLayer.fillColor = [MGLStyleValue valueWithRawValue:[UIColor purpleColor]]; - [self.mapView.style addLayer:fillLayer]; + [fillLayer addToMapView:self.mapView]; + } - (void)styleSymbolLayer From ec37fba9985ccd3d510fdf53287ed872f3c6427d Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Thu, 3 Nov 2016 17:45:09 -0700 Subject: [PATCH 2/5] [ios, macos wip] ownership refactor for MGLBackgroundStyleLayer and MGLForegroundStyleLayer subclasses --- platform/darwin/src/MGLBackgroundStyleLayer.h | 2 ++ .../darwin/src/MGLBackgroundStyleLayer.mm | 20 +++++++++++++++++- platform/darwin/src/MGLCircleStyleLayer.h | 2 ++ platform/darwin/src/MGLCircleStyleLayer.mm | 20 +++++++++++++++++- platform/darwin/src/MGLFillStyleLayer.mm | 2 +- platform/darwin/src/MGLLineStyleLayer.h | 2 ++ platform/darwin/src/MGLLineStyleLayer.mm | 20 +++++++++++++++++- platform/darwin/src/MGLRasterStyleLayer.h | 2 ++ platform/darwin/src/MGLRasterStyleLayer.mm | 20 +++++++++++++++++- platform/darwin/src/MGLSymbolStyleLayer.h | 2 ++ platform/darwin/src/MGLSymbolStyleLayer.mm | 21 ++++++++++++++++++- 11 files changed, 107 insertions(+), 6 deletions(-) diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.h b/platform/darwin/src/MGLBackgroundStyleLayer.h index 1c167fc91c6..6a9a9e18894 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.h +++ b/platform/darwin/src/MGLBackgroundStyleLayer.h @@ -50,6 +50,8 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, null_resettable) MGLStyleValue *backgroundOpacity; +- (void)addToMapView:(MGLMapView *)mapView; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index 33a105e5d53..761efb01565 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -2,6 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. #import "MGLSource.h" +#import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -16,15 +17,25 @@ @interface MGLBackgroundStyleLayer () @end @implementation MGLBackgroundStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier { if (self = [super initWithIdentifier:identifier]) { - _layer = new mbgl::style::BackgroundLayer(identifier.UTF8String); + [self commonInit:identifier]; } return self; } +- (void)commonInit:(NSString *)identifier +{ + auto layer = std::make_unique(identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + #pragma mark - Accessing the Paint Attributes - (void)setBackgroundColor:(MGLStyleValue *)backgroundColor { @@ -57,4 +68,11 @@ - (void)setBackgroundOpacity:(MGLStyleValue *)backgroundOpacity { return MGLStyleValueTransformer().toStyleValue(propertyValue); } +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h index 6006250cdf0..233b8ce98bc 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.h +++ b/platform/darwin/src/MGLCircleStyleLayer.h @@ -112,6 +112,8 @@ typedef NS_ENUM(NSUInteger, MGLCirclePitchScale) { */ @property (nonatomic, null_resettable) MGLStyleValue *circlePitchScale; +- (void)addToMapView:(MGLMapView *)mapView; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index 8fe97a05370..52e2b5e331d 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -2,6 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. #import "MGLSource.h" +#import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -16,15 +17,25 @@ @interface MGLCircleStyleLayer () @end @implementation MGLCircleStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::CircleLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -118,4 +129,11 @@ - (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { return MGLStyleValueTransformer().toStyleValue(propertyValue); } +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index 9edeeadd2d5..ddef3fb093f 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -129,7 +129,7 @@ - (void)setFillPattern:(MGLStyleValue *)fillPattern { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -#pragma mark - +#pragma mark - Add style layer to map - (void)addToMapView:(MGLMapView *)mapView { diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h index 663e9277182..d72209947b4 100644 --- a/platform/darwin/src/MGLLineStyleLayer.h +++ b/platform/darwin/src/MGLLineStyleLayer.h @@ -201,6 +201,8 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *linePattern; +- (void)addToMapView:(MGLMapView *)mapView; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 57724a0600e..ae304dcd709 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -2,6 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. #import "MGLSource.h" +#import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -16,15 +17,25 @@ @interface MGLLineStyleLayer () @end @implementation MGLLineStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::LineLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -190,4 +201,11 @@ - (void)setLinePattern:(MGLStyleValue *)linePattern { return MGLStyleValueTransformer().toStyleValue(propertyValue); } +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h index afae85001e3..73e1f84efe0 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.h +++ b/platform/darwin/src/MGLRasterStyleLayer.h @@ -69,6 +69,8 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, null_resettable) MGLStyleValue *rasterFadeDuration; +- (void)addToMapView:(MGLMapView *)mapView; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index f616e895181..f4bdfcb761d 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -2,6 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. #import "MGLSource.h" +#import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -16,15 +17,25 @@ @interface MGLRasterStyleLayer () @end @implementation MGLRasterStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::RasterLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + #pragma mark - Accessing the Paint Attributes - (void)setRasterOpacity:(MGLStyleValue *)rasterOpacity { @@ -97,4 +108,11 @@ - (void)setRasterFadeDuration:(MGLStyleValue *)rasterFadeDuration { return MGLStyleValueTransformer().toStyleValue(propertyValue); } +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h index 9bd943a34ed..6b52fca3e38 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.h +++ b/platform/darwin/src/MGLSymbolStyleLayer.h @@ -736,6 +736,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *textTranslateAnchor; +- (void)addToMapView:(MGLMapView *)mapView; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index a4c56fe2976..e0c17c8aa70 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -2,6 +2,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. #import "MGLSource.h" +#import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" @@ -16,15 +17,25 @@ @interface MGLSymbolStyleLayer () @end @implementation MGLSymbolStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::SymbolLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -530,4 +541,12 @@ - (void)setTextTranslateAnchor:(MGLStyleValue *)textTranslateAnchor { return MGLStyleValueTransformer().toStyleValue(propertyValue); } +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + + @end From 478f7a544c52d61c40ee7a4ed3201465e6aaa251 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Fri, 4 Nov 2016 10:00:24 -0700 Subject: [PATCH 3/5] [ios, macos wip] addToMapView became private, MGLStyleLayer.mm.ejs updated to import MGLMapView_Private header --- platform/darwin/src/MGLBackgroundStyleLayer.h | 2 -- .../darwin/src/MGLBackgroundStyleLayer.mm | 19 +----------------- platform/darwin/src/MGLCircleStyleLayer.h | 2 -- platform/darwin/src/MGLCircleStyleLayer.mm | 19 +----------------- platform/darwin/src/MGLFillStyleLayer.h | 3 --- platform/darwin/src/MGLFillStyleLayer.mm | 19 +----------------- platform/darwin/src/MGLLineStyleLayer.h | 2 -- platform/darwin/src/MGLLineStyleLayer.mm | 19 +----------------- platform/darwin/src/MGLRasterStyleLayer.h | 2 -- platform/darwin/src/MGLRasterStyleLayer.mm | 19 +----------------- platform/darwin/src/MGLStyle.mm | 3 +-- platform/darwin/src/MGLStyleLayer.mm.ejs | 1 + platform/darwin/src/MGLSymbolStyleLayer.h | 2 -- platform/darwin/src/MGLSymbolStyleLayer.mm | 20 +------------------ platform/ios/app/MBXViewController.m | 2 +- 15 files changed, 9 insertions(+), 125 deletions(-) diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.h b/platform/darwin/src/MGLBackgroundStyleLayer.h index 6a9a9e18894..1c167fc91c6 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.h +++ b/platform/darwin/src/MGLBackgroundStyleLayer.h @@ -50,8 +50,6 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, null_resettable) MGLStyleValue *backgroundOpacity; -- (void)addToMapView:(MGLMapView *)mapView; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index 761efb01565..a501d537f7c 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -17,25 +17,15 @@ @interface MGLBackgroundStyleLayer () @end @implementation MGLBackgroundStyleLayer -{ - std::unique_ptr _pendingLayer; -} - (instancetype)initWithIdentifier:(NSString *)identifier { if (self = [super initWithIdentifier:identifier]) { - [self commonInit:identifier]; + _layer = new mbgl::style::BackgroundLayer(identifier.UTF8String); } return self; } -- (void)commonInit:(NSString *)identifier -{ - auto layer = std::make_unique(identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - #pragma mark - Accessing the Paint Attributes - (void)setBackgroundColor:(MGLStyleValue *)backgroundColor { @@ -68,11 +58,4 @@ - (void)setBackgroundOpacity:(MGLStyleValue *)backgroundOpacity { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -#pragma mark - Add style layer to map - -- (void)addToMapView:(MGLMapView *)mapView -{ - mapView.mbglMap->addLayer(std::move(_pendingLayer)); -} - @end diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h index 233b8ce98bc..6006250cdf0 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.h +++ b/platform/darwin/src/MGLCircleStyleLayer.h @@ -112,8 +112,6 @@ typedef NS_ENUM(NSUInteger, MGLCirclePitchScale) { */ @property (nonatomic, null_resettable) MGLStyleValue *circlePitchScale; -- (void)addToMapView:(MGLMapView *)mapView; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index 52e2b5e331d..b273f8744a1 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -17,25 +17,15 @@ @interface MGLCircleStyleLayer () @end @implementation MGLCircleStyleLayer -{ - std::unique_ptr _pendingLayer; -} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + _layer = new mbgl::style::CircleLayer(identifier.UTF8String, source.identifier.UTF8String); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -129,11 +119,4 @@ - (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -#pragma mark - Add style layer to map - -- (void)addToMapView:(MGLMapView *)mapView -{ - mapView.mbglMap->addLayer(std::move(_pendingLayer)); -} - @end diff --git a/platform/darwin/src/MGLFillStyleLayer.h b/platform/darwin/src/MGLFillStyleLayer.h index 87a21661779..712bfea9980 100644 --- a/platform/darwin/src/MGLFillStyleLayer.h +++ b/platform/darwin/src/MGLFillStyleLayer.h @@ -96,9 +96,6 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *fillPattern; - -- (void)addToMapView:(MGLMapView *)mapView; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index ddef3fb093f..83fa2ffb22a 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -17,25 +17,15 @@ @interface MGLFillStyleLayer () @end @implementation MGLFillStyleLayer -{ - std::unique_ptr _pendingLayer; -} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + _layer = new mbgl::style::FillLayer(identifier.UTF8String, source.identifier.UTF8String); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -129,11 +119,4 @@ - (void)setFillPattern:(MGLStyleValue *)fillPattern { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -#pragma mark - Add style layer to map - -- (void)addToMapView:(MGLMapView *)mapView -{ - mapView.mbglMap->addLayer(std::move(_pendingLayer)); -} - @end diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h index d72209947b4..663e9277182 100644 --- a/platform/darwin/src/MGLLineStyleLayer.h +++ b/platform/darwin/src/MGLLineStyleLayer.h @@ -201,8 +201,6 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *linePattern; -- (void)addToMapView:(MGLMapView *)mapView; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index ae304dcd709..15c9180159b 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -17,25 +17,15 @@ @interface MGLLineStyleLayer () @end @implementation MGLLineStyleLayer -{ - std::unique_ptr _pendingLayer; -} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + _layer = new mbgl::style::LineLayer(identifier.UTF8String, source.identifier.UTF8String); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -201,11 +191,4 @@ - (void)setLinePattern:(MGLStyleValue *)linePattern { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -#pragma mark - Add style layer to map - -- (void)addToMapView:(MGLMapView *)mapView -{ - mapView.mbglMap->addLayer(std::move(_pendingLayer)); -} - @end diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h index 73e1f84efe0..afae85001e3 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.h +++ b/platform/darwin/src/MGLRasterStyleLayer.h @@ -69,8 +69,6 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, null_resettable) MGLStyleValue *rasterFadeDuration; -- (void)addToMapView:(MGLMapView *)mapView; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index f4bdfcb761d..e1c415561c5 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -17,25 +17,15 @@ @interface MGLRasterStyleLayer () @end @implementation MGLRasterStyleLayer -{ - std::unique_ptr _pendingLayer; -} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + _layer = new mbgl::style::RasterLayer(identifier.UTF8String, source.identifier.UTF8String); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - #pragma mark - Accessing the Paint Attributes - (void)setRasterOpacity:(MGLStyleValue *)rasterOpacity { @@ -108,11 +98,4 @@ - (void)setRasterFadeDuration:(MGLStyleValue *)rasterFadeDuration { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -#pragma mark - Add style layer to map - -- (void)addToMapView:(MGLMapView *)mapView -{ - mapView.mbglMap->addLayer(std::move(_pendingLayer)); -} - @end diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index a17b7d6b743..d1261faf709 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -179,8 +179,7 @@ - (void)addLayer:(MGLStyleLayer *)layer @"Make sure the style layer was created as a member of a concrete subclass of MGLStyleLayer.", layer]; } - - self.mapView.mbglMap->addLayer(std::unique_ptr(layer.layer)); + [layer addToMapView:self.mapView]; } - (void)insertLayer:(MGLStyleLayer *)layer belowLayer:(MGLStyleLayer *)otherLayer diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 3678e9ec52a..165fc3e1895 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -7,6 +7,7 @@ // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. #import "MGLSource.h" +#import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h index 6b52fca3e38..9bd943a34ed 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.h +++ b/platform/darwin/src/MGLSymbolStyleLayer.h @@ -736,8 +736,6 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *textTranslateAnchor; -- (void)addToMapView:(MGLMapView *)mapView; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index e0c17c8aa70..8371e198e87 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -17,25 +17,15 @@ @interface MGLSymbolStyleLayer () @end @implementation MGLSymbolStyleLayer -{ - std::unique_ptr _pendingLayer; -} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + _layer = new mbgl::style::SymbolLayer(identifier.UTF8String, source.identifier.UTF8String); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -541,12 +531,4 @@ - (void)setTextTranslateAnchor:(MGLStyleValue *)textTranslateAnchor { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -#pragma mark - Add style layer to map - -- (void)addToMapView:(MGLMapView *)mapView -{ - mapView.mbglMap->addLayer(std::move(_pendingLayer)); -} - - @end diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 519e4c863ef..11247ea3f7e 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -768,7 +768,7 @@ - (void)styleGeoJSONSource MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"test" source:source]; fillLayer.fillColor = [MGLStyleValue valueWithRawValue:[UIColor purpleColor]]; - [fillLayer addToMapView:self.mapView]; + [self.mapView.style addLayer:fillLayer]; } From 20c1ba816cad10c444f4c6b0e8ae005eb73aacb1 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Fri, 4 Nov 2016 10:27:58 -0700 Subject: [PATCH 4/5] [ios, macos wip] added missing selectors to MGLStyleLayer.mm.ejs template --- .../darwin/src/MGLBackgroundStyleLayer.mm | 19 ++++++++++++- platform/darwin/src/MGLCircleStyleLayer.mm | 20 ++++++++++++- platform/darwin/src/MGLFillStyleLayer.mm | 20 ++++++++++++- platform/darwin/src/MGLLineStyleLayer.mm | 20 ++++++++++++- platform/darwin/src/MGLRasterStyleLayer.mm | 20 ++++++++++++- platform/darwin/src/MGLStyleLayer.mm.ejs | 28 +++++++++++++++++-- platform/darwin/src/MGLSymbolStyleLayer.mm | 20 ++++++++++++- 7 files changed, 139 insertions(+), 8 deletions(-) diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index a501d537f7c..f404b5a2a9a 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -17,14 +17,23 @@ @interface MGLBackgroundStyleLayer () @end @implementation MGLBackgroundStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier { if (self = [super initWithIdentifier:identifier]) { - _layer = new mbgl::style::BackgroundLayer(identifier.UTF8String); + [self commonInit:identifier]; } return self; } +- (void)commonInit:(NSString *)identifier +{ + auto layer = std::make_unique(identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} #pragma mark - Accessing the Paint Attributes @@ -58,4 +67,12 @@ - (void)setBackgroundOpacity:(MGLStyleValue *)backgroundOpacity { return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index b273f8744a1..06ad7d2eef5 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -17,15 +17,25 @@ @interface MGLCircleStyleLayer () @end @implementation MGLCircleStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::CircleLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -119,4 +129,12 @@ - (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index 83fa2ffb22a..75a6d6610ec 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -17,15 +17,25 @@ @interface MGLFillStyleLayer () @end @implementation MGLFillStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::FillLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -119,4 +129,12 @@ - (void)setFillPattern:(MGLStyleValue *)fillPattern { return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 15c9180159b..11599dfd817 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -17,15 +17,25 @@ @interface MGLLineStyleLayer () @end @implementation MGLLineStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::LineLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -191,4 +201,12 @@ - (void)setLinePattern:(MGLStyleValue *)linePattern { return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index e1c415561c5..b4bc08ce79e 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -17,15 +17,25 @@ @interface MGLRasterStyleLayer () @end @implementation MGLRasterStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::RasterLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + #pragma mark - Accessing the Paint Attributes - (void)setRasterOpacity:(MGLStyleValue *)rasterOpacity { @@ -98,4 +108,12 @@ - (void)setRasterFadeDuration:(MGLStyleValue *)rasterFadeDuration { return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 165fc3e1895..1e784d5ef79 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -22,23 +22,39 @@ @end @implementation MGL<%- camelize(type) %>StyleLayer +{ + std::unique_ptrLayer> _pendingLayer; +} <% if (type == 'background') { -%> - (instancetype)initWithIdentifier:(NSString *)identifier { if (self = [super initWithIdentifier:identifier]) { - _layer = new mbgl::style::<%- camelize(type) %>Layer(identifier.UTF8String); + [self commonInit:identifier]; } return self; } +- (void)commonInit:(NSString *)identifier +{ + auto layer = std::make_uniqueLayer>(identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} <% } else { -%> - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::<%- camelize(type) %>Layer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } + +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_uniqueLayer>(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} <% } -%> <% if (type !== 'background' && type !== 'raster') { -%> @@ -96,4 +112,12 @@ <% } -%> <% } -%> + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 8371e198e87..4244a0a3eb2 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -17,15 +17,25 @@ @interface MGLSymbolStyleLayer () @end @implementation MGLSymbolStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - _layer = new mbgl::style::SymbolLayer(identifier.UTF8String, source.identifier.UTF8String); + [self commonInit:identifier source:source]; } return self; } +- (void)commonInit:(NSString *)identifier source:(MGLSource *)source +{ + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.layer = _pendingLayer.get(); +} + - (NSString *)sourceLayerIdentifier { auto layerID = self.layer->getSourceLayer(); @@ -531,4 +541,12 @@ - (void)setTextTranslateAnchor:(MGLStyleValue *)textTranslateAnchor { return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + mapView.mbglMap->addLayer(std::move(_pendingLayer)); +} + @end From 8fba1ac12f0fdd0855980f54a7daff57e523f048 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Fri, 4 Nov 2016 12:36:12 -0700 Subject: [PATCH 5/5] [ios, macos wip] commonInit pattern removed, standardized the way to add StyleLayers to map --- .../darwin/src/MGLBackgroundStyleLayer.mm | 37 +-- platform/darwin/src/MGLCircleStyleLayer.mm | 60 ++--- platform/darwin/src/MGLFillStyleLayer.mm | 60 ++--- platform/darwin/src/MGLLineStyleLayer.mm | 88 +++---- platform/darwin/src/MGLRasterStyleLayer.mm | 52 ++-- platform/darwin/src/MGLStyle.mm | 11 +- platform/darwin/src/MGLStyleLayer.mm.ejs | 51 ++-- platform/darwin/src/MGLStyleLayer_Private.h | 21 +- platform/darwin/src/MGLSymbolStyleLayer.mm | 224 +++++++++--------- 9 files changed, 331 insertions(+), 273 deletions(-) diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index f404b5a2a9a..38c97e8d468 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -12,7 +12,7 @@ @interface MGLBackgroundStyleLayer () -@property (nonatomic) mbgl::style::BackgroundLayer *layer; +@property (nonatomic) mbgl::style::BackgroundLayer *rawLayer; @end @@ -24,46 +24,43 @@ @implementation MGLBackgroundStyleLayer - (instancetype)initWithIdentifier:(NSString *)identifier { if (self = [super initWithIdentifier:identifier]) { - [self commonInit:identifier]; + auto layer = std::make_unique(identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } -- (void)commonInit:(NSString *)identifier -{ - auto layer = std::make_unique(identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} + #pragma mark - Accessing the Paint Attributes - (void)setBackgroundColor:(MGLStyleValue *)backgroundColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(backgroundColor); - self.layer->setBackgroundColor(mbglValue); + self.rawLayer->setBackgroundColor(mbglValue); } - (MGLStyleValue *)backgroundColor { - auto propertyValue = self.layer->getBackgroundColor() ?: self.layer->getDefaultBackgroundColor(); + auto propertyValue = self.rawLayer->getBackgroundColor() ?: self.rawLayer->getDefaultBackgroundColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setBackgroundPattern:(MGLStyleValue *)backgroundPattern { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(backgroundPattern); - self.layer->setBackgroundPattern(mbglValue); + self.rawLayer->setBackgroundPattern(mbglValue); } - (MGLStyleValue *)backgroundPattern { - auto propertyValue = self.layer->getBackgroundPattern() ?: self.layer->getDefaultBackgroundPattern(); + auto propertyValue = self.rawLayer->getBackgroundPattern() ?: self.rawLayer->getDefaultBackgroundPattern(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setBackgroundOpacity:(MGLStyleValue *)backgroundOpacity { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(backgroundOpacity); - self.layer->setBackgroundOpacity(mbglValue); + self.rawLayer->setBackgroundOpacity(mbglValue); } - (MGLStyleValue *)backgroundOpacity { - auto propertyValue = self.layer->getBackgroundOpacity() ?: self.layer->getDefaultBackgroundOpacity(); + auto propertyValue = self.rawLayer->getBackgroundOpacity() ?: self.rawLayer->getDefaultBackgroundOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -72,7 +69,17 @@ - (void)setBackgroundOpacity:(MGLStyleValue *)backgroundOpacity { - (void)addToMapView:(MGLMapView *)mapView { - mapView.mbglMap->addLayer(std::move(_pendingLayer)); + [self addToMapView:mapView belowLayer:nil]; +} + +- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer +{ + if (otherLayer) { + const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; + mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId); + } else { + mapView.mbglMap->addLayer(std::move(_pendingLayer)); + } } @end diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index 06ad7d2eef5..13eedf3f960 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -12,7 +12,7 @@ @interface MGLCircleStyleLayer () -@property (nonatomic) mbgl::style::CircleLayer *layer; +@property (nonatomic) mbgl::style::CircleLayer *rawLayer; @end @@ -24,108 +24,104 @@ @implementation MGLCircleStyleLayer - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - (NSString *)sourceLayerIdentifier { - auto layerID = self.layer->getSourceLayer(); + auto layerID = self.rawLayer->getSourceLayer(); return layerID.empty() ? nil : @(layerID.c_str()); } - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { - self.layer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); + self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } - (void)setPredicate:(NSPredicate *)predicate { - self.layer->setFilter(predicate.mgl_filter); + self.rawLayer->setFilter(predicate.mgl_filter); } - (NSPredicate *)predicate { - return [NSPredicate mgl_predicateWithFilter:self.layer->getFilter()]; + return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } #pragma mark - Accessing the Paint Attributes - (void)setCircleRadius:(MGLStyleValue *)circleRadius { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleRadius); - self.layer->setCircleRadius(mbglValue); + self.rawLayer->setCircleRadius(mbglValue); } - (MGLStyleValue *)circleRadius { - auto propertyValue = self.layer->getCircleRadius() ?: self.layer->getDefaultCircleRadius(); + auto propertyValue = self.rawLayer->getCircleRadius() ?: self.rawLayer->getDefaultCircleRadius(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setCircleColor:(MGLStyleValue *)circleColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleColor); - self.layer->setCircleColor(mbglValue); + self.rawLayer->setCircleColor(mbglValue); } - (MGLStyleValue *)circleColor { - auto propertyValue = self.layer->getCircleColor() ?: self.layer->getDefaultCircleColor(); + auto propertyValue = self.rawLayer->getCircleColor() ?: self.rawLayer->getDefaultCircleColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setCircleBlur:(MGLStyleValue *)circleBlur { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleBlur); - self.layer->setCircleBlur(mbglValue); + self.rawLayer->setCircleBlur(mbglValue); } - (MGLStyleValue *)circleBlur { - auto propertyValue = self.layer->getCircleBlur() ?: self.layer->getDefaultCircleBlur(); + auto propertyValue = self.rawLayer->getCircleBlur() ?: self.rawLayer->getDefaultCircleBlur(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setCircleOpacity:(MGLStyleValue *)circleOpacity { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleOpacity); - self.layer->setCircleOpacity(mbglValue); + self.rawLayer->setCircleOpacity(mbglValue); } - (MGLStyleValue *)circleOpacity { - auto propertyValue = self.layer->getCircleOpacity() ?: self.layer->getDefaultCircleOpacity(); + auto propertyValue = self.rawLayer->getCircleOpacity() ?: self.rawLayer->getDefaultCircleOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setCircleTranslate:(MGLStyleValue *)circleTranslate { auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(circleTranslate); - self.layer->setCircleTranslate(mbglValue); + self.rawLayer->setCircleTranslate(mbglValue); } - (MGLStyleValue *)circleTranslate { - auto propertyValue = self.layer->getCircleTranslate() ?: self.layer->getDefaultCircleTranslate(); + auto propertyValue = self.rawLayer->getCircleTranslate() ?: self.rawLayer->getDefaultCircleTranslate(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setCircleTranslateAnchor:(MGLStyleValue *)circleTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleTranslateAnchor); - self.layer->setCircleTranslateAnchor(mbglValue); + self.rawLayer->setCircleTranslateAnchor(mbglValue); } - (MGLStyleValue *)circleTranslateAnchor { - auto propertyValue = self.layer->getCircleTranslateAnchor() ?: self.layer->getDefaultCircleTranslateAnchor(); + auto propertyValue = self.rawLayer->getCircleTranslateAnchor() ?: self.rawLayer->getDefaultCircleTranslateAnchor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circlePitchScale); - self.layer->setCirclePitchScale(mbglValue); + self.rawLayer->setCirclePitchScale(mbglValue); } - (MGLStyleValue *)circlePitchScale { - auto propertyValue = self.layer->getCirclePitchScale() ?: self.layer->getDefaultCirclePitchScale(); + auto propertyValue = self.rawLayer->getCirclePitchScale() ?: self.rawLayer->getDefaultCirclePitchScale(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -134,7 +130,17 @@ - (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { - (void)addToMapView:(MGLMapView *)mapView { - mapView.mbglMap->addLayer(std::move(_pendingLayer)); + [self addToMapView:mapView belowLayer:nil]; +} + +- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer +{ + if (otherLayer) { + const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; + mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId); + } else { + mapView.mbglMap->addLayer(std::move(_pendingLayer)); + } } @end diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index 75a6d6610ec..1f8b7402d80 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -12,7 +12,7 @@ @interface MGLFillStyleLayer () -@property (nonatomic) mbgl::style::FillLayer *layer; +@property (nonatomic) mbgl::style::FillLayer *rawLayer; @end @@ -24,108 +24,104 @@ @implementation MGLFillStyleLayer - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - (NSString *)sourceLayerIdentifier { - auto layerID = self.layer->getSourceLayer(); + auto layerID = self.rawLayer->getSourceLayer(); return layerID.empty() ? nil : @(layerID.c_str()); } - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { - self.layer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); + self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } - (void)setPredicate:(NSPredicate *)predicate { - self.layer->setFilter(predicate.mgl_filter); + self.rawLayer->setFilter(predicate.mgl_filter); } - (NSPredicate *)predicate { - return [NSPredicate mgl_predicateWithFilter:self.layer->getFilter()]; + return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } #pragma mark - Accessing the Paint Attributes - (void)setFillAntialias:(MGLStyleValue *)fillAntialias { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillAntialias); - self.layer->setFillAntialias(mbglValue); + self.rawLayer->setFillAntialias(mbglValue); } - (MGLStyleValue *)fillAntialias { - auto propertyValue = self.layer->getFillAntialias() ?: self.layer->getDefaultFillAntialias(); + auto propertyValue = self.rawLayer->getFillAntialias() ?: self.rawLayer->getDefaultFillAntialias(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillOpacity:(MGLStyleValue *)fillOpacity { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillOpacity); - self.layer->setFillOpacity(mbglValue); + self.rawLayer->setFillOpacity(mbglValue); } - (MGLStyleValue *)fillOpacity { - auto propertyValue = self.layer->getFillOpacity() ?: self.layer->getDefaultFillOpacity(); + auto propertyValue = self.rawLayer->getFillOpacity() ?: self.rawLayer->getDefaultFillOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillColor:(MGLStyleValue *)fillColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillColor); - self.layer->setFillColor(mbglValue); + self.rawLayer->setFillColor(mbglValue); } - (MGLStyleValue *)fillColor { - auto propertyValue = self.layer->getFillColor() ?: self.layer->getDefaultFillColor(); + auto propertyValue = self.rawLayer->getFillColor() ?: self.rawLayer->getDefaultFillColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillOutlineColor:(MGLStyleValue *)fillOutlineColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillOutlineColor); - self.layer->setFillOutlineColor(mbglValue); + self.rawLayer->setFillOutlineColor(mbglValue); } - (MGLStyleValue *)fillOutlineColor { - auto propertyValue = self.layer->getFillOutlineColor() ?: self.layer->getDefaultFillOutlineColor(); + auto propertyValue = self.rawLayer->getFillOutlineColor() ?: self.rawLayer->getDefaultFillOutlineColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillTranslate:(MGLStyleValue *)fillTranslate { auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(fillTranslate); - self.layer->setFillTranslate(mbglValue); + self.rawLayer->setFillTranslate(mbglValue); } - (MGLStyleValue *)fillTranslate { - auto propertyValue = self.layer->getFillTranslate() ?: self.layer->getDefaultFillTranslate(); + auto propertyValue = self.rawLayer->getFillTranslate() ?: self.rawLayer->getDefaultFillTranslate(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setFillTranslateAnchor:(MGLStyleValue *)fillTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillTranslateAnchor); - self.layer->setFillTranslateAnchor(mbglValue); + self.rawLayer->setFillTranslateAnchor(mbglValue); } - (MGLStyleValue *)fillTranslateAnchor { - auto propertyValue = self.layer->getFillTranslateAnchor() ?: self.layer->getDefaultFillTranslateAnchor(); + auto propertyValue = self.rawLayer->getFillTranslateAnchor() ?: self.rawLayer->getDefaultFillTranslateAnchor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setFillPattern:(MGLStyleValue *)fillPattern { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillPattern); - self.layer->setFillPattern(mbglValue); + self.rawLayer->setFillPattern(mbglValue); } - (MGLStyleValue *)fillPattern { - auto propertyValue = self.layer->getFillPattern() ?: self.layer->getDefaultFillPattern(); + auto propertyValue = self.rawLayer->getFillPattern() ?: self.rawLayer->getDefaultFillPattern(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -134,7 +130,17 @@ - (void)setFillPattern:(MGLStyleValue *)fillPattern { - (void)addToMapView:(MGLMapView *)mapView { - mapView.mbglMap->addLayer(std::move(_pendingLayer)); + [self addToMapView:mapView belowLayer:nil]; +} + +- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer +{ + if (otherLayer) { + const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; + mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId); + } else { + mapView.mbglMap->addLayer(std::move(_pendingLayer)); + } } @end diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 11599dfd817..aa699ea37d8 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -12,7 +12,7 @@ @interface MGLLineStyleLayer () -@property (nonatomic) mbgl::style::LineLayer *layer; +@property (nonatomic) mbgl::style::LineLayer *rawLayer; @end @@ -24,78 +24,74 @@ @implementation MGLLineStyleLayer - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - (NSString *)sourceLayerIdentifier { - auto layerID = self.layer->getSourceLayer(); + auto layerID = self.rawLayer->getSourceLayer(); return layerID.empty() ? nil : @(layerID.c_str()); } - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { - self.layer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); + self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } - (void)setPredicate:(NSPredicate *)predicate { - self.layer->setFilter(predicate.mgl_filter); + self.rawLayer->setFilter(predicate.mgl_filter); } - (NSPredicate *)predicate { - return [NSPredicate mgl_predicateWithFilter:self.layer->getFilter()]; + return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } #pragma mark - Accessing the Layout Attributes - (void)setLineCap:(MGLStyleValue *)lineCap { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineCap); - self.layer->setLineCap(mbglValue); + self.rawLayer->setLineCap(mbglValue); } - (MGLStyleValue *)lineCap { - auto propertyValue = self.layer->getLineCap() ?: self.layer->getDefaultLineCap(); + auto propertyValue = self.rawLayer->getLineCap() ?: self.rawLayer->getDefaultLineCap(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineJoin:(MGLStyleValue *)lineJoin { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineJoin); - self.layer->setLineJoin(mbglValue); + self.rawLayer->setLineJoin(mbglValue); } - (MGLStyleValue *)lineJoin { - auto propertyValue = self.layer->getLineJoin() ?: self.layer->getDefaultLineJoin(); + auto propertyValue = self.rawLayer->getLineJoin() ?: self.rawLayer->getDefaultLineJoin(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineMiterLimit:(MGLStyleValue *)lineMiterLimit { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineMiterLimit); - self.layer->setLineMiterLimit(mbglValue); + self.rawLayer->setLineMiterLimit(mbglValue); } - (MGLStyleValue *)lineMiterLimit { - auto propertyValue = self.layer->getLineMiterLimit() ?: self.layer->getDefaultLineMiterLimit(); + auto propertyValue = self.rawLayer->getLineMiterLimit() ?: self.rawLayer->getDefaultLineMiterLimit(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineRoundLimit:(MGLStyleValue *)lineRoundLimit { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineRoundLimit); - self.layer->setLineRoundLimit(mbglValue); + self.rawLayer->setLineRoundLimit(mbglValue); } - (MGLStyleValue *)lineRoundLimit { - auto propertyValue = self.layer->getLineRoundLimit() ?: self.layer->getDefaultLineRoundLimit(); + auto propertyValue = self.rawLayer->getLineRoundLimit() ?: self.rawLayer->getDefaultLineRoundLimit(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -103,101 +99,101 @@ - (void)setLineRoundLimit:(MGLStyleValue *)lineRoundLimit { - (void)setLineOpacity:(MGLStyleValue *)lineOpacity { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineOpacity); - self.layer->setLineOpacity(mbglValue); + self.rawLayer->setLineOpacity(mbglValue); } - (MGLStyleValue *)lineOpacity { - auto propertyValue = self.layer->getLineOpacity() ?: self.layer->getDefaultLineOpacity(); + auto propertyValue = self.rawLayer->getLineOpacity() ?: self.rawLayer->getDefaultLineOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineColor:(MGLStyleValue *)lineColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineColor); - self.layer->setLineColor(mbglValue); + self.rawLayer->setLineColor(mbglValue); } - (MGLStyleValue *)lineColor { - auto propertyValue = self.layer->getLineColor() ?: self.layer->getDefaultLineColor(); + auto propertyValue = self.rawLayer->getLineColor() ?: self.rawLayer->getDefaultLineColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineTranslate:(MGLStyleValue *)lineTranslate { auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(lineTranslate); - self.layer->setLineTranslate(mbglValue); + self.rawLayer->setLineTranslate(mbglValue); } - (MGLStyleValue *)lineTranslate { - auto propertyValue = self.layer->getLineTranslate() ?: self.layer->getDefaultLineTranslate(); + auto propertyValue = self.rawLayer->getLineTranslate() ?: self.rawLayer->getDefaultLineTranslate(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setLineTranslateAnchor:(MGLStyleValue *)lineTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineTranslateAnchor); - self.layer->setLineTranslateAnchor(mbglValue); + self.rawLayer->setLineTranslateAnchor(mbglValue); } - (MGLStyleValue *)lineTranslateAnchor { - auto propertyValue = self.layer->getLineTranslateAnchor() ?: self.layer->getDefaultLineTranslateAnchor(); + auto propertyValue = self.rawLayer->getLineTranslateAnchor() ?: self.rawLayer->getDefaultLineTranslateAnchor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineWidth:(MGLStyleValue *)lineWidth { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineWidth); - self.layer->setLineWidth(mbglValue); + self.rawLayer->setLineWidth(mbglValue); } - (MGLStyleValue *)lineWidth { - auto propertyValue = self.layer->getLineWidth() ?: self.layer->getDefaultLineWidth(); + auto propertyValue = self.rawLayer->getLineWidth() ?: self.rawLayer->getDefaultLineWidth(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineGapWidth:(MGLStyleValue *)lineGapWidth { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineGapWidth); - self.layer->setLineGapWidth(mbglValue); + self.rawLayer->setLineGapWidth(mbglValue); } - (MGLStyleValue *)lineGapWidth { - auto propertyValue = self.layer->getLineGapWidth() ?: self.layer->getDefaultLineGapWidth(); + auto propertyValue = self.rawLayer->getLineGapWidth() ?: self.rawLayer->getDefaultLineGapWidth(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineOffset:(MGLStyleValue *)lineOffset { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineOffset); - self.layer->setLineOffset(mbglValue); + self.rawLayer->setLineOffset(mbglValue); } - (MGLStyleValue *)lineOffset { - auto propertyValue = self.layer->getLineOffset() ?: self.layer->getDefaultLineOffset(); + auto propertyValue = self.rawLayer->getLineOffset() ?: self.rawLayer->getDefaultLineOffset(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineBlur:(MGLStyleValue *)lineBlur { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineBlur); - self.layer->setLineBlur(mbglValue); + self.rawLayer->setLineBlur(mbglValue); } - (MGLStyleValue *)lineBlur { - auto propertyValue = self.layer->getLineBlur() ?: self.layer->getDefaultLineBlur(); + auto propertyValue = self.rawLayer->getLineBlur() ?: self.rawLayer->getDefaultLineBlur(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setLineDasharray:(MGLStyleValue *> *)lineDasharray { auto mbglValue = MGLStyleValueTransformer, NSArray *, float>().toPropertyValue(lineDasharray); - self.layer->setLineDasharray(mbglValue); + self.rawLayer->setLineDasharray(mbglValue); } - (MGLStyleValue *> *)lineDasharray { - auto propertyValue = self.layer->getLineDasharray() ?: self.layer->getDefaultLineDasharray(); + auto propertyValue = self.rawLayer->getLineDasharray() ?: self.rawLayer->getDefaultLineDasharray(); return MGLStyleValueTransformer, NSArray *, float>().toStyleValue(propertyValue); } - (void)setLinePattern:(MGLStyleValue *)linePattern { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(linePattern); - self.layer->setLinePattern(mbglValue); + self.rawLayer->setLinePattern(mbglValue); } - (MGLStyleValue *)linePattern { - auto propertyValue = self.layer->getLinePattern() ?: self.layer->getDefaultLinePattern(); + auto propertyValue = self.rawLayer->getLinePattern() ?: self.rawLayer->getDefaultLinePattern(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -206,7 +202,17 @@ - (void)setLinePattern:(MGLStyleValue *)linePattern { - (void)addToMapView:(MGLMapView *)mapView { - mapView.mbglMap->addLayer(std::move(_pendingLayer)); + [self addToMapView:mapView belowLayer:nil]; +} + +- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer +{ + if (otherLayer) { + const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; + mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId); + } else { + mapView.mbglMap->addLayer(std::move(_pendingLayer)); + } } @end diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index b4bc08ce79e..ba1df40f95d 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -12,7 +12,7 @@ @interface MGLRasterStyleLayer () -@property (nonatomic) mbgl::style::RasterLayer *layer; +@property (nonatomic) mbgl::style::RasterLayer *rawLayer; @end @@ -24,87 +24,83 @@ @implementation MGLRasterStyleLayer - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} #pragma mark - Accessing the Paint Attributes - (void)setRasterOpacity:(MGLStyleValue *)rasterOpacity { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterOpacity); - self.layer->setRasterOpacity(mbglValue); + self.rawLayer->setRasterOpacity(mbglValue); } - (MGLStyleValue *)rasterOpacity { - auto propertyValue = self.layer->getRasterOpacity() ?: self.layer->getDefaultRasterOpacity(); + auto propertyValue = self.rawLayer->getRasterOpacity() ?: self.rawLayer->getDefaultRasterOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterHueRotate:(MGLStyleValue *)rasterHueRotate { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterHueRotate); - self.layer->setRasterHueRotate(mbglValue); + self.rawLayer->setRasterHueRotate(mbglValue); } - (MGLStyleValue *)rasterHueRotate { - auto propertyValue = self.layer->getRasterHueRotate() ?: self.layer->getDefaultRasterHueRotate(); + auto propertyValue = self.rawLayer->getRasterHueRotate() ?: self.rawLayer->getDefaultRasterHueRotate(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterBrightnessMin:(MGLStyleValue *)rasterBrightnessMin { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterBrightnessMin); - self.layer->setRasterBrightnessMin(mbglValue); + self.rawLayer->setRasterBrightnessMin(mbglValue); } - (MGLStyleValue *)rasterBrightnessMin { - auto propertyValue = self.layer->getRasterBrightnessMin() ?: self.layer->getDefaultRasterBrightnessMin(); + auto propertyValue = self.rawLayer->getRasterBrightnessMin() ?: self.rawLayer->getDefaultRasterBrightnessMin(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterBrightnessMax:(MGLStyleValue *)rasterBrightnessMax { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterBrightnessMax); - self.layer->setRasterBrightnessMax(mbglValue); + self.rawLayer->setRasterBrightnessMax(mbglValue); } - (MGLStyleValue *)rasterBrightnessMax { - auto propertyValue = self.layer->getRasterBrightnessMax() ?: self.layer->getDefaultRasterBrightnessMax(); + auto propertyValue = self.rawLayer->getRasterBrightnessMax() ?: self.rawLayer->getDefaultRasterBrightnessMax(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterSaturation:(MGLStyleValue *)rasterSaturation { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterSaturation); - self.layer->setRasterSaturation(mbglValue); + self.rawLayer->setRasterSaturation(mbglValue); } - (MGLStyleValue *)rasterSaturation { - auto propertyValue = self.layer->getRasterSaturation() ?: self.layer->getDefaultRasterSaturation(); + auto propertyValue = self.rawLayer->getRasterSaturation() ?: self.rawLayer->getDefaultRasterSaturation(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterContrast:(MGLStyleValue *)rasterContrast { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterContrast); - self.layer->setRasterContrast(mbglValue); + self.rawLayer->setRasterContrast(mbglValue); } - (MGLStyleValue *)rasterContrast { - auto propertyValue = self.layer->getRasterContrast() ?: self.layer->getDefaultRasterContrast(); + auto propertyValue = self.rawLayer->getRasterContrast() ?: self.rawLayer->getDefaultRasterContrast(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setRasterFadeDuration:(MGLStyleValue *)rasterFadeDuration { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterFadeDuration); - self.layer->setRasterFadeDuration(mbglValue); + self.rawLayer->setRasterFadeDuration(mbglValue); } - (MGLStyleValue *)rasterFadeDuration { - auto propertyValue = self.layer->getRasterFadeDuration() ?: self.layer->getDefaultRasterFadeDuration(); + auto propertyValue = self.rawLayer->getRasterFadeDuration() ?: self.rawLayer->getDefaultRasterFadeDuration(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -113,7 +109,17 @@ - (void)setRasterFadeDuration:(MGLStyleValue *)rasterFadeDuration { - (void)addToMapView:(MGLMapView *)mapView { - mapView.mbglMap->addLayer(std::move(_pendingLayer)); + [self addToMapView:mapView belowLayer:nil]; +} + +- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer +{ + if (otherLayer) { + const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; + mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId); + } else { + mapView.mbglMap->addLayer(std::move(_pendingLayer)); + } } @end diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index d1261faf709..d59194725b3 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -134,7 +134,7 @@ - (MGLStyleLayer *)layerWithIdentifier:(NSString *)identifier return nil; } - styleLayer.layer = mbglLayer; + styleLayer.rawLayer = mbglLayer; return styleLayer; } @@ -173,7 +173,7 @@ - (void)removeLayer:(MGLStyleLayer *)layer - (void)addLayer:(MGLStyleLayer *)layer { - if (!layer.layer) { + if (!layer.rawLayer) { [NSException raise:NSInvalidArgumentException format: @"The style layer %@ cannot be added to the style. " @"Make sure the style layer was created as a member of a concrete subclass of MGLStyleLayer.", @@ -184,14 +184,14 @@ - (void)addLayer:(MGLStyleLayer *)layer - (void)insertLayer:(MGLStyleLayer *)layer belowLayer:(MGLStyleLayer *)otherLayer { - if (!layer.layer) { + if (!layer.rawLayer) { [NSException raise:NSInvalidArgumentException format: @"The style layer %@ cannot be added to the style. " @"Make sure the style layer was created as a member of a concrete subclass of MGLStyleLayer.", layer]; } - if (!otherLayer.layer) { + if (!otherLayer.rawLayer) { [NSException raise:NSInvalidArgumentException format: @"A style layer cannot be placed before %@ in the style. " @@ -199,8 +199,7 @@ - (void)insertLayer:(MGLStyleLayer *)layer belowLayer:(MGLStyleLayer *)otherLaye otherLayer]; } - const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; - self.mapView.mbglMap->addLayer(std::unique_ptr(layer.layer), belowLayerId); + [layer addToMapView:self.mapView belowLayer:otherLayer]; } - (void)addSource:(MGLSource *)source diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 1e784d5ef79..48d013d4824 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -17,7 +17,7 @@ @interface MGL<%- camelize(type) %>StyleLayer () -@property (nonatomic) mbgl::style::<%- camelize(type) %>Layer *layer; +@property (nonatomic) mbgl::style::<%- camelize(type) %>Layer *rawLayer; @end @@ -30,53 +30,46 @@ - (instancetype)initWithIdentifier:(NSString *)identifier { if (self = [super initWithIdentifier:identifier]) { - [self commonInit:identifier]; + auto layer = std::make_uniqueLayer>(identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } -- (void)commonInit:(NSString *)identifier -{ - auto layer = std::make_uniqueLayer>(identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} + <% } else { -%> - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + auto layer = std::make_uniqueLayer>(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_uniqueLayer>(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} <% } -%> <% if (type !== 'background' && type !== 'raster') { -%> - (NSString *)sourceLayerIdentifier { - auto layerID = self.layer->getSourceLayer(); + auto layerID = self.rawLayer->getSourceLayer(); return layerID.empty() ? nil : @(layerID.c_str()); } - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { - self.layer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); + self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } - (void)setPredicate:(NSPredicate *)predicate { - self.layer->setFilter(predicate.mgl_filter); + self.rawLayer->setFilter(predicate.mgl_filter); } - (NSPredicate *)predicate { - return [NSPredicate mgl_predicateWithFilter:self.layer->getFilter()]; + return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } <% } -%> @@ -86,11 +79,11 @@ <% for (const property of layoutProperties) { -%> - (void)set<%- camelize(property.name) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); - self.layer->set<%- camelize(property.name) %>(mbglValue); + self.rawLayer->set<%- camelize(property.name) %>(mbglValue); } - (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { - auto propertyValue = self.layer->get<%- camelize(property.name) %>() ?: self.layer->getDefault<%- camelize(property.name) %>(); + auto propertyValue = self.rawLayer->get<%- camelize(property.name) %>() ?: self.rawLayer->getDefault<%- camelize(property.name) %>(); return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); } @@ -102,11 +95,11 @@ <% for (const property of paintProperties) { -%> - (void)set<%- camelize(property.name) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); - self.layer->set<%- camelize(property.name) %>(mbglValue); + self.rawLayer->set<%- camelize(property.name) %>(mbglValue); } - (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { - auto propertyValue = self.layer->get<%- camelize(property.name) %>() ?: self.layer->getDefault<%- camelize(property.name) %>(); + auto propertyValue = self.rawLayer->get<%- camelize(property.name) %>() ?: self.rawLayer->getDefault<%- camelize(property.name) %>(); return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); } @@ -117,7 +110,17 @@ - (void)addToMapView:(MGLMapView *)mapView { - mapView.mbglMap->addLayer(std::move(_pendingLayer)); + [self addToMapView:mapView belowLayer:nil]; +} + +- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer +{ + if (otherLayer) { + const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; + mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId); + } else { + mapView.mbglMap->addLayer(std::move(_pendingLayer)); + } } @end diff --git a/platform/darwin/src/MGLStyleLayer_Private.h b/platform/darwin/src/MGLStyleLayer_Private.h index bd2225ad049..f61630b8c49 100644 --- a/platform/darwin/src/MGLStyleLayer_Private.h +++ b/platform/darwin/src/MGLStyleLayer_Private.h @@ -10,7 +10,15 @@ @interface MGLStyleLayer (Private) @property (nonatomic, readwrite, copy) NSString *identifier; -@property (nonatomic) mbgl::style::Layer *layer; + +/** + A raw pointer to the mbgl object, which is always initialized, either to the + value returned by `mbgl::Map getLayer`, or for independently created objects, + to the pointer value held in `pendingLayer`. In the latter case, this raw + pointer value stays even after ownership of the object is transferred via + `mbgl::Map addLayer`. + */ +@property (nonatomic) mbgl::style::Layer *rawLayer; /** Adds the mbgl style layer that this object represents to the mbgl map. @@ -21,4 +29,15 @@ */ - (void)addToMapView:(MGLMapView *)mapView; + + +/** + Adds the mbgl style layer that this object represents to the mbgl map below the specified `otherLayer`. + + Once a mbgl style layer is added, ownership of the object is transferred to the + `mbgl::Map` and this object no longer has an active unique_ptr reference to the + `mbgl::style::Layer`. + */ +- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer; + @end diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 4244a0a3eb2..539e0f2cc79 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -12,7 +12,7 @@ @interface MGLSymbolStyleLayer () -@property (nonatomic) mbgl::style::SymbolLayer *layer; +@property (nonatomic) mbgl::style::SymbolLayer *rawLayer; @end @@ -24,378 +24,374 @@ @implementation MGLSymbolStyleLayer - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { if (self = [super initWithIdentifier:identifier source:source]) { - [self commonInit:identifier source:source]; + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } -- (void)commonInit:(NSString *)identifier source:(MGLSource *)source -{ - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - _pendingLayer = std::move(layer); - self.layer = _pendingLayer.get(); -} - (NSString *)sourceLayerIdentifier { - auto layerID = self.layer->getSourceLayer(); + auto layerID = self.rawLayer->getSourceLayer(); return layerID.empty() ? nil : @(layerID.c_str()); } - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { - self.layer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); + self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } - (void)setPredicate:(NSPredicate *)predicate { - self.layer->setFilter(predicate.mgl_filter); + self.rawLayer->setFilter(predicate.mgl_filter); } - (NSPredicate *)predicate { - return [NSPredicate mgl_predicateWithFilter:self.layer->getFilter()]; + return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } #pragma mark - Accessing the Layout Attributes - (void)setSymbolPlacement:(MGLStyleValue *)symbolPlacement { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(symbolPlacement); - self.layer->setSymbolPlacement(mbglValue); + self.rawLayer->setSymbolPlacement(mbglValue); } - (MGLStyleValue *)symbolPlacement { - auto propertyValue = self.layer->getSymbolPlacement() ?: self.layer->getDefaultSymbolPlacement(); + auto propertyValue = self.rawLayer->getSymbolPlacement() ?: self.rawLayer->getDefaultSymbolPlacement(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setSymbolSpacing:(MGLStyleValue *)symbolSpacing { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(symbolSpacing); - self.layer->setSymbolSpacing(mbglValue); + self.rawLayer->setSymbolSpacing(mbglValue); } - (MGLStyleValue *)symbolSpacing { - auto propertyValue = self.layer->getSymbolSpacing() ?: self.layer->getDefaultSymbolSpacing(); + auto propertyValue = self.rawLayer->getSymbolSpacing() ?: self.rawLayer->getDefaultSymbolSpacing(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setSymbolAvoidEdges:(MGLStyleValue *)symbolAvoidEdges { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(symbolAvoidEdges); - self.layer->setSymbolAvoidEdges(mbglValue); + self.rawLayer->setSymbolAvoidEdges(mbglValue); } - (MGLStyleValue *)symbolAvoidEdges { - auto propertyValue = self.layer->getSymbolAvoidEdges() ?: self.layer->getDefaultSymbolAvoidEdges(); + auto propertyValue = self.rawLayer->getSymbolAvoidEdges() ?: self.rawLayer->getDefaultSymbolAvoidEdges(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconAllowOverlap:(MGLStyleValue *)iconAllowOverlap { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconAllowOverlap); - self.layer->setIconAllowOverlap(mbglValue); + self.rawLayer->setIconAllowOverlap(mbglValue); } - (MGLStyleValue *)iconAllowOverlap { - auto propertyValue = self.layer->getIconAllowOverlap() ?: self.layer->getDefaultIconAllowOverlap(); + auto propertyValue = self.rawLayer->getIconAllowOverlap() ?: self.rawLayer->getDefaultIconAllowOverlap(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconIgnorePlacement:(MGLStyleValue *)iconIgnorePlacement { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconIgnorePlacement); - self.layer->setIconIgnorePlacement(mbglValue); + self.rawLayer->setIconIgnorePlacement(mbglValue); } - (MGLStyleValue *)iconIgnorePlacement { - auto propertyValue = self.layer->getIconIgnorePlacement() ?: self.layer->getDefaultIconIgnorePlacement(); + auto propertyValue = self.rawLayer->getIconIgnorePlacement() ?: self.rawLayer->getDefaultIconIgnorePlacement(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconOptional:(MGLStyleValue *)iconOptional { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconOptional); - self.layer->setIconOptional(mbglValue); + self.rawLayer->setIconOptional(mbglValue); } - (MGLStyleValue *)iconOptional { - auto propertyValue = self.layer->getIconOptional() ?: self.layer->getDefaultIconOptional(); + auto propertyValue = self.rawLayer->getIconOptional() ?: self.rawLayer->getDefaultIconOptional(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconRotationAlignment:(MGLStyleValue *)iconRotationAlignment { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconRotationAlignment); - self.layer->setIconRotationAlignment(mbglValue); + self.rawLayer->setIconRotationAlignment(mbglValue); } - (MGLStyleValue *)iconRotationAlignment { - auto propertyValue = self.layer->getIconRotationAlignment() ?: self.layer->getDefaultIconRotationAlignment(); + auto propertyValue = self.rawLayer->getIconRotationAlignment() ?: self.rawLayer->getDefaultIconRotationAlignment(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconSize:(MGLStyleValue *)iconSize { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconSize); - self.layer->setIconSize(mbglValue); + self.rawLayer->setIconSize(mbglValue); } - (MGLStyleValue *)iconSize { - auto propertyValue = self.layer->getIconSize() ?: self.layer->getDefaultIconSize(); + auto propertyValue = self.rawLayer->getIconSize() ?: self.rawLayer->getDefaultIconSize(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconTextFit:(MGLStyleValue *)iconTextFit { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconTextFit); - self.layer->setIconTextFit(mbglValue); + self.rawLayer->setIconTextFit(mbglValue); } - (MGLStyleValue *)iconTextFit { - auto propertyValue = self.layer->getIconTextFit() ?: self.layer->getDefaultIconTextFit(); + auto propertyValue = self.rawLayer->getIconTextFit() ?: self.rawLayer->getDefaultIconTextFit(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconTextFitPadding:(MGLStyleValue *)iconTextFitPadding { auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(iconTextFitPadding); - self.layer->setIconTextFitPadding(mbglValue); + self.rawLayer->setIconTextFitPadding(mbglValue); } - (MGLStyleValue *)iconTextFitPadding { - auto propertyValue = self.layer->getIconTextFitPadding() ?: self.layer->getDefaultIconTextFitPadding(); + auto propertyValue = self.rawLayer->getIconTextFitPadding() ?: self.rawLayer->getDefaultIconTextFitPadding(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setIconImage:(MGLStyleValue *)iconImage { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconImage); - self.layer->setIconImage(mbglValue); + self.rawLayer->setIconImage(mbglValue); } - (MGLStyleValue *)iconImage { - auto propertyValue = self.layer->getIconImage() ?: self.layer->getDefaultIconImage(); + auto propertyValue = self.rawLayer->getIconImage() ?: self.rawLayer->getDefaultIconImage(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconRotate:(MGLStyleValue *)iconRotate { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconRotate); - self.layer->setIconRotate(mbglValue); + self.rawLayer->setIconRotate(mbglValue); } - (MGLStyleValue *)iconRotate { - auto propertyValue = self.layer->getIconRotate() ?: self.layer->getDefaultIconRotate(); + auto propertyValue = self.rawLayer->getIconRotate() ?: self.rawLayer->getDefaultIconRotate(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconPadding:(MGLStyleValue *)iconPadding { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconPadding); - self.layer->setIconPadding(mbglValue); + self.rawLayer->setIconPadding(mbglValue); } - (MGLStyleValue *)iconPadding { - auto propertyValue = self.layer->getIconPadding() ?: self.layer->getDefaultIconPadding(); + auto propertyValue = self.rawLayer->getIconPadding() ?: self.rawLayer->getDefaultIconPadding(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconKeepUpright:(MGLStyleValue *)iconKeepUpright { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconKeepUpright); - self.layer->setIconKeepUpright(mbglValue); + self.rawLayer->setIconKeepUpright(mbglValue); } - (MGLStyleValue *)iconKeepUpright { - auto propertyValue = self.layer->getIconKeepUpright() ?: self.layer->getDefaultIconKeepUpright(); + auto propertyValue = self.rawLayer->getIconKeepUpright() ?: self.rawLayer->getDefaultIconKeepUpright(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconOffset:(MGLStyleValue *)iconOffset { auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(iconOffset); - self.layer->setIconOffset(mbglValue); + self.rawLayer->setIconOffset(mbglValue); } - (MGLStyleValue *)iconOffset { - auto propertyValue = self.layer->getIconOffset() ?: self.layer->getDefaultIconOffset(); + auto propertyValue = self.rawLayer->getIconOffset() ?: self.rawLayer->getDefaultIconOffset(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setTextPitchAlignment:(MGLStyleValue *)textPitchAlignment { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textPitchAlignment); - self.layer->setTextPitchAlignment(mbglValue); + self.rawLayer->setTextPitchAlignment(mbglValue); } - (MGLStyleValue *)textPitchAlignment { - auto propertyValue = self.layer->getTextPitchAlignment() ?: self.layer->getDefaultTextPitchAlignment(); + auto propertyValue = self.rawLayer->getTextPitchAlignment() ?: self.rawLayer->getDefaultTextPitchAlignment(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextRotationAlignment:(MGLStyleValue *)textRotationAlignment { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textRotationAlignment); - self.layer->setTextRotationAlignment(mbglValue); + self.rawLayer->setTextRotationAlignment(mbglValue); } - (MGLStyleValue *)textRotationAlignment { - auto propertyValue = self.layer->getTextRotationAlignment() ?: self.layer->getDefaultTextRotationAlignment(); + auto propertyValue = self.rawLayer->getTextRotationAlignment() ?: self.rawLayer->getDefaultTextRotationAlignment(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextField:(MGLStyleValue *)textField { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textField); - self.layer->setTextField(mbglValue); + self.rawLayer->setTextField(mbglValue); } - (MGLStyleValue *)textField { - auto propertyValue = self.layer->getTextField() ?: self.layer->getDefaultTextField(); + auto propertyValue = self.rawLayer->getTextField() ?: self.rawLayer->getDefaultTextField(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextFont:(MGLStyleValue *> *)textFont { auto mbglValue = MGLStyleValueTransformer, NSArray *, std::string>().toPropertyValue(textFont); - self.layer->setTextFont(mbglValue); + self.rawLayer->setTextFont(mbglValue); } - (MGLStyleValue *> *)textFont { - auto propertyValue = self.layer->getTextFont() ?: self.layer->getDefaultTextFont(); + auto propertyValue = self.rawLayer->getTextFont() ?: self.rawLayer->getDefaultTextFont(); return MGLStyleValueTransformer, NSArray *, std::string>().toStyleValue(propertyValue); } - (void)setTextSize:(MGLStyleValue *)textSize { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textSize); - self.layer->setTextSize(mbglValue); + self.rawLayer->setTextSize(mbglValue); } - (MGLStyleValue *)textSize { - auto propertyValue = self.layer->getTextSize() ?: self.layer->getDefaultTextSize(); + auto propertyValue = self.rawLayer->getTextSize() ?: self.rawLayer->getDefaultTextSize(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextMaxWidth:(MGLStyleValue *)textMaxWidth { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textMaxWidth); - self.layer->setTextMaxWidth(mbglValue); + self.rawLayer->setTextMaxWidth(mbglValue); } - (MGLStyleValue *)textMaxWidth { - auto propertyValue = self.layer->getTextMaxWidth() ?: self.layer->getDefaultTextMaxWidth(); + auto propertyValue = self.rawLayer->getTextMaxWidth() ?: self.rawLayer->getDefaultTextMaxWidth(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextLineHeight:(MGLStyleValue *)textLineHeight { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textLineHeight); - self.layer->setTextLineHeight(mbglValue); + self.rawLayer->setTextLineHeight(mbglValue); } - (MGLStyleValue *)textLineHeight { - auto propertyValue = self.layer->getTextLineHeight() ?: self.layer->getDefaultTextLineHeight(); + auto propertyValue = self.rawLayer->getTextLineHeight() ?: self.rawLayer->getDefaultTextLineHeight(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextLetterSpacing:(MGLStyleValue *)textLetterSpacing { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textLetterSpacing); - self.layer->setTextLetterSpacing(mbglValue); + self.rawLayer->setTextLetterSpacing(mbglValue); } - (MGLStyleValue *)textLetterSpacing { - auto propertyValue = self.layer->getTextLetterSpacing() ?: self.layer->getDefaultTextLetterSpacing(); + auto propertyValue = self.rawLayer->getTextLetterSpacing() ?: self.rawLayer->getDefaultTextLetterSpacing(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextJustify:(MGLStyleValue *)textJustify { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textJustify); - self.layer->setTextJustify(mbglValue); + self.rawLayer->setTextJustify(mbglValue); } - (MGLStyleValue *)textJustify { - auto propertyValue = self.layer->getTextJustify() ?: self.layer->getDefaultTextJustify(); + auto propertyValue = self.rawLayer->getTextJustify() ?: self.rawLayer->getDefaultTextJustify(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextAnchor:(MGLStyleValue *)textAnchor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textAnchor); - self.layer->setTextAnchor(mbglValue); + self.rawLayer->setTextAnchor(mbglValue); } - (MGLStyleValue *)textAnchor { - auto propertyValue = self.layer->getTextAnchor() ?: self.layer->getDefaultTextAnchor(); + auto propertyValue = self.rawLayer->getTextAnchor() ?: self.rawLayer->getDefaultTextAnchor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextMaxAngle:(MGLStyleValue *)textMaxAngle { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textMaxAngle); - self.layer->setTextMaxAngle(mbglValue); + self.rawLayer->setTextMaxAngle(mbglValue); } - (MGLStyleValue *)textMaxAngle { - auto propertyValue = self.layer->getTextMaxAngle() ?: self.layer->getDefaultTextMaxAngle(); + auto propertyValue = self.rawLayer->getTextMaxAngle() ?: self.rawLayer->getDefaultTextMaxAngle(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextRotate:(MGLStyleValue *)textRotate { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textRotate); - self.layer->setTextRotate(mbglValue); + self.rawLayer->setTextRotate(mbglValue); } - (MGLStyleValue *)textRotate { - auto propertyValue = self.layer->getTextRotate() ?: self.layer->getDefaultTextRotate(); + auto propertyValue = self.rawLayer->getTextRotate() ?: self.rawLayer->getDefaultTextRotate(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextPadding:(MGLStyleValue *)textPadding { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textPadding); - self.layer->setTextPadding(mbglValue); + self.rawLayer->setTextPadding(mbglValue); } - (MGLStyleValue *)textPadding { - auto propertyValue = self.layer->getTextPadding() ?: self.layer->getDefaultTextPadding(); + auto propertyValue = self.rawLayer->getTextPadding() ?: self.rawLayer->getDefaultTextPadding(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextKeepUpright:(MGLStyleValue *)textKeepUpright { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textKeepUpright); - self.layer->setTextKeepUpright(mbglValue); + self.rawLayer->setTextKeepUpright(mbglValue); } - (MGLStyleValue *)textKeepUpright { - auto propertyValue = self.layer->getTextKeepUpright() ?: self.layer->getDefaultTextKeepUpright(); + auto propertyValue = self.rawLayer->getTextKeepUpright() ?: self.rawLayer->getDefaultTextKeepUpright(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextTransform:(MGLStyleValue *)textTransform { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textTransform); - self.layer->setTextTransform(mbglValue); + self.rawLayer->setTextTransform(mbglValue); } - (MGLStyleValue *)textTransform { - auto propertyValue = self.layer->getTextTransform() ?: self.layer->getDefaultTextTransform(); + auto propertyValue = self.rawLayer->getTextTransform() ?: self.rawLayer->getDefaultTextTransform(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextOffset:(MGLStyleValue *)textOffset { auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(textOffset); - self.layer->setTextOffset(mbglValue); + self.rawLayer->setTextOffset(mbglValue); } - (MGLStyleValue *)textOffset { - auto propertyValue = self.layer->getTextOffset() ?: self.layer->getDefaultTextOffset(); + auto propertyValue = self.rawLayer->getTextOffset() ?: self.rawLayer->getDefaultTextOffset(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setTextAllowOverlap:(MGLStyleValue *)textAllowOverlap { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textAllowOverlap); - self.layer->setTextAllowOverlap(mbglValue); + self.rawLayer->setTextAllowOverlap(mbglValue); } - (MGLStyleValue *)textAllowOverlap { - auto propertyValue = self.layer->getTextAllowOverlap() ?: self.layer->getDefaultTextAllowOverlap(); + auto propertyValue = self.rawLayer->getTextAllowOverlap() ?: self.rawLayer->getDefaultTextAllowOverlap(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextIgnorePlacement:(MGLStyleValue *)textIgnorePlacement { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textIgnorePlacement); - self.layer->setTextIgnorePlacement(mbglValue); + self.rawLayer->setTextIgnorePlacement(mbglValue); } - (MGLStyleValue *)textIgnorePlacement { - auto propertyValue = self.layer->getTextIgnorePlacement() ?: self.layer->getDefaultTextIgnorePlacement(); + auto propertyValue = self.rawLayer->getTextIgnorePlacement() ?: self.rawLayer->getDefaultTextIgnorePlacement(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextOptional:(MGLStyleValue *)textOptional { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textOptional); - self.layer->setTextOptional(mbglValue); + self.rawLayer->setTextOptional(mbglValue); } - (MGLStyleValue *)textOptional { - auto propertyValue = self.layer->getTextOptional() ?: self.layer->getDefaultTextOptional(); + auto propertyValue = self.rawLayer->getTextOptional() ?: self.rawLayer->getDefaultTextOptional(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -403,141 +399,141 @@ - (void)setTextOptional:(MGLStyleValue *)textOptional { - (void)setIconOpacity:(MGLStyleValue *)iconOpacity { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconOpacity); - self.layer->setIconOpacity(mbglValue); + self.rawLayer->setIconOpacity(mbglValue); } - (MGLStyleValue *)iconOpacity { - auto propertyValue = self.layer->getIconOpacity() ?: self.layer->getDefaultIconOpacity(); + auto propertyValue = self.rawLayer->getIconOpacity() ?: self.rawLayer->getDefaultIconOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconColor:(MGLStyleValue *)iconColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconColor); - self.layer->setIconColor(mbglValue); + self.rawLayer->setIconColor(mbglValue); } - (MGLStyleValue *)iconColor { - auto propertyValue = self.layer->getIconColor() ?: self.layer->getDefaultIconColor(); + auto propertyValue = self.rawLayer->getIconColor() ?: self.rawLayer->getDefaultIconColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconHaloColor:(MGLStyleValue *)iconHaloColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconHaloColor); - self.layer->setIconHaloColor(mbglValue); + self.rawLayer->setIconHaloColor(mbglValue); } - (MGLStyleValue *)iconHaloColor { - auto propertyValue = self.layer->getIconHaloColor() ?: self.layer->getDefaultIconHaloColor(); + auto propertyValue = self.rawLayer->getIconHaloColor() ?: self.rawLayer->getDefaultIconHaloColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconHaloWidth:(MGLStyleValue *)iconHaloWidth { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconHaloWidth); - self.layer->setIconHaloWidth(mbglValue); + self.rawLayer->setIconHaloWidth(mbglValue); } - (MGLStyleValue *)iconHaloWidth { - auto propertyValue = self.layer->getIconHaloWidth() ?: self.layer->getDefaultIconHaloWidth(); + auto propertyValue = self.rawLayer->getIconHaloWidth() ?: self.rawLayer->getDefaultIconHaloWidth(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconHaloBlur:(MGLStyleValue *)iconHaloBlur { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconHaloBlur); - self.layer->setIconHaloBlur(mbglValue); + self.rawLayer->setIconHaloBlur(mbglValue); } - (MGLStyleValue *)iconHaloBlur { - auto propertyValue = self.layer->getIconHaloBlur() ?: self.layer->getDefaultIconHaloBlur(); + auto propertyValue = self.rawLayer->getIconHaloBlur() ?: self.rawLayer->getDefaultIconHaloBlur(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconTranslate:(MGLStyleValue *)iconTranslate { auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(iconTranslate); - self.layer->setIconTranslate(mbglValue); + self.rawLayer->setIconTranslate(mbglValue); } - (MGLStyleValue *)iconTranslate { - auto propertyValue = self.layer->getIconTranslate() ?: self.layer->getDefaultIconTranslate(); + auto propertyValue = self.rawLayer->getIconTranslate() ?: self.rawLayer->getDefaultIconTranslate(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setIconTranslateAnchor:(MGLStyleValue *)iconTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconTranslateAnchor); - self.layer->setIconTranslateAnchor(mbglValue); + self.rawLayer->setIconTranslateAnchor(mbglValue); } - (MGLStyleValue *)iconTranslateAnchor { - auto propertyValue = self.layer->getIconTranslateAnchor() ?: self.layer->getDefaultIconTranslateAnchor(); + auto propertyValue = self.rawLayer->getIconTranslateAnchor() ?: self.rawLayer->getDefaultIconTranslateAnchor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextOpacity:(MGLStyleValue *)textOpacity { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textOpacity); - self.layer->setTextOpacity(mbglValue); + self.rawLayer->setTextOpacity(mbglValue); } - (MGLStyleValue *)textOpacity { - auto propertyValue = self.layer->getTextOpacity() ?: self.layer->getDefaultTextOpacity(); + auto propertyValue = self.rawLayer->getTextOpacity() ?: self.rawLayer->getDefaultTextOpacity(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextColor:(MGLStyleValue *)textColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textColor); - self.layer->setTextColor(mbglValue); + self.rawLayer->setTextColor(mbglValue); } - (MGLStyleValue *)textColor { - auto propertyValue = self.layer->getTextColor() ?: self.layer->getDefaultTextColor(); + auto propertyValue = self.rawLayer->getTextColor() ?: self.rawLayer->getDefaultTextColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextHaloColor:(MGLStyleValue *)textHaloColor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textHaloColor); - self.layer->setTextHaloColor(mbglValue); + self.rawLayer->setTextHaloColor(mbglValue); } - (MGLStyleValue *)textHaloColor { - auto propertyValue = self.layer->getTextHaloColor() ?: self.layer->getDefaultTextHaloColor(); + auto propertyValue = self.rawLayer->getTextHaloColor() ?: self.rawLayer->getDefaultTextHaloColor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextHaloWidth:(MGLStyleValue *)textHaloWidth { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textHaloWidth); - self.layer->setTextHaloWidth(mbglValue); + self.rawLayer->setTextHaloWidth(mbglValue); } - (MGLStyleValue *)textHaloWidth { - auto propertyValue = self.layer->getTextHaloWidth() ?: self.layer->getDefaultTextHaloWidth(); + auto propertyValue = self.rawLayer->getTextHaloWidth() ?: self.rawLayer->getDefaultTextHaloWidth(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextHaloBlur:(MGLStyleValue *)textHaloBlur { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textHaloBlur); - self.layer->setTextHaloBlur(mbglValue); + self.rawLayer->setTextHaloBlur(mbglValue); } - (MGLStyleValue *)textHaloBlur { - auto propertyValue = self.layer->getTextHaloBlur() ?: self.layer->getDefaultTextHaloBlur(); + auto propertyValue = self.rawLayer->getTextHaloBlur() ?: self.rawLayer->getDefaultTextHaloBlur(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setTextTranslate:(MGLStyleValue *)textTranslate { auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(textTranslate); - self.layer->setTextTranslate(mbglValue); + self.rawLayer->setTextTranslate(mbglValue); } - (MGLStyleValue *)textTranslate { - auto propertyValue = self.layer->getTextTranslate() ?: self.layer->getDefaultTextTranslate(); + auto propertyValue = self.rawLayer->getTextTranslate() ?: self.rawLayer->getDefaultTextTranslate(); return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } - (void)setTextTranslateAnchor:(MGLStyleValue *)textTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textTranslateAnchor); - self.layer->setTextTranslateAnchor(mbglValue); + self.rawLayer->setTextTranslateAnchor(mbglValue); } - (MGLStyleValue *)textTranslateAnchor { - auto propertyValue = self.layer->getTextTranslateAnchor() ?: self.layer->getDefaultTextTranslateAnchor(); + auto propertyValue = self.rawLayer->getTextTranslateAnchor() ?: self.rawLayer->getDefaultTextTranslateAnchor(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -546,7 +542,17 @@ - (void)setTextTranslateAnchor:(MGLStyleValue *)textTranslateAnchor { - (void)addToMapView:(MGLMapView *)mapView { - mapView.mbglMap->addLayer(std::move(_pendingLayer)); + [self addToMapView:mapView belowLayer:nil]; +} + +- (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer +{ + if (otherLayer) { + const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; + mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId); + } else { + mapView.mbglMap->addLayer(std::move(_pendingLayer)); + } } @end