diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index 33a105e5d53..38c97e8d468 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" @@ -11,50 +12,74 @@ @interface MGLBackgroundStyleLayer () -@property (nonatomic) mbgl::style::BackgroundLayer *layer; +@property (nonatomic) mbgl::style::BackgroundLayer *rawLayer; @end @implementation MGLBackgroundStyleLayer +{ + std::unique_ptr _pendingLayer; +} - (instancetype)initWithIdentifier:(NSString *)identifier { if (self = [super initWithIdentifier:identifier]) { - _layer = new mbgl::style::BackgroundLayer(identifier.UTF8String); + auto layer = std::make_unique(identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } + #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); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + [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 8fe97a05370..13eedf3f960 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" @@ -11,111 +12,135 @@ @interface MGLCircleStyleLayer () -@property (nonatomic) mbgl::style::CircleLayer *layer; +@property (nonatomic) mbgl::style::CircleLayer *rawLayer; @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); + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } + - (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); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + [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 e16e3b26522..1f8b7402d80 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" @@ -11,111 +12,135 @@ @interface MGLFillStyleLayer () -@property (nonatomic) mbgl::style::FillLayer *layer; +@property (nonatomic) mbgl::style::FillLayer *rawLayer; @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); + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } + - (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); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + [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 57724a0600e..aa699ea37d8 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" @@ -11,80 +12,86 @@ @interface MGLLineStyleLayer () -@property (nonatomic) mbgl::style::LineLayer *layer; +@property (nonatomic) mbgl::style::LineLayer *rawLayer; @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); + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } + - (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); } @@ -92,102 +99,120 @@ - (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); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + [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 f616e895181..ba1df40f95d 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" @@ -11,90 +12,114 @@ @interface MGLRasterStyleLayer () -@property (nonatomic) mbgl::style::RasterLayer *layer; +@property (nonatomic) mbgl::style::RasterLayer *rawLayer; @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); + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } + #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); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + [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 a17b7d6b743..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,26 +173,25 @@ - (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.", layer]; } - - self.mapView.mbglMap->addLayer(std::unique_ptr(layer.layer)); + [layer addToMapView:self.mapView]; } - (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. " @@ -200,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 3678e9ec52a..48d013d4824 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" @@ -16,50 +17,59 @@ @interface MGL<%- camelize(type) %>StyleLayer () -@property (nonatomic) mbgl::style::<%- camelize(type) %>Layer *layer; +@property (nonatomic) mbgl::style::<%- camelize(type) %>Layer *rawLayer; @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); + auto layer = std::make_uniqueLayer>(identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } + <% } 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); + auto layer = std::make_uniqueLayer>(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } + <% } -%> <% 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()]; } <% } -%> @@ -69,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); } @@ -85,14 +95,32 @@ <% 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); } <% } -%> <% } -%> + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + [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 5fa01856eaf..f61630b8c49 100644 --- a/platform/darwin/src/MGLStyleLayer_Private.h +++ b/platform/darwin/src/MGLStyleLayer_Private.h @@ -5,9 +5,39 @@ #include +@class MGLMapView; + @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. + + 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; + + + +/** + 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 a4c56fe2976..539e0f2cc79 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" @@ -11,380 +12,386 @@ @interface MGLSymbolStyleLayer () -@property (nonatomic) mbgl::style::SymbolLayer *layer; +@property (nonatomic) mbgl::style::SymbolLayer *rawLayer; @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); + auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); + _pendingLayer = std::move(layer); + self.rawLayer = _pendingLayer.get(); } return self; } + - (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); } @@ -392,142 +399,160 @@ - (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); } + +#pragma mark - Add style layer to map + +- (void)addToMapView:(MGLMapView *)mapView +{ + [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/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index a7ea4293008..11247ea3f7e 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -769,6 +769,7 @@ - (void)styleGeoJSONSource MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"test" source:source]; fillLayer.fillColor = [MGLStyleValue valueWithRawValue:[UIColor purpleColor]]; [self.mapView.style addLayer:fillLayer]; + } - (void)styleSymbolLayer