summaryrefslogtreecommitdiff
path: root/platform/darwin
diff options
context:
space:
mode:
authorFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2016-08-11 13:14:45 -0400
committerGitHub <noreply@github.com>2016-08-11 13:14:45 -0400
commit2354c87411ce88c581e02f93445a66a2158bd7b0 (patch)
treea7deb9a3b1b0f24e2a876dedc13fbd1c6b22947e /platform/darwin
parentb0cb8715ed74678b4d0f05829fa71a590e41b2f6 (diff)
downloadqtlocation-mapboxgl-2354c87411ce88c581e02f93445a66a2158bd7b0.tar.gz
Runtime styling API for iOS/macOS (#5727)
* [ios] wip runtime styling * [ios, macos] Outlined header templates * [ios, macos] cleanup and use appropiate data types * [ios, macos] removed refs to mbgl and added convenient color methods on UIColor and NSColor * [ios, macos] updated header template, included doc string * [ios, macos] outlined template for layer implementation files * [ios, macos] moved script to platform/darwin and updated comments * [ios, macos] Cleaned up the implementation template * [ios, macos] removed unused function and added support for more datatypes * [ios, macos] overhauling the type protocols * [ios, macos] removed unnecessary style classes * [ios, macos] added support for more types * [ios, macos] fixed string and number prop values * [ios, macos] enum getters * [ios, macos] added removeLayer() and removed unused layer ref * [ios, macos] fixed remaining layer types and converted style layer into a protocol * [ios, macos] fixed addLayer() and added example for line layer * [ios] GeoJSON source now works * [ios] fixed raster layer and raster source * [ios] fixed attr prop number and outlined prop function * [ios] wip functions * [ios] bool and float function fix * [ios] cleanup * [macos] fixed support for macos * [ios] fixed string functions * [ios] extended array functions * [ios] added tests and fixed a few bugs * [ios] less verbose functions and improved tests * [ios, macos] Removed unnecessary use of default arguments Default arguments aren’t supported in Node v4, and they aren’t needed here anyways, because we’re only testing for truthiness. * [ios, macos] Enum setters Rely on a macro instead of category methods to specialize the setter implementation for enum attributes, since generic types are disallowed in Objective-C method signatures and mbgl::style::PropertyType must be type-qualified. * [ios, macos] Got macOS closer to parity w/ iOS Added various classes and test classes to the macOS workspace. Also fixed lots of compiler errors and updated macosapp runtime styling example to use the new dictionary syntax for function stops. Updated all conversions from Objective-C stops to C++ stops to enumerate over the dictionary. Fixed compiler errors in enum setter implementations. Also corrected path to script in generated file comments. * [ios, macos] Added EJS templates to project * [ios, macos] Code formatting Made code format more consistent. * [ios, macos] Spelled out ID Cocoa convention is to always spell out “ID” as “identifier”, in part to avoid confusion with the id keyword. Also, URL is capitalized in most contexts, including property names. * [ios, macos] Grouped related headers together * [ios, macos] Cleaned up layer transformation Also added support for converting background layers into Objective-C. * [ios, macos] Cleaned up tests Also made the tests work on macOS by introducing a new window to host the map. * [ios, macos] Replaced TODOs with #warnings * [ios] convert array based property values * [ios, macos] color function/undefined getter * [ios, macos] fixed function/undefined getters for bool and float properties * [ios, macos] more function/undefined property getters * [ios, macos] more type conversion and cleanup * [ios, macos] disable macos runtime styling tests for now * [ios, macos] cleaned up style code script * [ios, macos] more type conversion * [ios] added a base layer to handle visibility min/max zoom * [macos] fixed base layer * [ios, macos] use accessor methods * [ios, macos] cleanup * [ios, macos] add geojson to ios and macos * [macos] rebase fix * [ios, macos] fixed enum getters and added tests for enums * [ios, macos] added an update method to base layer * [ios, macos] added some documentation * [ios, macos] docs * [ios, macos] removed refs to filters for now * [ios, macos] various tail work * [ios, macos] missing import and incorrect type
Diffstat (limited to 'platform/darwin')
-rw-r--r--platform/darwin/scripts/generate-style-code.js211
-rw-r--r--platform/darwin/src/MGLBackgroundStyleLayer.h27
-rw-r--r--platform/darwin/src/MGLBackgroundStyleLayer.mm57
-rw-r--r--platform/darwin/src/MGLBaseStyleLayer.h22
-rw-r--r--platform/darwin/src/MGLBaseStyleLayer.mm56
-rw-r--r--platform/darwin/src/MGLCircleStyleLayer.h57
-rw-r--r--platform/darwin/src/MGLCircleStyleLayer.mm89
-rw-r--r--platform/darwin/src/MGLFillStyleLayer.h52
-rw-r--r--platform/darwin/src/MGLFillStyleLayer.mm89
-rw-r--r--platform/darwin/src/MGLGeoJSONSource.h9
-rw-r--r--platform/darwin/src/MGLGeoJSONSource.mm43
-rw-r--r--platform/darwin/src/MGLLineStyleLayer.h101
-rw-r--r--platform/darwin/src/MGLLineStyleLayer.mm147
-rw-r--r--platform/darwin/src/MGLRasterSource.h10
-rw-r--r--platform/darwin/src/MGLRasterSource.mm26
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer.h47
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer.mm89
-rw-r--r--platform/darwin/src/MGLRuntimeStylingTests.m.ejs40
-rw-r--r--platform/darwin/src/MGLSource.h11
-rw-r--r--platform/darwin/src/MGLSource.mm20
-rw-r--r--platform/darwin/src/MGLSource_Private.hpp10
-rw-r--r--platform/darwin/src/MGLStyle.h55
-rw-r--r--platform/darwin/src/MGLStyle.mm96
-rw-r--r--platform/darwin/src/MGLStyleAttribute.hpp25
-rw-r--r--platform/darwin/src/MGLStyleAttribute.mm111
-rw-r--r--platform/darwin/src/MGLStyleAttributeFunction.h26
-rw-r--r--platform/darwin/src/MGLStyleAttributeFunction.mm243
-rw-r--r--platform/darwin/src/MGLStyleAttributeFunction_Private.hpp61
-rw-r--r--platform/darwin/src/MGLStyleAttributeValue.h7
-rw-r--r--platform/darwin/src/MGLStyleAttributeValue_Private.hpp25
-rw-r--r--platform/darwin/src/MGLStyleFilter.h5
-rw-r--r--platform/darwin/src/MGLStyleFilter.m5
-rw-r--r--platform/darwin/src/MGLStyleLayer.h17
-rw-r--r--platform/darwin/src/MGLStyleLayer.h.ejs55
-rw-r--r--platform/darwin/src/MGLStyleLayer.mm5
-rw-r--r--platform/darwin/src/MGLStyleLayer.mm.ejs64
-rw-r--r--platform/darwin/src/MGLStyleLayer_Private.hpp30
-rw-r--r--platform/darwin/src/MGLStyle_Private.hpp10
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer.h315
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer.mm419
-rw-r--r--platform/darwin/src/MGLTypes.h8
-rw-r--r--platform/darwin/src/MGLVectorSource.h5
-rw-r--r--platform/darwin/src/MGLVectorSource.m5
-rw-r--r--platform/darwin/src/NSArray+MGLStyleAttributeAdditions.h7
-rw-r--r--platform/darwin/src/NSArray+MGLStyleAttributeAdditions.mm54
-rw-r--r--platform/darwin/src/NSArray+MGLStyleAttributeAdditions_Private.hpp9
-rw-r--r--platform/darwin/src/NSColor+MGLStyleAttributeAdditions.h7
-rw-r--r--platform/darwin/src/NSColor+MGLStyleAttributeAdditions.m5
-rw-r--r--platform/darwin/src/NSColor+MGLStyleAttributeAdditions_Private.hpp9
-rw-r--r--platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.h7
-rw-r--r--platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.mm22
-rw-r--r--platform/darwin/src/NSNumber+MGLStyleAttributeAdditions_Private.hpp13
-rw-r--r--platform/darwin/src/NSString+MGLStyleAttributeAdditions.h7
-rw-r--r--platform/darwin/src/NSString+MGLStyleAttributeAdditions.mm17
-rw-r--r--platform/darwin/src/NSString+MGLStyleAttributeAdditions_Private.hpp11
-rw-r--r--platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h7
-rw-r--r--platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm19
-rw-r--r--platform/darwin/src/NSValue+MGLStyleAttributeAdditions_Private.hpp9
-rw-r--r--platform/darwin/src/UIColor+MGLStyleAttributeAdditions_Private.hpp9
-rw-r--r--platform/darwin/test/MGLBackgroundStyleLayerTests.m29
-rw-r--r--platform/darwin/test/MGLCircleStyleLayerTests.m37
-rw-r--r--platform/darwin/test/MGLFillStyleLayerTests.m37
-rw-r--r--platform/darwin/test/MGLLineStyleLayerTests.m51
-rw-r--r--platform/darwin/test/MGLRasterStyleLayerTests.m37
-rw-r--r--platform/darwin/test/MGLRuntimeStylingHelper.h25
-rw-r--r--platform/darwin/test/MGLRuntimeStylingHelper.m56
-rw-r--r--platform/darwin/test/MGLStyleLayerTests.h10
-rw-r--r--platform/darwin/test/MGLStyleLayerTests.m21
-rw-r--r--platform/darwin/test/MGLSymbolStyleLayerTests.m119
69 files changed, 3438 insertions, 1 deletions
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js
new file mode 100644
index 0000000000..fd1cf2f66d
--- /dev/null
+++ b/platform/darwin/scripts/generate-style-code.js
@@ -0,0 +1,211 @@
+'use strict';
+
+const fs = require('fs');
+const ejs = require('ejs');
+const spec = require('mapbox-gl-style-spec').latest;
+
+var prefix = 'MGL';
+var suffix = 'StyleLayer';
+
+global.camelize = function (str) {
+ return str.replace(/(?:^|-)(.)/g, function (_, x) {
+ return x.toUpperCase();
+ });
+};
+
+global.camelizeWithLeadingLowercase = function (str) {
+ return str.replace(/-(.)/g, function (_, x) {
+ return x.toUpperCase();
+ });
+};
+
+global.objCName = function (property) { return camelizeWithLeadingLowercase(property.name); }
+
+global.testImplementation = function (property, layerType) {
+ switch (property.type) {
+ case 'boolean':
+ return `layer.${objCName(property)} = MGLRuntimeStylingHelper.testBool;`;
+ case 'number':
+ return `layer.${objCName(property)} = MGLRuntimeStylingHelper.testNumber;`;
+ case 'string':
+ return `layer.${objCName(property)} = MGLRuntimeStylingHelper.testString;`;
+ case 'enum':
+ var objCType = `${prefix}${camelize(layerType)}${suffix}${camelize(property.name)}`;
+ var objCEnum = `${objCType}${camelize(property.values[property.values.length-1])}`;
+ return `layer.${objCName(property)} = [MGLRuntimeStylingHelper testEnum:${objCEnum} type:@encode(${objCType})];`;
+ case 'color':
+ return `layer.${objCName(property)} = MGLRuntimeStylingHelper.testColor;`;
+ case 'array':
+ return testArrayImplementation(property);
+ default: throw new Error(`unknown type for ${property.name}`)
+ }
+}
+
+global.testGetterImplementation = function (property, layerType) {
+ switch (property.type) {
+ case 'boolean':
+ return `XCTAssertEqualObjects(gLayer.${objCName(property)}, MGLRuntimeStylingHelper.testBool);`;
+ case 'number':
+ return `XCTAssertEqualObjects(gLayer.${objCName(property)}, MGLRuntimeStylingHelper.testNumber);`;
+ case 'string':
+ return `XCTAssertEqualObjects(gLayer.${objCName(property)}, MGLRuntimeStylingHelper.testString);`;
+ case 'enum':
+ var objCType = `${prefix}${camelize(layerType)}${suffix}${camelize(property.name)}`;
+ var objCEnum = `${objCType}${camelize(property.values[property.values.length-1])}`;
+ return `XCTAssert([(NSValue *)gLayer.${objCName(property)} objCType] == [[MGLRuntimeStylingHelper testEnum:${objCEnum} type:@encode(${objCType})] objCType]);`;
+ case 'color':
+ return `XCTAssertEqualObjects(gLayer.${objCName(property)}, MGLRuntimeStylingHelper.testColor);`;
+ case 'array':
+ return testGetterArrayImplementation(property);
+ default: throw new Error(`unknown type for ${property.name}`)
+ }
+}
+
+global.testGetterArrayImplementation = function (property) {
+ switch (property.name) {
+ case 'icon-text-fit-padding':
+ return `XCTAssertEqualObjects(gLayer.${objCName(property)}, MGLRuntimeStylingHelper.testPadding);`;
+ case 'line-dasharray':
+ return `XCTAssertEqualObjects(gLayer.${objCName(property)}, MGLRuntimeStylingHelper.testDashArray);`;
+ case 'text-font':
+ return `XCTAssertEqualObjects(gLayer.${objCName(property)}, MGLRuntimeStylingHelper.testFont);`;
+ default:
+ return `XCTAssertEqualObjects(gLayer.${objCName(property)}, MGLRuntimeStylingHelper.testOffset);`; // Default offset (dx, dy)
+ }
+};
+
+global.testArrayImplementation = function (property) {
+ switch (property.name) {
+ case 'icon-text-fit-padding':
+ return `layer.${objCName(property)} = MGLRuntimeStylingHelper.testPadding;`;
+ case 'line-dasharray':
+ return `layer.${objCName(property)} = MGLRuntimeStylingHelper.testDashArray;`;
+ case 'text-font':
+ return `layer.${objCName(property)} = MGLRuntimeStylingHelper.testFont;`;
+ default:
+ return `layer.${objCName(property)} = MGLRuntimeStylingHelper.testOffset;`; // Default offset (dx, dy)
+ }
+};
+
+global.propertyType = function (property, _private) {
+ return _private ? `id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>` : `id <MGLStyleAttributeValue>`;
+};
+
+global.initLayer = function (layerType) {
+ if (layerType == "background") {
+ return `_layer = new mbgl::style::${camelize(layerType)}Layer(layerIdentifier.UTF8String);`
+ } else {
+ return `_layer = new mbgl::style::${camelize(layerType)}Layer(layerIdentifier.UTF8String, sourceIdentifier.UTF8String);`
+ }
+}
+
+global.setterImplementation = function(property, layerType) {
+ switch (property.type) {
+ case 'boolean':
+ return `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_boolPropertyValue);`;
+ case 'number':
+ return `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_floatPropertyValue);`;
+ case 'string':
+ return `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_stringPropertyValue);`;
+ case 'enum':
+ var objCType = `${prefix}${camelize(layerType)}${suffix}${camelize(property.name)}`;
+ return `MGLSetEnumProperty(${objCName(property)}, ${camelize(property.name)}, ${mbglType(property)}, ${objCType});`;
+ case 'color':
+ return `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_colorPropertyValue);`;
+ case 'array':
+ return arraySetterImplementation(property);
+ default: throw new Error(`unknown type for ${property.name}`)
+ }
+}
+
+global.mbglType = function(property) {
+ var mbglType = camelize(property.name) + 'Type';
+ if (/-translate-anchor$/.test(property.name)) {
+ mbglType = 'TranslateAnchorType';
+ }
+ if (/-(rotation|pitch)-alignment$/.test(property.name)) {
+ mbglType = 'AlignmentType';
+ }
+ return mbglType;
+}
+
+global.arraySetterImplementation = function(property) {
+ return `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_${convertedType(property)}PropertyValue);`;
+}
+
+global.getterImplementation = function(property, layerType) {
+ switch (property.type) {
+ case 'boolean':
+ return `return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->get${camelize(property.name)}()];`
+ case 'number':
+ return `return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->get${camelize(property.name)}()];`
+ case 'string':
+ return `return [MGLStyleAttribute mbgl_stringPropertyValueWith:self.layer->get${camelize(property.name)}()];`
+ case 'enum':
+ var objCType = `${prefix}${camelize(layerType)}${suffix}${camelize(property.name)}`;
+ return `MGLGetEnumProperty(${camelize(property.name)}, ${mbglType(property)}, ${objCType});`;
+ case 'color':
+ return `return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->get${camelize(property.name)}()];`
+ case 'array':
+ return arrayGetterImplementation(property);
+ default:
+ throw new Error(`unknown type for ${property.name}`)
+ }
+}
+
+global.arrayGetterImplementation = function(property) {
+ return `return [MGLStyleAttribute mbgl_${convertedType(property)}PropertyValueWith:self.layer->get${camelize(property.name)}()];`
+}
+
+global.convertedType = function(property) {
+ switch (property.name) {
+ case 'boolean':
+ return 'bool';
+ case 'number':
+ return 'number';
+ case 'color':
+ return 'color';
+ case 'string':
+ return 'string';
+ case 'icon-text-fit-padding':
+ return "padding";
+ case 'line-dasharray':
+ return "numberArray";
+ case 'text-font':
+ return "stringArray";
+ default:
+ return "offset";
+ }
+}
+
+const layerH = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.h.ejs', 'utf8'), { strict: true });
+const layerM = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.mm.ejs', 'utf8'), { strict: true});
+const testLayers = ejs.compile(fs.readFileSync('platform/darwin/src/MGLRuntimeStylingTests.m.ejs', 'utf8'), { strict: true});
+
+const layers = spec.layer.type.values.map((type) => {
+ const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => {
+ if (name !== 'visibility') {
+ spec[`layout_${type}`][name].name = name;
+ memo.push(spec[`layout_${type}`][name]);
+ }
+ return memo;
+ }, []);
+
+ const paintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => {
+ spec[`paint_${type}`][name].name = name;
+ memo.push(spec[`paint_${type}`][name]);
+ return memo;
+ }, []);
+
+ return {
+ type: type,
+ layoutProperties: layoutProperties,
+ paintProperties: paintProperties,
+ };
+});
+
+for (const layer of layers) {
+ fs.writeFileSync(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.h`, layerH(layer));
+ fs.writeFileSync(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.mm`, layerM(layer));
+ fs.writeFileSync(`platform/darwin/test/${prefix}${camelize(layer.type)}${suffix}Tests.m`, testLayers(layer));
+}
diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.h b/platform/darwin/src/MGLBackgroundStyleLayer.h
new file mode 100644
index 0000000000..4b0fddeceb
--- /dev/null
+++ b/platform/darwin/src/MGLBackgroundStyleLayer.h
@@ -0,0 +1,27 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLTypes.h"
+#import "MGLStyleAttributeValue.h"
+#import "MGLBaseStyleLayer.h"
+
+@interface MGLBackgroundStyleLayer : MGLBaseStyleLayer <MGLStyleLayer>
+
+#pragma mark - Accessing the Paint Attributes
+
+/**
+ The color with which the background will be drawn.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> backgroundColor;
+
+/**
+ Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> backgroundPattern;
+
+/**
+ The opacity at which the background will be drawn.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> backgroundOpacity;
+
+@end
diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm
new file mode 100644
index 0000000000..66e308bb1f
--- /dev/null
+++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm
@@ -0,0 +1,57 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLStyleAttributeValue.h"
+#import "MGLBackgroundStyleLayer.h"
+
+#include <mbgl/style/layers/background_layer.hpp>
+
+@interface MGLBackgroundStyleLayer ()
+
+@property (nonatomic) mbgl::style::BackgroundLayer *layer;
+@property (nonatomic, readwrite) NSString *layerIdentifier;
+@property (nonatomic, readwrite) NSString *sourceIdentifier;
+
+@end
+
+@implementation MGLBackgroundStyleLayer
+
+@synthesize mapView;
+
+- (instancetype)initWithLayerIdentifier:(NSString *)layerIdentifier sourceIdentifier:(NSString *)sourceIdentifier {
+ if (self = [super init]) {
+ _layerIdentifier = layerIdentifier;
+ _sourceIdentifier = sourceIdentifier;
+ _layer = new mbgl::style::BackgroundLayer(layerIdentifier.UTF8String);
+ }
+ return self;
+}
+
+#pragma mark - Accessing the Paint Attributes
+
+- (void)setBackgroundColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)backgroundColor {
+ self.layer->setBackgroundColor(backgroundColor.mbgl_colorPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)backgroundColor {
+ return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->getBackgroundColor()];
+}
+
+- (void)setBackgroundPattern:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)backgroundPattern {
+ self.layer->setBackgroundPattern(backgroundPattern.mbgl_stringPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)backgroundPattern {
+ return [MGLStyleAttribute mbgl_stringPropertyValueWith:self.layer->getBackgroundPattern()];
+}
+
+- (void)setBackgroundOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)backgroundOpacity {
+ self.layer->setBackgroundOpacity(backgroundOpacity.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)backgroundOpacity {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getBackgroundOpacity()];
+}
+
+@end
diff --git a/platform/darwin/src/MGLBaseStyleLayer.h b/platform/darwin/src/MGLBaseStyleLayer.h
new file mode 100644
index 0000000000..597b67cdc2
--- /dev/null
+++ b/platform/darwin/src/MGLBaseStyleLayer.h
@@ -0,0 +1,22 @@
+#import <Foundation/Foundation.h>
+
+@interface MGLBaseStyleLayer : NSObject
+
+@property (nonatomic, assign, getter=isVisible) BOOL visible;
+
+/**
+ The maximum zoom level on which the layer gets parsed and appears on.
+ */
+@property (nonatomic, assign) float maximumZoomLevel;
+
+/**
+ The minimum zoom level on which the layer gets parsed and appears on.
+ */
+@property (nonatomic, assign) float minimumZoomLevel;
+
+/**
+ Updates the layer’s layout and paint properties.
+ */
+- (void)update;
+
+@end
diff --git a/platform/darwin/src/MGLBaseStyleLayer.mm b/platform/darwin/src/MGLBaseStyleLayer.mm
new file mode 100644
index 0000000000..c567ce33d8
--- /dev/null
+++ b/platform/darwin/src/MGLBaseStyleLayer.mm
@@ -0,0 +1,56 @@
+#import "MGLBaseStyleLayer.h"
+
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLMapView_Private.hpp"
+
+#include <mbgl/style/layer.hpp>
+
+@interface MGLBaseStyleLayer() <MGLStyleLayer_Private>
+@end
+
+@implementation MGLBaseStyleLayer
+
+@synthesize layerIdentifier;
+@synthesize mapView;
+@synthesize layer;
+
+- (void)update
+{
+ self.mapView.mbglMap->update(mbgl::Update::RecalculateStyle | mbgl::Update::Classes);
+}
+
+- (void)setVisible:(BOOL)visible
+{
+ mbgl::style::VisibilityType v = visible
+ ? mbgl::style::VisibilityType::Visible
+ : mbgl::style::VisibilityType::None;
+ self.layer->setVisibility(v);
+}
+
+- (BOOL)isVisible
+{
+ mbgl::style::VisibilityType v = self.layer->getVisibility();
+ return (v == mbgl::style::VisibilityType::Visible);
+}
+
+- (void)setMaximumZoomLevel:(float)maximumZoomLevel
+{
+ self.layer->setMaxZoom(maximumZoomLevel);
+}
+
+- (float)maximumZoomLevel
+{
+ return self.layer->getMaxZoom();
+}
+
+- (void)setMinimumZoomLevel:(float)minimumZoomLevel
+{
+ self.layer->setMinZoom(minimumZoomLevel);
+}
+
+- (float)minimumZoomLevel
+{
+ return self.layer->getMinZoom();
+}
+
+@end
diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h
new file mode 100644
index 0000000000..eaab3b843d
--- /dev/null
+++ b/platform/darwin/src/MGLCircleStyleLayer.h
@@ -0,0 +1,57 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLTypes.h"
+#import "MGLStyleAttributeValue.h"
+#import "MGLBaseStyleLayer.h"
+
+typedef NS_ENUM(NSUInteger, MGLCircleStyleLayerCircleTranslateAnchor) {
+ MGLCircleStyleLayerCircleTranslateAnchorMap,
+ MGLCircleStyleLayerCircleTranslateAnchorViewport,
+};
+
+typedef NS_ENUM(NSUInteger, MGLCircleStyleLayerCirclePitchScale) {
+ MGLCircleStyleLayerCirclePitchScaleMap,
+ MGLCircleStyleLayerCirclePitchScaleViewport,
+};
+
+@interface MGLCircleStyleLayer : MGLBaseStyleLayer <MGLStyleLayer>
+
+#pragma mark - Accessing the Paint Attributes
+
+/**
+ Circle radius.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> circleRadius;
+
+/**
+ The color of the circle.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> circleColor;
+
+/**
+ Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> circleBlur;
+
+/**
+ The opacity at which the circle will be drawn.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> circleOpacity;
+
+/**
+ The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> circleTranslate;
+
+/**
+ Control whether the translation is relative to the map (north) or viewport (screen)
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> circleTranslateAnchor;
+
+/**
+ Controls the scaling behavior of the circle when the map is pitched. The value `map` scales circles according to their apparent distance to the camera. The value `viewport` results in no pitch-related scaling.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> circlePitchScale;
+
+@end
diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm
new file mode 100644
index 0000000000..44d6e39e79
--- /dev/null
+++ b/platform/darwin/src/MGLCircleStyleLayer.mm
@@ -0,0 +1,89 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLStyleAttributeValue.h"
+#import "MGLCircleStyleLayer.h"
+
+#include <mbgl/style/layers/circle_layer.hpp>
+
+@interface MGLCircleStyleLayer ()
+
+@property (nonatomic) mbgl::style::CircleLayer *layer;
+@property (nonatomic, readwrite) NSString *layerIdentifier;
+@property (nonatomic, readwrite) NSString *sourceIdentifier;
+
+@end
+
+@implementation MGLCircleStyleLayer
+
+@synthesize mapView;
+
+- (instancetype)initWithLayerIdentifier:(NSString *)layerIdentifier sourceIdentifier:(NSString *)sourceIdentifier {
+ if (self = [super init]) {
+ _layerIdentifier = layerIdentifier;
+ _sourceIdentifier = sourceIdentifier;
+ _layer = new mbgl::style::CircleLayer(layerIdentifier.UTF8String, sourceIdentifier.UTF8String);
+ }
+ return self;
+}
+
+#pragma mark - Accessing the Paint Attributes
+
+- (void)setCircleRadius:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleRadius {
+ self.layer->setCircleRadius(circleRadius.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)circleRadius {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getCircleRadius()];
+}
+
+- (void)setCircleColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleColor {
+ self.layer->setCircleColor(circleColor.mbgl_colorPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)circleColor {
+ return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->getCircleColor()];
+}
+
+- (void)setCircleBlur:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleBlur {
+ self.layer->setCircleBlur(circleBlur.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)circleBlur {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getCircleBlur()];
+}
+
+- (void)setCircleOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleOpacity {
+ self.layer->setCircleOpacity(circleOpacity.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)circleOpacity {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getCircleOpacity()];
+}
+
+- (void)setCircleTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleTranslate {
+ self.layer->setCircleTranslate(circleTranslate.mbgl_offsetPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)circleTranslate {
+ return [MGLStyleAttribute mbgl_offsetPropertyValueWith:self.layer->getCircleTranslate()];
+}
+
+- (void)setCircleTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circleTranslateAnchor {
+ MGLSetEnumProperty(circleTranslateAnchor, CircleTranslateAnchor, TranslateAnchorType, MGLCircleStyleLayerCircleTranslateAnchor);
+}
+
+- (id <MGLStyleAttributeValue>)circleTranslateAnchor {
+ MGLGetEnumProperty(CircleTranslateAnchor, TranslateAnchorType, MGLCircleStyleLayerCircleTranslateAnchor);
+}
+
+- (void)setCirclePitchScale:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)circlePitchScale {
+ MGLSetEnumProperty(circlePitchScale, CirclePitchScale, CirclePitchScaleType, MGLCircleStyleLayerCirclePitchScale);
+}
+
+- (id <MGLStyleAttributeValue>)circlePitchScale {
+ MGLGetEnumProperty(CirclePitchScale, CirclePitchScaleType, MGLCircleStyleLayerCirclePitchScale);
+}
+
+@end
diff --git a/platform/darwin/src/MGLFillStyleLayer.h b/platform/darwin/src/MGLFillStyleLayer.h
new file mode 100644
index 0000000000..06a58b12bd
--- /dev/null
+++ b/platform/darwin/src/MGLFillStyleLayer.h
@@ -0,0 +1,52 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLTypes.h"
+#import "MGLStyleAttributeValue.h"
+#import "MGLBaseStyleLayer.h"
+
+typedef NS_ENUM(NSUInteger, MGLFillStyleLayerFillTranslateAnchor) {
+ MGLFillStyleLayerFillTranslateAnchorMap,
+ MGLFillStyleLayerFillTranslateAnchorViewport,
+};
+
+@interface MGLFillStyleLayer : MGLBaseStyleLayer <MGLStyleLayer>
+
+#pragma mark - Accessing the Paint Attributes
+
+/**
+ Whether or not the fill should be antialiased.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> fillAntialias;
+
+/**
+ The opacity of the entire fill layer. In contrast to the fill-color, this value will also affect the 1px stroke around the fill, if the stroke is used.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> fillOpacity;
+
+/**
+ The color of the filled part of this layer. This color can be specified as rgba with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> fillColor;
+
+/**
+ The outline color of the fill. Matches the value of `fill-color` if unspecified.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> fillOutlineColor;
+
+/**
+ The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> fillTranslate;
+
+/**
+ Control whether the translation is relative to the map (north) or viewport (screen)
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> fillTranslateAnchor;
+
+/**
+ Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512).
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> fillPattern;
+
+@end
diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm
new file mode 100644
index 0000000000..95e82a2e52
--- /dev/null
+++ b/platform/darwin/src/MGLFillStyleLayer.mm
@@ -0,0 +1,89 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLStyleAttributeValue.h"
+#import "MGLFillStyleLayer.h"
+
+#include <mbgl/style/layers/fill_layer.hpp>
+
+@interface MGLFillStyleLayer ()
+
+@property (nonatomic) mbgl::style::FillLayer *layer;
+@property (nonatomic, readwrite) NSString *layerIdentifier;
+@property (nonatomic, readwrite) NSString *sourceIdentifier;
+
+@end
+
+@implementation MGLFillStyleLayer
+
+@synthesize mapView;
+
+- (instancetype)initWithLayerIdentifier:(NSString *)layerIdentifier sourceIdentifier:(NSString *)sourceIdentifier {
+ if (self = [super init]) {
+ _layerIdentifier = layerIdentifier;
+ _sourceIdentifier = sourceIdentifier;
+ _layer = new mbgl::style::FillLayer(layerIdentifier.UTF8String, sourceIdentifier.UTF8String);
+ }
+ return self;
+}
+
+#pragma mark - Accessing the Paint Attributes
+
+- (void)setFillAntialias:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillAntialias {
+ self.layer->setFillAntialias(fillAntialias.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)fillAntialias {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getFillAntialias()];
+}
+
+- (void)setFillOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillOpacity {
+ self.layer->setFillOpacity(fillOpacity.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)fillOpacity {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getFillOpacity()];
+}
+
+- (void)setFillColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillColor {
+ self.layer->setFillColor(fillColor.mbgl_colorPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)fillColor {
+ return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->getFillColor()];
+}
+
+- (void)setFillOutlineColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillOutlineColor {
+ self.layer->setFillOutlineColor(fillOutlineColor.mbgl_colorPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)fillOutlineColor {
+ return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->getFillOutlineColor()];
+}
+
+- (void)setFillTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillTranslate {
+ self.layer->setFillTranslate(fillTranslate.mbgl_offsetPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)fillTranslate {
+ return [MGLStyleAttribute mbgl_offsetPropertyValueWith:self.layer->getFillTranslate()];
+}
+
+- (void)setFillTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillTranslateAnchor {
+ MGLSetEnumProperty(fillTranslateAnchor, FillTranslateAnchor, TranslateAnchorType, MGLFillStyleLayerFillTranslateAnchor);
+}
+
+- (id <MGLStyleAttributeValue>)fillTranslateAnchor {
+ MGLGetEnumProperty(FillTranslateAnchor, TranslateAnchorType, MGLFillStyleLayerFillTranslateAnchor);
+}
+
+- (void)setFillPattern:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)fillPattern {
+ self.layer->setFillPattern(fillPattern.mbgl_stringPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)fillPattern {
+ return [MGLStyleAttribute mbgl_stringPropertyValueWith:self.layer->getFillPattern()];
+}
+
+@end
diff --git a/platform/darwin/src/MGLGeoJSONSource.h b/platform/darwin/src/MGLGeoJSONSource.h
new file mode 100644
index 0000000000..58c0f6b794
--- /dev/null
+++ b/platform/darwin/src/MGLGeoJSONSource.h
@@ -0,0 +1,9 @@
+#import "MGLSource.h"
+
+@interface MGLGeoJSONSource : MGLSource
+
+@property (nonatomic, readonly, copy) NSString *data;
+
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url NS_DESIGNATED_INITIALIZER;
+
+@end
diff --git a/platform/darwin/src/MGLGeoJSONSource.mm b/platform/darwin/src/MGLGeoJSONSource.mm
new file mode 100644
index 0000000000..92c5b87e89
--- /dev/null
+++ b/platform/darwin/src/MGLGeoJSONSource.mm
@@ -0,0 +1,43 @@
+#import "MGLGeoJSONSource.h"
+
+#import "MGLSource_Private.hpp"
+
+#include <mbgl/style/sources/geojson_source.hpp>
+
+@interface MGLGeoJSONSource ()
+
+@property (nonatomic, copy) NSURL *URL;
+
+@end
+
+@implementation MGLGeoJSONSource
+
+static NSString *MGLGeoJSONSourceType = @"geojson";
+static NSString *MGLGeoJSONDataKey = @"data";
+
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url
+{
+ if (self = [super initWithSourceIdentifier:sourceIdentifier sourceType:MGLGeoJSONSourceType]) {
+ _URL = url;
+ if (url.isFileURL) {
+ _data = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:NULL];
+ } else {
+ _data = url.absoluteString;
+ }
+ }
+ return self;
+}
+
+- (std::unique_ptr<mbgl::style::Source>)mbgl_source
+{
+ auto source = std::make_unique<mbgl::style::GeoJSONSource>(self.sourceIdentifier.UTF8String);
+ if (_URL.isFileURL) {
+ const auto geojson = mapbox::geojson::parse(self.data.UTF8String).get<mapbox::geojson::feature_collection>();
+ source->setGeoJSON(geojson);
+ } else {
+ source->setURL(self.data.UTF8String);
+ }
+ return std::move(source);
+}
+
+@end
diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h
new file mode 100644
index 0000000000..6f3472b0b3
--- /dev/null
+++ b/platform/darwin/src/MGLLineStyleLayer.h
@@ -0,0 +1,101 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLTypes.h"
+#import "MGLStyleAttributeValue.h"
+#import "MGLBaseStyleLayer.h"
+
+typedef NS_ENUM(NSUInteger, MGLLineStyleLayerLineCap) {
+ MGLLineStyleLayerLineCapButt,
+ MGLLineStyleLayerLineCapRound,
+ MGLLineStyleLayerLineCapSquare,
+};
+
+typedef NS_ENUM(NSUInteger, MGLLineStyleLayerLineJoin) {
+ MGLLineStyleLayerLineJoinBevel,
+ MGLLineStyleLayerLineJoinRound,
+ MGLLineStyleLayerLineJoinMiter,
+};
+
+typedef NS_ENUM(NSUInteger, MGLLineStyleLayerLineTranslateAnchor) {
+ MGLLineStyleLayerLineTranslateAnchorMap,
+ MGLLineStyleLayerLineTranslateAnchorViewport,
+};
+
+@interface MGLLineStyleLayer : MGLBaseStyleLayer <MGLStyleLayer>
+
+#pragma mark - Accessing the Layout Attributes
+
+/**
+ The display of line endings.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineCap;
+
+/**
+ The display of lines when joining.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineJoin;
+
+/**
+ Used to automatically convert miter joins to bevel joins for sharp angles.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineMiterLimit;
+
+/**
+ Used to automatically convert round joins to miter joins for shallow angles.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineRoundLimit;
+
+#pragma mark - Accessing the Paint Attributes
+
+/**
+ The opacity at which the line will be drawn.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineOpacity;
+
+/**
+ The color with which the line will be drawn.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineColor;
+
+/**
+ The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineTranslate;
+
+/**
+ Control whether the translation is relative to the map (north) or viewport (screen)
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineTranslateAnchor;
+
+/**
+ Stroke thickness.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineWidth;
+
+/**
+ Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineGapWidth;
+
+/**
+ The line's offset perpendicular to its direction. Values may be positive or negative, where positive indicates "rightwards" (if you were moving in the direction of the line) and negative indicates "leftwards."
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineOffset;
+
+/**
+ Blur applied to the line, in pixels.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineBlur;
+
+/**
+ Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> lineDasharray;
+
+/**
+ Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512).
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> linePattern;
+
+@end
diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm
new file mode 100644
index 0000000000..8c6ee1e6d2
--- /dev/null
+++ b/platform/darwin/src/MGLLineStyleLayer.mm
@@ -0,0 +1,147 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLStyleAttributeValue.h"
+#import "MGLLineStyleLayer.h"
+
+#include <mbgl/style/layers/line_layer.hpp>
+
+@interface MGLLineStyleLayer ()
+
+@property (nonatomic) mbgl::style::LineLayer *layer;
+@property (nonatomic, readwrite) NSString *layerIdentifier;
+@property (nonatomic, readwrite) NSString *sourceIdentifier;
+
+@end
+
+@implementation MGLLineStyleLayer
+
+@synthesize mapView;
+
+- (instancetype)initWithLayerIdentifier:(NSString *)layerIdentifier sourceIdentifier:(NSString *)sourceIdentifier {
+ if (self = [super init]) {
+ _layerIdentifier = layerIdentifier;
+ _sourceIdentifier = sourceIdentifier;
+ _layer = new mbgl::style::LineLayer(layerIdentifier.UTF8String, sourceIdentifier.UTF8String);
+ }
+ return self;
+}
+
+#pragma mark - Accessing the Layout Attributes
+
+- (void)setLineCap:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineCap {
+ MGLSetEnumProperty(lineCap, LineCap, LineCapType, MGLLineStyleLayerLineCap);
+}
+
+- (id <MGLStyleAttributeValue>)lineCap {
+ MGLGetEnumProperty(LineCap, LineCapType, MGLLineStyleLayerLineCap);
+}
+
+- (void)setLineJoin:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineJoin {
+ MGLSetEnumProperty(lineJoin, LineJoin, LineJoinType, MGLLineStyleLayerLineJoin);
+}
+
+- (id <MGLStyleAttributeValue>)lineJoin {
+ MGLGetEnumProperty(LineJoin, LineJoinType, MGLLineStyleLayerLineJoin);
+}
+
+- (void)setLineMiterLimit:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineMiterLimit {
+ self.layer->setLineMiterLimit(lineMiterLimit.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineMiterLimit {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getLineMiterLimit()];
+}
+
+- (void)setLineRoundLimit:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineRoundLimit {
+ self.layer->setLineRoundLimit(lineRoundLimit.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineRoundLimit {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getLineRoundLimit()];
+}
+
+#pragma mark - Accessing the Paint Attributes
+
+- (void)setLineOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineOpacity {
+ self.layer->setLineOpacity(lineOpacity.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineOpacity {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getLineOpacity()];
+}
+
+- (void)setLineColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineColor {
+ self.layer->setLineColor(lineColor.mbgl_colorPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineColor {
+ return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->getLineColor()];
+}
+
+- (void)setLineTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineTranslate {
+ self.layer->setLineTranslate(lineTranslate.mbgl_offsetPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineTranslate {
+ return [MGLStyleAttribute mbgl_offsetPropertyValueWith:self.layer->getLineTranslate()];
+}
+
+- (void)setLineTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineTranslateAnchor {
+ MGLSetEnumProperty(lineTranslateAnchor, LineTranslateAnchor, TranslateAnchorType, MGLLineStyleLayerLineTranslateAnchor);
+}
+
+- (id <MGLStyleAttributeValue>)lineTranslateAnchor {
+ MGLGetEnumProperty(LineTranslateAnchor, TranslateAnchorType, MGLLineStyleLayerLineTranslateAnchor);
+}
+
+- (void)setLineWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineWidth {
+ self.layer->setLineWidth(lineWidth.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineWidth {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getLineWidth()];
+}
+
+- (void)setLineGapWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineGapWidth {
+ self.layer->setLineGapWidth(lineGapWidth.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineGapWidth {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getLineGapWidth()];
+}
+
+- (void)setLineOffset:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineOffset {
+ self.layer->setLineOffset(lineOffset.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineOffset {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getLineOffset()];
+}
+
+- (void)setLineBlur:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineBlur {
+ self.layer->setLineBlur(lineBlur.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineBlur {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getLineBlur()];
+}
+
+- (void)setLineDasharray:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)lineDasharray {
+ self.layer->setLineDasharray(lineDasharray.mbgl_numberArrayPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)lineDasharray {
+ return [MGLStyleAttribute mbgl_numberArrayPropertyValueWith:self.layer->getLineDasharray()];
+}
+
+- (void)setLinePattern:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)linePattern {
+ self.layer->setLinePattern(linePattern.mbgl_stringPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)linePattern {
+ return [MGLStyleAttribute mbgl_stringPropertyValueWith:self.layer->getLinePattern()];
+}
+
+@end
diff --git a/platform/darwin/src/MGLRasterSource.h b/platform/darwin/src/MGLRasterSource.h
new file mode 100644
index 0000000000..e563244bce
--- /dev/null
+++ b/platform/darwin/src/MGLRasterSource.h
@@ -0,0 +1,10 @@
+#import "MGLSource.h"
+
+@interface MGLRasterSource : MGLSource
+
+@property (nonatomic, readonly, copy) NSURL *URL;
+@property (nonatomic, readonly, assign) CGFloat tileSize;
+
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url tileSize:(CGFloat)tileSize;
+
+@end
diff --git a/platform/darwin/src/MGLRasterSource.mm b/platform/darwin/src/MGLRasterSource.mm
new file mode 100644
index 0000000000..5f3881b285
--- /dev/null
+++ b/platform/darwin/src/MGLRasterSource.mm
@@ -0,0 +1,26 @@
+#import "MGLRasterSource.h"
+
+#import "MGLSource_Private.hpp"
+
+#include <mbgl/style/sources/raster_source.hpp>
+
+@implementation MGLRasterSource
+
+static NSString *MGLRasterSourceType = @"raster";
+
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url tileSize:(CGFloat)tileSize {
+ if (self = [super initWithSourceIdentifier:sourceIdentifier sourceType:MGLRasterSourceType]) {
+ _URL = url;
+ _tileSize = tileSize;
+ }
+ return self;
+}
+
+- (std::unique_ptr<mbgl::style::Source>)mbgl_source {
+ auto source = std::make_unique<mbgl::style::RasterSource>(self.sourceIdentifier.UTF8String,
+ self.URL.absoluteString.UTF8String,
+ uint16_t(self.tileSize));
+ return std::move(source);
+}
+
+@end
diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h
new file mode 100644
index 0000000000..e666862339
--- /dev/null
+++ b/platform/darwin/src/MGLRasterStyleLayer.h
@@ -0,0 +1,47 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLTypes.h"
+#import "MGLStyleAttributeValue.h"
+#import "MGLBaseStyleLayer.h"
+
+@interface MGLRasterStyleLayer : MGLBaseStyleLayer <MGLStyleLayer>
+
+#pragma mark - Accessing the Paint Attributes
+
+/**
+ The opacity at which the image will be drawn.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> rasterOpacity;
+
+/**
+ Rotates hues around the color wheel.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> rasterHueRotate;
+
+/**
+ Increase or reduce the brightness of the image. The value is the minimum brightness.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> rasterBrightnessMin;
+
+/**
+ Increase or reduce the brightness of the image. The value is the maximum brightness.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> rasterBrightnessMax;
+
+/**
+ Increase or reduce the saturation of the image.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> rasterSaturation;
+
+/**
+ Increase or reduce the contrast of the image.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> rasterContrast;
+
+/**
+ Fade duration when a new tile is added.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> rasterFadeDuration;
+
+@end
diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm
new file mode 100644
index 0000000000..f976f3ddaf
--- /dev/null
+++ b/platform/darwin/src/MGLRasterStyleLayer.mm
@@ -0,0 +1,89 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLStyleAttributeValue.h"
+#import "MGLRasterStyleLayer.h"
+
+#include <mbgl/style/layers/raster_layer.hpp>
+
+@interface MGLRasterStyleLayer ()
+
+@property (nonatomic) mbgl::style::RasterLayer *layer;
+@property (nonatomic, readwrite) NSString *layerIdentifier;
+@property (nonatomic, readwrite) NSString *sourceIdentifier;
+
+@end
+
+@implementation MGLRasterStyleLayer
+
+@synthesize mapView;
+
+- (instancetype)initWithLayerIdentifier:(NSString *)layerIdentifier sourceIdentifier:(NSString *)sourceIdentifier {
+ if (self = [super init]) {
+ _layerIdentifier = layerIdentifier;
+ _sourceIdentifier = sourceIdentifier;
+ _layer = new mbgl::style::RasterLayer(layerIdentifier.UTF8String, sourceIdentifier.UTF8String);
+ }
+ return self;
+}
+
+#pragma mark - Accessing the Paint Attributes
+
+- (void)setRasterOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterOpacity {
+ self.layer->setRasterOpacity(rasterOpacity.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)rasterOpacity {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getRasterOpacity()];
+}
+
+- (void)setRasterHueRotate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterHueRotate {
+ self.layer->setRasterHueRotate(rasterHueRotate.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)rasterHueRotate {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getRasterHueRotate()];
+}
+
+- (void)setRasterBrightnessMin:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterBrightnessMin {
+ self.layer->setRasterBrightnessMin(rasterBrightnessMin.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)rasterBrightnessMin {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getRasterBrightnessMin()];
+}
+
+- (void)setRasterBrightnessMax:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterBrightnessMax {
+ self.layer->setRasterBrightnessMax(rasterBrightnessMax.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)rasterBrightnessMax {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getRasterBrightnessMax()];
+}
+
+- (void)setRasterSaturation:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterSaturation {
+ self.layer->setRasterSaturation(rasterSaturation.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)rasterSaturation {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getRasterSaturation()];
+}
+
+- (void)setRasterContrast:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterContrast {
+ self.layer->setRasterContrast(rasterContrast.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)rasterContrast {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getRasterContrast()];
+}
+
+- (void)setRasterFadeDuration:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)rasterFadeDuration {
+ self.layer->setRasterFadeDuration(rasterFadeDuration.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)rasterFadeDuration {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getRasterFadeDuration()];
+}
+
+@end
diff --git a/platform/darwin/src/MGLRuntimeStylingTests.m.ejs b/platform/darwin/src/MGLRuntimeStylingTests.m.ejs
new file mode 100644
index 0000000000..fff6aaf697
--- /dev/null
+++ b/platform/darwin/src/MGLRuntimeStylingTests.m.ejs
@@ -0,0 +1,40 @@
+<%
+ const type = locals.type;
+ const layoutProperties = locals.layoutProperties;
+ const paintProperties = locals.paintProperties;
+-%>
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayerTests.h"
+
+@interface MGL<%- camelize(type) %>LayerTests : MGLStyleLayerTests
+@end
+
+@implementation MGL<%- camelize(type) %>LayerTests
+
+- (void)test<%- camelize(type) %>Layer {
+ NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"];
+ NSURL *url = [NSURL fileURLWithPath:filePath];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url];
+ MGL<%- camelize(type) %>StyleLayer *layer = [[MGL<%- camelize(type) %>StyleLayer alloc] initWithLayerIdentifier:@"layerID" sourceIdentifier:@"sourceID"];
+ [self.mapView.style addSource:source];
+ [self.mapView.style addLayer:layer];
+
+<% for (const property of layoutProperties) { -%>
+ <%- testImplementation(property, type) %>
+<% } -%>
+<% for (const property of paintProperties) { -%>
+ <%- testImplementation(property, type) %>
+<% } -%>
+
+ MGL<%- camelize(type) %>StyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"];
+<% for (const property of layoutProperties) { -%>
+ <%- testGetterImplementation(property, type) %>
+<% } -%>
+<% for (const property of paintProperties) { -%>
+ <%- testGetterImplementation(property, type) %>
+<% } -%>
+}
+
+@end
diff --git a/platform/darwin/src/MGLSource.h b/platform/darwin/src/MGLSource.h
new file mode 100644
index 0000000000..b08a09ec4d
--- /dev/null
+++ b/platform/darwin/src/MGLSource.h
@@ -0,0 +1,11 @@
+#import <Foundation/Foundation.h>
+#import <CoreGraphics/CoreGraphics.h>
+
+@interface MGLSource : NSObject
+
+@property (nonatomic, copy) NSString *sourceIdentifier;
+@property (nonatomic, copy) NSString *sourceType;
+
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier sourceType:(NSString *)sourceType;
+
+@end
diff --git a/platform/darwin/src/MGLSource.mm b/platform/darwin/src/MGLSource.mm
new file mode 100644
index 0000000000..c80fbe914c
--- /dev/null
+++ b/platform/darwin/src/MGLSource.mm
@@ -0,0 +1,20 @@
+#import "MGLSource.h"
+
+#include <mbgl/style/source.hpp>
+
+@implementation MGLSource
+
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier sourceType:(NSString *)sourceType {
+ if (self = [super init]) {
+ _sourceIdentifier = sourceIdentifier;
+ _sourceType = sourceType;
+ }
+ return self;
+}
+
+- (std::unique_ptr<mbgl::style::Source>)mbgl_source {
+ [NSException raise:@"Subclasses must override this method" format:@""];
+ return nil;
+}
+
+@end
diff --git a/platform/darwin/src/MGLSource_Private.hpp b/platform/darwin/src/MGLSource_Private.hpp
new file mode 100644
index 0000000000..bbbd556635
--- /dev/null
+++ b/platform/darwin/src/MGLSource_Private.hpp
@@ -0,0 +1,10 @@
+#import "MGLSource.h"
+
+#include <mbgl/mbgl.hpp>
+#include <mbgl/style/source.hpp>
+
+@interface MGLSource (Private)
+
+- (std::unique_ptr<mbgl::style::Source>)mbgl_source;
+
+@end
diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h
index 8577522b96..368557fc81 100644
--- a/platform/darwin/src/MGLStyle.h
+++ b/platform/darwin/src/MGLStyle.h
@@ -2,6 +2,10 @@
#import "MGLTypes.h"
+#import "MGLStyleLayer.h"
+
+@class MGLSource;
+
NS_ASSUME_NONNULL_BEGIN
/**
@@ -32,6 +36,8 @@ static const NSInteger MGLStyleDefaultVersion = 9;
*/
@interface MGLStyle : NSObject
+#pragma mark Default Style URLs
+
/**
Returns the URL to version 8 of the
<a href="https://www.mapbox.com/maps/streets/">Mapbox Streets</a> style.
@@ -158,7 +164,54 @@ static const NSInteger MGLStyleDefaultVersion = 9;
*/
+ (NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version;
-- (instancetype)init NS_UNAVAILABLE;
+#pragma mark Runtime Styling
+
+/**
+ Returns a layer that conforms to `MGLStyleLayer` if any layer with the given
+ identifier was found.
+
+ @return layer A layer instance of the corresponding type.
+ */
+- (nullable id <MGLStyleLayer>)layerWithIdentifier:(NSString *)identifier;
+
+/**
+ Adds a new layer at the top of the hierarchy.
+
+ @param styleLayer The layer object to add to the map view. This object
+ must conform to the `MGLStyleLayer` protocol.
+ */
+- (void)addLayer:(id <MGLStyleLayer>)styleLayer;
+
+/**
+ Inserts a new layer below another layer.
+
+ @param styleLayer Layer to be inserted.
+ @param belowLayer A layer that's already on the map view.
+ */
+- (void)insertLayer:(id <MGLStyleLayer>)styleLayer
+ belowLayer:(id <MGLStyleLayer>)belowLayer;
+
+/**
+ Removes a layer from the map view.
+
+ @param styleLayer The layer object to remove from the map view. This object
+ must conform to the `MGLStyleLayer` protocol.
+ */
+- (void)removeLayer:(id <MGLStyleLayer>)styleLayer;
+
+/**
+ Adds a new source to the map view.
+
+ @param source The source to add to the map view.
+ */
+- (void)addSource:(MGLSource *)source;
+
+/**
+ Removes a source from the map view.
+
+ @param source The source to remove.
+ */
+- (void)removeSource:(MGLSource *)source;
@end
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index 347fc2be24..c75572052b 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -1,6 +1,32 @@
#import "MGLStyle.h"
+#import "MGLMapView_Private.hpp"
+#import "MGLStyleLayer.h"
+#import "MGLFillStyleLayer.h"
+#import "MGLLineStyleLayer.h"
+#import "MGLCircleStyleLayer.h"
+#import "MGLSymbolStyleLayer.h"
+#import "MGLRasterStyleLayer.h"
+#import "MGLBackgroundStyleLayer.h"
+
+#import "MGLStyle_Private.hpp"
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLSource_Private.hpp"
+#import "MGLSource.h"
+
#import <mbgl/util/default_styles.hpp>
+#include <mbgl/style/layers/fill_layer.hpp>
+#include <mbgl/style/layers/line_layer.hpp>
+#include <mbgl/style/layers/symbol_layer.hpp>
+#include <mbgl/style/layers/raster_layer.hpp>
+#include <mbgl/style/layers/circle_layer.hpp>
+#include <mbgl/style/layers/background_layer.hpp>
+#include <mbgl/style/sources/geojson_source.hpp>
+#include <mbgl/mbgl.hpp>
+
+@interface MGLStyle()
+@property (nonatomic, weak) MGLMapView *mapView;
+@end
@implementation MGLStyle
@@ -54,4 +80,74 @@ static NSURL *MGLStyleURL_emerald;
return MGLStyleURL_emerald;
}
+- (mbgl::style::Layer *)mbglLayerWithIdentifier:(NSString *)identifier
+{
+ return self.mapView.mbglMap->getLayer(identifier.UTF8String);
+}
+
+- (mbgl::style::Source *)mbglSourceWithIdentifier:(NSString *)identifier
+{
+ return self.mapView.mbglMap->getSource(identifier.UTF8String);
+}
+
+- (id <MGLStyleLayer>)layerWithIdentifier:(NSString *)identifier
+{
+ auto layer = self.mapView.mbglMap->getLayer(identifier.UTF8String);
+
+ Class clazz = [self classFromLayer:layer];
+
+ id <MGLStyleLayer, MGLStyleLayer_Private> styleLayer = [[clazz alloc] init];
+ styleLayer.layerIdentifier = identifier;
+ styleLayer.layer = layer;
+ styleLayer.mapView = self.mapView;
+
+ return styleLayer;
+}
+
+- (Class)classFromLayer:(mbgl::style::Layer *)layer
+{
+ if (layer->is<mbgl::style::FillLayer>()) {
+ return MGLFillStyleLayer.class;
+ } else if (layer->is<mbgl::style::LineLayer>()) {
+ return MGLLineStyleLayer.class;
+ } else if (layer->is<mbgl::style::SymbolLayer>()) {
+ return MGLSymbolStyleLayer.class;
+ } else if (layer->is<mbgl::style::RasterLayer>()) {
+ return MGLRasterStyleLayer.class;
+ } else if (layer->is<mbgl::style::CircleLayer>()) {
+ return MGLCircleStyleLayer.class;
+ } else if (layer->is<mbgl::style::BackgroundLayer>()) {
+ return MGLBackgroundStyleLayer.class;
+ }
+ [NSException raise:@"Layer type not handled" format:@""];
+ return Nil;
+}
+
+- (void)removeLayer:(id <MGLStyleLayer_Private>)styleLayer
+{
+ self.mapView.mbglMap->removeLayer(styleLayer.layer->getID());
+}
+
+- (void)addLayer:(id <MGLStyleLayer, MGLStyleLayer_Private>)styleLayer
+{
+ self.mapView.mbglMap->addLayer(std::unique_ptr<mbgl::style::Layer>(styleLayer.layer));
+}
+
+- (void)insertLayer:(id <MGLStyleLayer, MGLStyleLayer_Private>)styleLayer
+ belowLayer:(id <MGLStyleLayer, MGLStyleLayer_Private>)belowLayer
+{
+ const mbgl::optional<std::string> belowLayerId{[belowLayer layerIdentifier].UTF8String};
+ self.mapView.mbglMap->addLayer(std::unique_ptr<mbgl::style::Layer>(styleLayer.layer), belowLayerId);
+}
+
+- (void)addSource:(MGLSource *)source
+{
+ self.mapView.mbglMap->addSource(std::move([source mbgl_source]));
+}
+
+- (void)removeSource:(MGLSource *)source
+{
+ self.mapView.mbglMap->removeSource(source.sourceIdentifier.UTF8String);
+}
+
@end
diff --git a/platform/darwin/src/MGLStyleAttribute.hpp b/platform/darwin/src/MGLStyleAttribute.hpp
new file mode 100644
index 0000000000..1f9207f05a
--- /dev/null
+++ b/platform/darwin/src/MGLStyleAttribute.hpp
@@ -0,0 +1,25 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLStyleAttributeValue_Private.hpp"
+
+@interface MGLStyleAttribute : NSObject <MGLStyleAttributeValue>
+
++ (id <MGLStyleAttributeValue>)mbgl_colorPropertyValueWith:(mbgl::style::PropertyValue<mbgl::Color>)property;
+
++ (id <MGLStyleAttributeValue>)mbgl_numberPropertyValueWith:(mbgl::style::PropertyValue<float>)property;
+
++ (id <MGLStyleAttributeValue>)mbgl_boolPropertyValueWith:(mbgl::style::PropertyValue<bool>)property;
+
++ (id <MGLStyleAttributeValue>)mbgl_stringPropertyValueWith:(mbgl::style::PropertyValue<std::string>)property;
+
++ (id <MGLStyleAttributeValue>)mbgl_offsetPropertyValueWith:(mbgl::style::PropertyValue<std::array<float, 2>>)property;
+
++ (id <MGLStyleAttributeValue>)mbgl_paddingPropertyValueWith:(mbgl::style::PropertyValue<std::array<float, 4>>)property;
+
++ (id <MGLStyleAttributeValue>)mbgl_stringArrayPropertyValueWith:(mbgl::style::PropertyValue<std::vector<std::string>>)property;
+
++ (id <MGLStyleAttributeValue>)mbgl_numberArrayPropertyValueWith:(mbgl::style::PropertyValue<std::vector<float>>)property;
+
+@end
diff --git a/platform/darwin/src/MGLStyleAttribute.mm b/platform/darwin/src/MGLStyleAttribute.mm
new file mode 100644
index 0000000000..32c0f4e71e
--- /dev/null
+++ b/platform/darwin/src/MGLStyleAttribute.mm
@@ -0,0 +1,111 @@
+#import "MGLStyleAttribute.hpp"
+
+#import "MGLStyleAttributeValue_Private.hpp"
+#import "MGLStyleAttributeFunction_Private.hpp"
+
+@interface MGLStyleAttribute()
+@end
+
+@implementation MGLStyleAttribute
+
++ (id <MGLStyleAttributeValue>)mbgl_colorPropertyValueWith:(mbgl::style::PropertyValue<mbgl::Color>)property
+{
+ if (property.isConstant()) {
+ return [MGLColor mbgl_colorWithColor:property.asConstant()];
+ } else if (property.isFunction()) {
+ return [MGLStyleAttributeFunction functionWithColorPropertyValue:property.asFunction()];
+ } else {
+ return nil;
+ }
+}
+
++ (id <MGLStyleAttributeValue>)mbgl_numberPropertyValueWith:(mbgl::style::PropertyValue<float>)property
+{
+ if (property.isConstant()) {
+ return @(property.asConstant());
+ } else if (property.isFunction()) {
+ return [MGLStyleAttributeFunction functionWithNumberPropertyValue:property.asFunction()];
+ } else {
+ return nil;
+ }
+}
+
++ (id<MGLStyleAttributeValue>)mbgl_boolPropertyValueWith:(mbgl::style::PropertyValue<bool>)property
+{
+ if (property.isConstant()) {
+ return @(property.asConstant());
+ } else if (property.isFunction()) {
+ return [MGLStyleAttributeFunction functionWithBoolPropertyValue:property.asFunction()];
+ } else {
+ return nil;
+ }
+}
+
++ (id<MGLStyleAttributeValue>)mbgl_stringPropertyValueWith:(mbgl::style::PropertyValue<std::string>)property
+{
+ if (property.isConstant()) {
+ return @(property.asConstant().c_str());
+ } else if (property.isFunction()) {
+ return [MGLStyleAttributeFunction functionWithStringPropertyValue:property.asFunction()];
+ } else {
+ return nil;
+ }
+}
+
++ (id<MGLStyleAttributeValue>)mbgl_offsetPropertyValueWith:(mbgl::style::PropertyValue<std::array<float, 2> >)property
+{
+ if (property.isConstant()) {
+ auto offset = property.asConstant();
+ return @[@(offset[0]), @(offset[1])];
+ } else if (property.isFunction()) {
+ return [MGLStyleAttributeFunction functionWithOffsetPropertyValue:property.asFunction()];
+ } else {
+ return nil;
+ }
+}
+
++ (id<MGLStyleAttributeValue>)mbgl_paddingPropertyValueWith:(mbgl::style::PropertyValue<std::array<float, 4> >)property
+{
+ if (property.isConstant()) {
+ auto padding = property.asConstant();
+ return @[@(padding[0]), @(padding[1]), @(padding[2]), @(padding[3])];
+ } else if (property.isFunction()) {
+ return [MGLStyleAttributeFunction functionWithPaddingPropertyValue:property.asFunction()];
+ } else {
+ return nil;
+ }
+}
+
++ (id<MGLStyleAttributeValue>)mbgl_stringArrayPropertyValueWith:(mbgl::style::PropertyValue<std::vector<std::string> >)property
+{
+ if (property.isConstant()) {
+ auto strings = property.asConstant();
+ NSMutableArray *convertedStrings = [[NSMutableArray alloc] initWithCapacity:strings.size()];
+ for (auto string : strings) {
+ [convertedStrings addObject:@(string.c_str())];
+ }
+ return convertedStrings;
+ } else if (property.isFunction()) {
+ return [MGLStyleAttributeFunction functionWithStringArrayPropertyValue:property.asFunction()];
+ } else {
+ return nil;
+ }
+}
+
++ (id<MGLStyleAttributeValue>)mbgl_numberArrayPropertyValueWith:(mbgl::style::PropertyValue<std::vector<float> >)property
+{
+ if (property.isConstant()) {
+ auto numbers = property.asConstant();
+ NSMutableArray *convertedNumbers = [NSMutableArray arrayWithCapacity:numbers.size()];
+ for (auto number : numbers) {
+ [convertedNumbers addObject:@(number)];
+ }
+ return convertedNumbers;
+ } else if (property.isFunction()) {
+ return [MGLStyleAttributeFunction functionWithNumberArrayPropertyValue:property.asFunction()];
+ } else {
+ return nil;
+ }
+}
+
+@end
diff --git a/platform/darwin/src/MGLStyleAttributeFunction.h b/platform/darwin/src/MGLStyleAttributeFunction.h
new file mode 100644
index 0000000000..dbef311548
--- /dev/null
+++ b/platform/darwin/src/MGLStyleAttributeFunction.h
@@ -0,0 +1,26 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLTypes.h"
+#import "MGLStyleAttributeValue.h"
+
+typedef NS_ENUM(NSUInteger, MGLStyleAttributeFunctionType) {
+ MGLStyleAttributeFunctionTypeExponential,
+ MGLStyleAttributeFunctionTypeInterval,
+ MGLStyleAttributeFunctionTypeCategorical
+};
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface MGLStyleAttributeFunction : NSObject <MGLStyleAttributeValue>
+
+@property (nonatomic, copy) NSDictionary<NSNumber *, id> *stops;
+
+@property (nonatomic, copy, nullable) NSString *property;
+
+@property (nonatomic, copy, nullable) NSNumber *base;
+
+@property (nonatomic, copy, nullable) NSNumber *functionType;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLStyleAttributeFunction.mm b/platform/darwin/src/MGLStyleAttributeFunction.mm
new file mode 100644
index 0000000000..d97f8b720f
--- /dev/null
+++ b/platform/darwin/src/MGLStyleAttributeFunction.mm
@@ -0,0 +1,243 @@
+#import "MGLStyleAttributeFunction.h"
+
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLStyleAttributeValue_Private.hpp"
+#import "MGLStyleAttributeFunction_Private.hpp"
+
+@interface MGLStyleAttributeFunction() <MGLStyleAttributeValue_Private>
+@end
+
+@implementation MGLStyleAttributeFunction
+
+- (instancetype)init
+{
+ if (self = [super init]) {
+ _base = @1;
+ }
+ return self;
+}
+
+- (BOOL)isFunction
+{
+ return YES;
+}
+
+- (mbgl::style::PropertyValue<mbgl::Color>)mbgl_colorPropertyValue
+{
+ __block std::vector<std::pair<float, mbgl::Color>> stops;
+ [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLColor * _Nonnull color, BOOL * _Nonnull stop) {
+ NSAssert([color isKindOfClass:[MGLColor class]], @"Stops should be colors");
+ stops.emplace_back(zoomKey.floatValue, color.mbgl_color);
+ }];
+ return mbgl::style::Function<mbgl::Color>({{stops}}, _base.floatValue);
+}
+
+- (mbgl::style::PropertyValue<float>)mbgl_floatPropertyValue
+{
+ __block std::vector<std::pair<float, float>> stops;
+ [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSNumber * _Nonnull number, BOOL * _Nonnull stop) {
+ NSAssert([number isKindOfClass:[NSNumber class]], @"Stops should be NSNumbers");
+ stops.emplace_back(zoomKey.floatValue, number.floatValue);
+ }];
+ return mbgl::style::Function<float>({{stops}}, _base.floatValue);
+}
+
+- (mbgl::style::PropertyValue<bool>)mbgl_boolPropertyValue
+{
+ __block std::vector<std::pair<float, bool>> stops;
+ [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSNumber * _Nonnull number, BOOL * _Nonnull stop) {
+ NSAssert([number isKindOfClass:[NSNumber class]], @"Stops should be NSNumbers");
+ stops.emplace_back(zoomKey.floatValue, number.boolValue);
+ }];
+ return mbgl::style::Function<bool>({{stops}}, _base.floatValue);
+}
+
+- (mbgl::style::PropertyValue<std::string>)mbgl_stringPropertyValue
+{
+ __block std::vector<std::pair<float, std::string>> stops;
+ [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSString * _Nonnull string, BOOL * _Nonnull stop) {
+ NSAssert([string isKindOfClass:[NSString class]], @"Stops should be strings");
+ stops.emplace_back(zoomKey.floatValue, string.UTF8String);
+ }];
+ return mbgl::style::Function<std::string>({{stops}}, _base.floatValue);
+}
+
+- (mbgl::style::PropertyValue<std::vector<std::string> >)mbgl_stringArrayPropertyValue
+{
+ __block std::vector<std::pair<float, std::vector<std::string>>> stops;
+ [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSArray * _Nonnull strings, BOOL * _Nonnull stop) {
+ NSAssert([strings isKindOfClass:[NSArray class]], @"Stops should be NSArray");
+ std::vector<std::string>convertedStrings;
+ for (NSString *string in strings) {
+ convertedStrings.emplace_back(string.UTF8String);
+ }
+ stops.emplace_back(zoomKey.floatValue, convertedStrings);
+ }];
+ return mbgl::style::Function<std::vector<std::string>>({{stops}}, _base.floatValue);
+}
+
+- (mbgl::style::PropertyValue<std::vector<float> >)mbgl_numberArrayPropertyValue
+{
+ __block std::vector<std::pair<float, std::vector<float>>> stops;
+ [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSArray * _Nonnull numbers, BOOL * _Nonnull stop) {
+ NSAssert([numbers isKindOfClass:[NSArray class]], @"Stops should be NSArray");
+ std::vector<float>convertedNumbers;
+ for (NSNumber *number in numbers) {
+ convertedNumbers.emplace_back(number.floatValue);
+ }
+ stops.emplace_back(zoomKey.floatValue, convertedNumbers);
+ }];
+ return mbgl::style::Function<std::vector<float>>({{stops}}, _base.floatValue);
+}
+
+- (mbgl::style::PropertyValue<std::array<float, 4> >)mbgl_paddingPropertyValue
+{
+ __block std::vector<std::pair<float, std::array<float, 4>>> stops;
+ [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSArray * _Nonnull padding, BOOL * _Nonnull stop) {
+ NSAssert([padding isKindOfClass:[NSArray class]], @"Stops should be NSArray");
+ NSNumber *top = padding[0];
+ NSNumber *left = padding[1];
+ NSNumber *bottom = padding[2];
+ NSNumber *right = padding[2];
+ auto pad = std::array<float, 4>({{top.floatValue, left.floatValue, bottom.floatValue, right.floatValue}});
+ stops.emplace_back(zoomKey.floatValue, pad);
+ }];
+ return mbgl::style::Function<std::array<float, 4>>({{stops}}, _base.floatValue);
+}
+
+- (mbgl::style::PropertyValue<std::array<float, 2> >)mbgl_offsetPropertyValue
+{
+ __block std::vector<std::pair<float, std::array<float, 2>>> stops;
+ [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSArray * _Nonnull offset, BOOL * _Nonnull stop) {
+ NSAssert([offset isKindOfClass:[NSArray class]], @"Stops should be NSArray");
+ NSNumber *dx = offset[0];
+ NSNumber *dy = offset[1];
+ auto off = std::array<float, 2>({{dx.floatValue, dy.floatValue}});
+ stops.emplace_back(zoomKey.floatValue, off);
+ }];
+ return mbgl::style::Function<std::array<float, 2>>({{stops}}, _base.floatValue);
+}
+
++ (instancetype)functionWithColorPropertyValue:(mbgl::style::Function<mbgl::Color>)property
+{
+ MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init];
+ auto stops = property.getStops();
+ NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()];
+ for (auto stop : stops) {
+ convertedStops[@(stop.first)] = [MGLColor mbgl_colorWithColor:stop.second];
+ }
+ function.base = @(property.getBase());
+ function.stops = convertedStops;
+ return function;
+}
+
++ (instancetype)functionWithNumberPropertyValue:(mbgl::style::Function<float>)property
+{
+ MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init];
+ auto stops = property.getStops();
+ NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()];
+ for (auto stop : stops) {
+ convertedStops[@(stop.first)] = @(stop.second);
+ }
+ function.base = @(property.getBase());
+ function.stops = convertedStops;
+ return function;
+}
+
++ (instancetype)functionWithBoolPropertyValue:(mbgl::style::Function<bool>)property
+{
+ MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init];
+ auto stops = property.getStops();
+ NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()];
+ for (auto stop : stops) {
+ convertedStops[@(stop.first)] = @(stop.second);
+ }
+ function.base = @(property.getBase());
+ function.stops = convertedStops;
+ return function;
+}
+
++ (instancetype)functionWithStringPropertyValue:(mbgl::style::Function<std::string>)property
+{
+ MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init];
+ auto stops = property.getStops();
+ NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()];
+ for (auto stop : stops) {
+ convertedStops[@(stop.first)] = @(stop.second.c_str());
+ }
+ function.base = @(property.getBase());
+ function.stops = convertedStops;
+ return function;
+}
+
++ (instancetype)functionWithOffsetPropertyValue:(mbgl::style::Function<std::array<float, 2> >)property
+{
+ MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init];
+ auto stops = property.getStops();
+ NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()];
+ for (auto stop : stops) {
+ convertedStops[@(stop.first)] = @[@(stop.second[0]), @(stop.second[1])];
+ }
+ function.base = @(property.getBase());
+ function.stops = convertedStops;
+ return function;
+}
+
++ (instancetype)functionWithPaddingPropertyValue:(mbgl::style::Function<std::array<float, 4> >)property
+{
+ MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init];
+ auto stops = property.getStops();
+ NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()];
+ for (auto stop : stops) {
+ convertedStops[@(stop.first)] = @[@(stop.second[0]), @(stop.second[1]), @(stop.second[2]), @(stop.second[3])];
+ }
+ function.base = @(property.getBase());
+ function.stops = convertedStops;
+ return function;
+}
+
++ (instancetype)functionWithStringArrayPropertyValue:(mbgl::style::Function<std::vector<std::string> >)property
+{
+ MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init];
+ auto stops = property.getStops();
+ NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()];
+ for (auto stop : stops) {
+ auto strings = stop.second;
+ NSMutableArray *convertedStrings = [NSMutableArray arrayWithCapacity:strings.size()];
+ for (auto const& string: strings) {
+ [convertedStrings addObject:@(string.c_str())];
+ }
+ convertedStops[@(stop.first)] = convertedStrings;
+ }
+ function.base = @(property.getBase());
+ function.stops = convertedStops;
+ return function;
+}
+
++ (instancetype)functionWithNumberArrayPropertyValue:(mbgl::style::Function<std::vector<float> >)property
+{
+ MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init];
+ auto stops = property.getStops();
+ NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()];
+ for (auto stop : stops) {
+ auto numbers = stop.second;
+ NSMutableArray *convertedNumbers = [NSMutableArray arrayWithCapacity:numbers.size()];
+ for (auto const& number: numbers) {
+ [convertedNumbers addObject:@(number)];
+ }
+ convertedStops[@(stop.first)] = convertedNumbers;
+ }
+ function.base = @(property.getBase());
+ function.stops = convertedStops;
+ return function;
+}
+
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"<%@: %p, base = %@; stops = %@>",
+ NSStringFromClass([self class]), (void *)self,
+ self.base,
+ self.stops];
+}
+
+@end
diff --git a/platform/darwin/src/MGLStyleAttributeFunction_Private.hpp b/platform/darwin/src/MGLStyleAttributeFunction_Private.hpp
new file mode 100644
index 0000000000..a75e17483d
--- /dev/null
+++ b/platform/darwin/src/MGLStyleAttributeFunction_Private.hpp
@@ -0,0 +1,61 @@
+#import "MGLStyleAttributeFunction.h"
+
+#include <mbgl/util/color.hpp>
+#include <mbgl/style/function.hpp>
+#include <mbgl/style/property_value.hpp>
+
+#define MGLSetEnumProperty(name, Name, MBGLType, ObjCType) \
+ if (name.isFunction) { \
+ NSAssert([name isKindOfClass:[MGLStyleAttributeFunction class]], @"" #name @" should be a function"); \
+ \
+ __block std::vector<std::pair<float, mbgl::style::MBGLType>> stops; \
+ [[(MGLStyleAttributeFunction *)name stops] enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull key, NSValue * _Nonnull obj, BOOL * _Nonnull stop) { \
+ NSAssert([obj isKindOfClass:[NSValue class]], @"Stops in " #name @" should be NSValues"); \
+ ObjCType value; \
+ [obj getValue:&value]; \
+ stops.emplace_back(key.floatValue, static_cast<mbgl::style::MBGLType>(value)); \
+ }]; \
+ auto function = mbgl::style::Function<mbgl::style::MBGLType> { \
+ stops, \
+ [(MGLStyleAttributeFunction *)name base].floatValue, \
+ }; \
+ self.layer->set##Name(function); \
+ } else { \
+ NSAssert([name isKindOfClass:[NSValue class]], @"" #name @"should be an NSValue"); \
+ ObjCType value; \
+ [(NSValue *)name getValue:&value]; \
+ self.layer->set##Name({ static_cast<mbgl::style::MBGLType>(value) }); \
+ }
+
+#define MGLGetEnumProperty(Name, MBGLType, ObjCType) \
+ const char *type = @encode(ObjCType); \
+ mbgl::style::PropertyValue<mbgl::style::MBGLType> property = self.layer->get##Name(); \
+ if (property.isConstant()) { \
+ return [NSValue value:&property.asConstant() withObjCType:type]; \
+ } else if (property.isFunction()) { \
+ return nil; \
+ } else { \
+ return nil; \
+ }
+
+@interface MGLStyleAttributeFunction(Private)
+
++ (instancetype)functionWithColorPropertyValue:(mbgl::style::Function<mbgl::Color>)property;
+
++ (instancetype)functionWithNumberPropertyValue:(mbgl::style::Function<float>)property;
+
++ (instancetype)functionWithBoolPropertyValue:(mbgl::style::Function<bool>)property;
+
++ (instancetype)functionWithStringPropertyValue:(mbgl::style::Function<std::string>)property;
+
++ (instancetype)functionWithOffsetPropertyValue:(mbgl::style::Function<std::array<float, 2>>)property;
+
++ (instancetype)functionWithPaddingPropertyValue:(mbgl::style::Function<std::array<float, 4>>)property;
+
++ (instancetype)functionWithStringArrayPropertyValue:(mbgl::style::Function<std::vector<std::string>>)property;
+
++ (instancetype)functionWithNumberArrayPropertyValue:(mbgl::style::Function<std::vector<float>>)property;
+
++ (instancetype)functionWithEnumProperyValue:(mbgl::style::Function<bool>)property type:(const char *)type;
+
+@end;
diff --git a/platform/darwin/src/MGLStyleAttributeValue.h b/platform/darwin/src/MGLStyleAttributeValue.h
new file mode 100644
index 0000000000..31edccb14f
--- /dev/null
+++ b/platform/darwin/src/MGLStyleAttributeValue.h
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLTypes.h"
+
+@protocol MGLStyleAttributeValue <NSObject>
+@optional
+@end \ No newline at end of file
diff --git a/platform/darwin/src/MGLStyleAttributeValue_Private.hpp b/platform/darwin/src/MGLStyleAttributeValue_Private.hpp
new file mode 100644
index 0000000000..a3c8a1a149
--- /dev/null
+++ b/platform/darwin/src/MGLStyleAttributeValue_Private.hpp
@@ -0,0 +1,25 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLTypes.h"
+#import "MGLStyleAttributeFunction_Private.hpp"
+#include <array>
+
+@protocol MGLStyleAttributeValue_Private <NSObject>
+- (BOOL)isFunction;
+@optional
+
+// Convert darwin types to mbgl types
+- (mbgl::style::PropertyValue<mbgl::Color>)mbgl_colorPropertyValue;
+- (mbgl::style::PropertyValue<float>)mbgl_floatPropertyValue;
+- (mbgl::style::PropertyValue<bool>)mbgl_boolPropertyValue;
+- (mbgl::style::PropertyValue<std::string>)mbgl_stringPropertyValue;
+- (mbgl::style::PropertyValue<std::array<float, 2>>)mbgl_offsetPropertyValue;
+- (mbgl::style::PropertyValue<std::array<float, 4>>)mbgl_paddingPropertyValue;
+- (mbgl::style::PropertyValue<std::vector<std::string> >)mbgl_stringArrayPropertyValue;
+- (mbgl::style::PropertyValue<std::vector<float> >)mbgl_numberArrayPropertyValue;
+- (mbgl::style::PropertyValue<uint8_t>)mbgl_enumPropertyValue;
+
+// Convert mbgl types to darwin types
+- (id <MGLStyleAttributeValue>)mbgl_colorPropertyValueWith:(mbgl::style::PropertyValue<mbgl::Color>)color;
+
+@end
diff --git a/platform/darwin/src/MGLStyleFilter.h b/platform/darwin/src/MGLStyleFilter.h
new file mode 100644
index 0000000000..29167f2248
--- /dev/null
+++ b/platform/darwin/src/MGLStyleFilter.h
@@ -0,0 +1,5 @@
+#import <Foundation/Foundation.h>
+
+@interface MGLStyleFilter : NSObject
+
+@end
diff --git a/platform/darwin/src/MGLStyleFilter.m b/platform/darwin/src/MGLStyleFilter.m
new file mode 100644
index 0000000000..8649a89d81
--- /dev/null
+++ b/platform/darwin/src/MGLStyleFilter.m
@@ -0,0 +1,5 @@
+#import "MGLStyleFilter.h"
+
+@implementation MGLStyleFilter
+
+@end
diff --git a/platform/darwin/src/MGLStyleLayer.h b/platform/darwin/src/MGLStyleLayer.h
new file mode 100644
index 0000000000..30456331db
--- /dev/null
+++ b/platform/darwin/src/MGLStyleLayer.h
@@ -0,0 +1,17 @@
+#import <Foundation/Foundation.h>
+
+@class MGLMapView;
+
+@protocol MGLStyleLayer <NSObject>
+
+@property (nonatomic, weak) MGLMapView *mapView;
+@property (nonatomic, copy, readonly) NSString *layerIdentifier;
+
+@optional
+
+@property (nonatomic, readonly) NSString *sourceIdentifier;
+
+- (instancetype)initWithLayerIdentifier:(NSString *)layerIdentifier;
+- (instancetype)initWithLayerIdentifier:(NSString *)layerIdentifier sourceIdentifier:(NSString *)sourceIdentifier;
+
+@end
diff --git a/platform/darwin/src/MGLStyleLayer.h.ejs b/platform/darwin/src/MGLStyleLayer.h.ejs
new file mode 100644
index 0000000000..629edba6c6
--- /dev/null
+++ b/platform/darwin/src/MGLStyleLayer.h.ejs
@@ -0,0 +1,55 @@
+<%
+ const type = locals.type;
+ const layoutProperties = locals.layoutProperties;
+ const paintProperties = locals.paintProperties;
+-%>
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLTypes.h"
+#import "MGLStyleAttributeValue.h"
+#import "MGLBaseStyleLayer.h"
+
+<% for (const property of layoutProperties) { -%>
+<% if (property.type == "enum") { -%>
+typedef NS_ENUM(NSUInteger, MGL<%- camelize(type) %>StyleLayer<%- camelize(property.name) %>) {
+<% for (const value of property.values) { -%>
+ MGL<%- camelize(type) %>StyleLayer<%- camelize(property.name) %><%- camelize(value) %>,
+<% } -%>
+};
+
+<% } -%>
+<% } -%>
+<% for (const property of paintProperties) { -%>
+<% if (property.type == "enum") { -%>
+typedef NS_ENUM(NSUInteger, MGL<%- camelize(type) %>StyleLayer<%- camelize(property.name) %>) {
+<% for (const value of property.values) { -%>
+ MGL<%- camelize(type) %>StyleLayer<%- camelize(property.name) %><%- camelize(value) %>,
+<% } -%>
+};
+
+<% } -%>
+<% } -%>
+@interface MGL<%- camelize(type) %>StyleLayer : MGLBaseStyleLayer <MGLStyleLayer>
+
+<% if (layoutProperties.length) { -%>
+#pragma mark - Accessing the Layout Attributes
+
+<% for (const property of layoutProperties) { -%>
+/**
+ <%- property.doc %>
+ */
+@property (nonatomic) <%- propertyType(property, false, type) %> <%- camelizeWithLeadingLowercase(property.name) %>;
+
+<% } -%>
+<% } -%>
+#pragma mark - Accessing the Paint Attributes
+
+<% for (const property of paintProperties) { -%>
+/**
+ <%- property.doc %>
+ */
+@property (nonatomic) <%- propertyType(property, false, type) %> <%- camelizeWithLeadingLowercase(property.name) %>;
+
+<% } -%>
+@end
diff --git a/platform/darwin/src/MGLStyleLayer.mm b/platform/darwin/src/MGLStyleLayer.mm
new file mode 100644
index 0000000000..cacc11380a
--- /dev/null
+++ b/platform/darwin/src/MGLStyleLayer.mm
@@ -0,0 +1,5 @@
+#import "MGLStyleLayer.h"
+
+#import "MGLTypes.h"
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLMapView_Private.hpp"
diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs
new file mode 100644
index 0000000000..c360898098
--- /dev/null
+++ b/platform/darwin/src/MGLStyleLayer.mm.ejs
@@ -0,0 +1,64 @@
+<%
+ const type = locals.type;
+ const layoutProperties = locals.layoutProperties;
+ const paintProperties = locals.paintProperties;
+-%>
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLStyleAttributeValue.h"
+#import "MGL<%- camelize(type) %>StyleLayer.h"
+
+#include <mbgl/style/layers/<%- type %>_layer.hpp>
+
+@interface MGL<%- camelize(type) %>StyleLayer ()
+
+@property (nonatomic) mbgl::style::<%- camelize(type) %>Layer *layer;
+@property (nonatomic, readwrite) NSString *layerIdentifier;
+@property (nonatomic, readwrite) NSString *sourceIdentifier;
+
+@end
+
+@implementation MGL<%- camelize(type) %>StyleLayer
+
+@synthesize mapView;
+
+- (instancetype)initWithLayerIdentifier:(NSString *)layerIdentifier sourceIdentifier:(NSString *)sourceIdentifier {
+ if (self = [super init]) {
+ _layerIdentifier = layerIdentifier;
+ _sourceIdentifier = sourceIdentifier;
+ <%- initLayer(type) %>
+ }
+ return self;
+}
+
+<% if (layoutProperties.length) { -%>
+#pragma mark - Accessing the Layout Attributes
+
+<% for (const property of layoutProperties) { -%>
+- (void)set<%- camelize(property.name) %>:(<%- propertyType(property, true, type) %>)<%- objCName(property) %> {
+ <%- setterImplementation(property, type) %>
+}
+
+- (<%- propertyType(property, false, type) %>)<%- objCName(property) %> {
+ <%- getterImplementation(property, type) %>
+}
+
+<% } -%>
+<% } -%>
+<% if (paintProperties.length) { -%>
+#pragma mark - Accessing the Paint Attributes
+
+<% for (const property of paintProperties) { -%>
+- (void)set<%- camelize(property.name) %>:(<%- propertyType(property, true, type) %>)<%- objCName(property) %> {
+ <%- setterImplementation(property, type) %>
+}
+
+- (<%- propertyType(property, false, type) %>)<%- objCName(property) %> {
+ <%- getterImplementation(property, type) %>
+}
+
+<% } -%>
+<% } -%>
+@end
diff --git a/platform/darwin/src/MGLStyleLayer_Private.hpp b/platform/darwin/src/MGLStyleLayer_Private.hpp
new file mode 100644
index 0000000000..b62093d321
--- /dev/null
+++ b/platform/darwin/src/MGLStyleLayer_Private.hpp
@@ -0,0 +1,30 @@
+#import <Foundation/Foundation.h>
+#include <mbgl/style/layer.hpp>
+
+#import "MGLStyleLayer.h"
+#import "MGLStyleAttribute.hpp"
+
+#import "NSNumber+MGLStyleAttributeAdditions_Private.hpp"
+#import "NSArray+MGLStyleAttributeAdditions_Private.hpp"
+#import "NSString+MGLStyleAttributeAdditions_Private.hpp"
+#import "NSValue+MGLStyleAttributeAdditions_Private.hpp"
+#import "MGLStyleAttributeFunction_Private.hpp"
+#import "MGLStyleAttributeValue_Private.hpp"
+
+#if TARGET_OS_IPHONE
+#import "UIColor+MGLAdditions.hpp"
+#import "UIColor+MGLStyleAttributeAdditions_Private.hpp"
+#else
+#import "NSColor+MGLAdditions.hpp"
+#import "NSColor+MGLStyleAttributeAdditions_Private.hpp"
+#endif
+
+@class MGLMapView;
+
+@protocol MGLStyleLayer_Private <MGLStyleLayer>
+
+@property (nonatomic, weak) MGLMapView *mapView;
+@property (nonatomic, readwrite, copy) NSString *layerIdentifier;
+@property (nonatomic) mbgl::style::Layer *layer;
+
+@end
diff --git a/platform/darwin/src/MGLStyle_Private.hpp b/platform/darwin/src/MGLStyle_Private.hpp
new file mode 100644
index 0000000000..ed0122bf73
--- /dev/null
+++ b/platform/darwin/src/MGLStyle_Private.hpp
@@ -0,0 +1,10 @@
+#import "MGLStyle.h"
+
+#import "MGLStyleLayer.h"
+#import "MGLFillStyleLayer.h"
+#import <mbgl/util/default_styles.hpp>
+#include <mbgl/mbgl.hpp>
+
+@interface MGLStyle (Private)
+@property (nonatomic, weak) MGLMapView *mapView;
+@end
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h
new file mode 100644
index 0000000000..1f3568890b
--- /dev/null
+++ b/platform/darwin/src/MGLSymbolStyleLayer.h
@@ -0,0 +1,315 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLTypes.h"
+#import "MGLStyleAttributeValue.h"
+#import "MGLBaseStyleLayer.h"
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerSymbolPlacement) {
+ MGLSymbolStyleLayerSymbolPlacementPoint,
+ MGLSymbolStyleLayerSymbolPlacementLine,
+};
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerIconRotationAlignment) {
+ MGLSymbolStyleLayerIconRotationAlignmentMap,
+ MGLSymbolStyleLayerIconRotationAlignmentViewport,
+};
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerIconTextFit) {
+ MGLSymbolStyleLayerIconTextFitNone,
+ MGLSymbolStyleLayerIconTextFitBoth,
+ MGLSymbolStyleLayerIconTextFitWidth,
+ MGLSymbolStyleLayerIconTextFitHeight,
+};
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextPitchAlignment) {
+ MGLSymbolStyleLayerTextPitchAlignmentMap,
+ MGLSymbolStyleLayerTextPitchAlignmentViewport,
+};
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextRotationAlignment) {
+ MGLSymbolStyleLayerTextRotationAlignmentMap,
+ MGLSymbolStyleLayerTextRotationAlignmentViewport,
+};
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextJustify) {
+ MGLSymbolStyleLayerTextJustifyLeft,
+ MGLSymbolStyleLayerTextJustifyCenter,
+ MGLSymbolStyleLayerTextJustifyRight,
+};
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextAnchor) {
+ MGLSymbolStyleLayerTextAnchorCenter,
+ MGLSymbolStyleLayerTextAnchorLeft,
+ MGLSymbolStyleLayerTextAnchorRight,
+ MGLSymbolStyleLayerTextAnchorTop,
+ MGLSymbolStyleLayerTextAnchorBottom,
+ MGLSymbolStyleLayerTextAnchorTopLeft,
+ MGLSymbolStyleLayerTextAnchorTopRight,
+ MGLSymbolStyleLayerTextAnchorBottomLeft,
+ MGLSymbolStyleLayerTextAnchorBottomRight,
+};
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextTransform) {
+ MGLSymbolStyleLayerTextTransformNone,
+ MGLSymbolStyleLayerTextTransformUppercase,
+ MGLSymbolStyleLayerTextTransformLowercase,
+};
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerIconTranslateAnchor) {
+ MGLSymbolStyleLayerIconTranslateAnchorMap,
+ MGLSymbolStyleLayerIconTranslateAnchorViewport,
+};
+
+typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextTranslateAnchor) {
+ MGLSymbolStyleLayerTextTranslateAnchorMap,
+ MGLSymbolStyleLayerTextTranslateAnchorViewport,
+};
+
+@interface MGLSymbolStyleLayer : MGLBaseStyleLayer <MGLStyleLayer>
+
+#pragma mark - Accessing the Layout Attributes
+
+/**
+ Label placement relative to its geometry. `line` can only be used on LineStrings and Polygons.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> symbolPlacement;
+
+/**
+ Distance between two symbol anchors.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> symbolSpacing;
+
+/**
+ If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> symbolAvoidEdges;
+
+/**
+ If true, the icon will be visible even if it collides with other previously drawn symbols.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconAllowOverlap;
+
+/**
+ If true, other symbols can be visible even if they collide with the icon.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconIgnorePlacement;
+
+/**
+ If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconOptional;
+
+/**
+ Orientation of icon when map is rotated.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconRotationAlignment;
+
+/**
+ Scale factor for icon. 1 is original size, 3 triples the size.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconSize;
+
+/**
+ Position and scale an icon by the its corresponding text.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconTextFit;
+
+/**
+ Size of padding area around the text-fit size in clockwise order: top, right, bottom, left.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconTextFitPadding;
+
+/**
+ A string with {tokens} replaced, referencing the data property to pull from.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconImage;
+
+/**
+ Rotates the icon clockwise.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconRotate;
+
+/**
+ Size of the additional area around the icon bounding box used for detecting symbol collisions.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconPadding;
+
+/**
+ If true, the icon may be flipped to prevent it from being rendered upside-down.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconKeepUpright;
+
+/**
+ Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconOffset;
+
+/**
+ Aligns text to the plane of the `viewport` or the `map` when the map is pitched. Matches `text-rotation-alignment` if unspecified.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textPitchAlignment;
+
+/**
+ Orientation of text when map is rotated.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textRotationAlignment;
+
+/**
+ Value to use for a text label. Feature properties are specified using tokens like {field_name}.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textField;
+
+/**
+ Font stack to use for displaying text.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textFont;
+
+/**
+ Font size.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textSize;
+
+/**
+ The maximum line width for text wrapping.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textMaxWidth;
+
+/**
+ Text leading value for multi-line text.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textLineHeight;
+
+/**
+ Text tracking amount.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textLetterSpacing;
+
+/**
+ Text justification options.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textJustify;
+
+/**
+ Part of the text placed closest to the anchor.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textAnchor;
+
+/**
+ Maximum angle change between adjacent characters.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textMaxAngle;
+
+/**
+ Rotates the text clockwise.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textRotate;
+
+/**
+ Size of the additional area around the text bounding box used for detecting symbol collisions.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textPadding;
+
+/**
+ If true, the text may be flipped vertically to prevent it from being rendered upside-down.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textKeepUpright;
+
+/**
+ Specifies how to capitalize text, similar to the CSS `text-transform` property.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textTransform;
+
+/**
+ Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textOffset;
+
+/**
+ If true, the text will be visible even if it collides with other previously drawn symbols.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textAllowOverlap;
+
+/**
+ If true, other symbols can be visible even if they collide with the text.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textIgnorePlacement;
+
+/**
+ If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textOptional;
+
+#pragma mark - Accessing the Paint Attributes
+
+/**
+ The opacity at which the icon will be drawn.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconOpacity;
+
+/**
+ The color of the icon. This can only be used with sdf icons.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconColor;
+
+/**
+ The color of the icon's halo. Icon halos can only be used with sdf icons.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconHaloColor;
+
+/**
+ Distance of halo to the icon outline.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconHaloWidth;
+
+/**
+ Fade out the halo towards the outside.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconHaloBlur;
+
+/**
+ Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconTranslate;
+
+/**
+ Control whether the translation is relative to the map (north) or viewport (screen).
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> iconTranslateAnchor;
+
+/**
+ The opacity at which the text will be drawn.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textOpacity;
+
+/**
+ The color with which the text will be drawn.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textColor;
+
+/**
+ The color of the text's halo, which helps it stand out from backgrounds.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textHaloColor;
+
+/**
+ Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textHaloWidth;
+
+/**
+ The halo's fadeout distance towards the outside.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textHaloBlur;
+
+/**
+ Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textTranslate;
+
+/**
+ Control whether the translation is relative to the map (north) or viewport (screen).
+ */
+@property (nonatomic) id <MGLStyleAttributeValue> textTranslateAnchor;
+
+@end
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm
new file mode 100644
index 0000000000..335d0bfc6c
--- /dev/null
+++ b/platform/darwin/src/MGLSymbolStyleLayer.mm
@@ -0,0 +1,419 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayer_Private.hpp"
+#import "MGLStyleAttributeValue.h"
+#import "MGLSymbolStyleLayer.h"
+
+#include <mbgl/style/layers/symbol_layer.hpp>
+
+@interface MGLSymbolStyleLayer ()
+
+@property (nonatomic) mbgl::style::SymbolLayer *layer;
+@property (nonatomic, readwrite) NSString *layerIdentifier;
+@property (nonatomic, readwrite) NSString *sourceIdentifier;
+
+@end
+
+@implementation MGLSymbolStyleLayer
+
+@synthesize mapView;
+
+- (instancetype)initWithLayerIdentifier:(NSString *)layerIdentifier sourceIdentifier:(NSString *)sourceIdentifier {
+ if (self = [super init]) {
+ _layerIdentifier = layerIdentifier;
+ _sourceIdentifier = sourceIdentifier;
+ _layer = new mbgl::style::SymbolLayer(layerIdentifier.UTF8String, sourceIdentifier.UTF8String);
+ }
+ return self;
+}
+
+#pragma mark - Accessing the Layout Attributes
+
+- (void)setSymbolPlacement:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)symbolPlacement {
+ MGLSetEnumProperty(symbolPlacement, SymbolPlacement, SymbolPlacementType, MGLSymbolStyleLayerSymbolPlacement);
+}
+
+- (id <MGLStyleAttributeValue>)symbolPlacement {
+ MGLGetEnumProperty(SymbolPlacement, SymbolPlacementType, MGLSymbolStyleLayerSymbolPlacement);
+}
+
+- (void)setSymbolSpacing:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)symbolSpacing {
+ self.layer->setSymbolSpacing(symbolSpacing.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)symbolSpacing {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getSymbolSpacing()];
+}
+
+- (void)setSymbolAvoidEdges:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)symbolAvoidEdges {
+ self.layer->setSymbolAvoidEdges(symbolAvoidEdges.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)symbolAvoidEdges {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getSymbolAvoidEdges()];
+}
+
+- (void)setIconAllowOverlap:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconAllowOverlap {
+ self.layer->setIconAllowOverlap(iconAllowOverlap.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconAllowOverlap {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getIconAllowOverlap()];
+}
+
+- (void)setIconIgnorePlacement:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconIgnorePlacement {
+ self.layer->setIconIgnorePlacement(iconIgnorePlacement.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconIgnorePlacement {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getIconIgnorePlacement()];
+}
+
+- (void)setIconOptional:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconOptional {
+ self.layer->setIconOptional(iconOptional.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconOptional {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getIconOptional()];
+}
+
+- (void)setIconRotationAlignment:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconRotationAlignment {
+ MGLSetEnumProperty(iconRotationAlignment, IconRotationAlignment, AlignmentType, MGLSymbolStyleLayerIconRotationAlignment);
+}
+
+- (id <MGLStyleAttributeValue>)iconRotationAlignment {
+ MGLGetEnumProperty(IconRotationAlignment, AlignmentType, MGLSymbolStyleLayerIconRotationAlignment);
+}
+
+- (void)setIconSize:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconSize {
+ self.layer->setIconSize(iconSize.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconSize {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getIconSize()];
+}
+
+- (void)setIconTextFit:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconTextFit {
+ MGLSetEnumProperty(iconTextFit, IconTextFit, IconTextFitType, MGLSymbolStyleLayerIconTextFit);
+}
+
+- (id <MGLStyleAttributeValue>)iconTextFit {
+ MGLGetEnumProperty(IconTextFit, IconTextFitType, MGLSymbolStyleLayerIconTextFit);
+}
+
+- (void)setIconTextFitPadding:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconTextFitPadding {
+ self.layer->setIconTextFitPadding(iconTextFitPadding.mbgl_paddingPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconTextFitPadding {
+ return [MGLStyleAttribute mbgl_paddingPropertyValueWith:self.layer->getIconTextFitPadding()];
+}
+
+- (void)setIconImage:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconImage {
+ self.layer->setIconImage(iconImage.mbgl_stringPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconImage {
+ return [MGLStyleAttribute mbgl_stringPropertyValueWith:self.layer->getIconImage()];
+}
+
+- (void)setIconRotate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconRotate {
+ self.layer->setIconRotate(iconRotate.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconRotate {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getIconRotate()];
+}
+
+- (void)setIconPadding:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconPadding {
+ self.layer->setIconPadding(iconPadding.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconPadding {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getIconPadding()];
+}
+
+- (void)setIconKeepUpright:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconKeepUpright {
+ self.layer->setIconKeepUpright(iconKeepUpright.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconKeepUpright {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getIconKeepUpright()];
+}
+
+- (void)setIconOffset:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconOffset {
+ self.layer->setIconOffset(iconOffset.mbgl_offsetPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconOffset {
+ return [MGLStyleAttribute mbgl_offsetPropertyValueWith:self.layer->getIconOffset()];
+}
+
+- (void)setTextPitchAlignment:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textPitchAlignment {
+ MGLSetEnumProperty(textPitchAlignment, TextPitchAlignment, AlignmentType, MGLSymbolStyleLayerTextPitchAlignment);
+}
+
+- (id <MGLStyleAttributeValue>)textPitchAlignment {
+ MGLGetEnumProperty(TextPitchAlignment, AlignmentType, MGLSymbolStyleLayerTextPitchAlignment);
+}
+
+- (void)setTextRotationAlignment:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textRotationAlignment {
+ MGLSetEnumProperty(textRotationAlignment, TextRotationAlignment, AlignmentType, MGLSymbolStyleLayerTextRotationAlignment);
+}
+
+- (id <MGLStyleAttributeValue>)textRotationAlignment {
+ MGLGetEnumProperty(TextRotationAlignment, AlignmentType, MGLSymbolStyleLayerTextRotationAlignment);
+}
+
+- (void)setTextField:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textField {
+ self.layer->setTextField(textField.mbgl_stringPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textField {
+ return [MGLStyleAttribute mbgl_stringPropertyValueWith:self.layer->getTextField()];
+}
+
+- (void)setTextFont:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textFont {
+ self.layer->setTextFont(textFont.mbgl_stringArrayPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textFont {
+ return [MGLStyleAttribute mbgl_stringArrayPropertyValueWith:self.layer->getTextFont()];
+}
+
+- (void)setTextSize:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textSize {
+ self.layer->setTextSize(textSize.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textSize {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextSize()];
+}
+
+- (void)setTextMaxWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textMaxWidth {
+ self.layer->setTextMaxWidth(textMaxWidth.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textMaxWidth {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextMaxWidth()];
+}
+
+- (void)setTextLineHeight:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textLineHeight {
+ self.layer->setTextLineHeight(textLineHeight.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textLineHeight {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextLineHeight()];
+}
+
+- (void)setTextLetterSpacing:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textLetterSpacing {
+ self.layer->setTextLetterSpacing(textLetterSpacing.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textLetterSpacing {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextLetterSpacing()];
+}
+
+- (void)setTextJustify:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textJustify {
+ MGLSetEnumProperty(textJustify, TextJustify, TextJustifyType, MGLSymbolStyleLayerTextJustify);
+}
+
+- (id <MGLStyleAttributeValue>)textJustify {
+ MGLGetEnumProperty(TextJustify, TextJustifyType, MGLSymbolStyleLayerTextJustify);
+}
+
+- (void)setTextAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textAnchor {
+ MGLSetEnumProperty(textAnchor, TextAnchor, TextAnchorType, MGLSymbolStyleLayerTextAnchor);
+}
+
+- (id <MGLStyleAttributeValue>)textAnchor {
+ MGLGetEnumProperty(TextAnchor, TextAnchorType, MGLSymbolStyleLayerTextAnchor);
+}
+
+- (void)setTextMaxAngle:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textMaxAngle {
+ self.layer->setTextMaxAngle(textMaxAngle.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textMaxAngle {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextMaxAngle()];
+}
+
+- (void)setTextRotate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textRotate {
+ self.layer->setTextRotate(textRotate.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textRotate {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextRotate()];
+}
+
+- (void)setTextPadding:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textPadding {
+ self.layer->setTextPadding(textPadding.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textPadding {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextPadding()];
+}
+
+- (void)setTextKeepUpright:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textKeepUpright {
+ self.layer->setTextKeepUpright(textKeepUpright.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textKeepUpright {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getTextKeepUpright()];
+}
+
+- (void)setTextTransform:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textTransform {
+ MGLSetEnumProperty(textTransform, TextTransform, TextTransformType, MGLSymbolStyleLayerTextTransform);
+}
+
+- (id <MGLStyleAttributeValue>)textTransform {
+ MGLGetEnumProperty(TextTransform, TextTransformType, MGLSymbolStyleLayerTextTransform);
+}
+
+- (void)setTextOffset:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textOffset {
+ self.layer->setTextOffset(textOffset.mbgl_offsetPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textOffset {
+ return [MGLStyleAttribute mbgl_offsetPropertyValueWith:self.layer->getTextOffset()];
+}
+
+- (void)setTextAllowOverlap:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textAllowOverlap {
+ self.layer->setTextAllowOverlap(textAllowOverlap.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textAllowOverlap {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getTextAllowOverlap()];
+}
+
+- (void)setTextIgnorePlacement:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textIgnorePlacement {
+ self.layer->setTextIgnorePlacement(textIgnorePlacement.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textIgnorePlacement {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getTextIgnorePlacement()];
+}
+
+- (void)setTextOptional:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textOptional {
+ self.layer->setTextOptional(textOptional.mbgl_boolPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textOptional {
+ return [MGLStyleAttribute mbgl_boolPropertyValueWith:self.layer->getTextOptional()];
+}
+
+#pragma mark - Accessing the Paint Attributes
+
+- (void)setIconOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconOpacity {
+ self.layer->setIconOpacity(iconOpacity.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconOpacity {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getIconOpacity()];
+}
+
+- (void)setIconColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconColor {
+ self.layer->setIconColor(iconColor.mbgl_colorPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconColor {
+ return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->getIconColor()];
+}
+
+- (void)setIconHaloColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconHaloColor {
+ self.layer->setIconHaloColor(iconHaloColor.mbgl_colorPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconHaloColor {
+ return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->getIconHaloColor()];
+}
+
+- (void)setIconHaloWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconHaloWidth {
+ self.layer->setIconHaloWidth(iconHaloWidth.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconHaloWidth {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getIconHaloWidth()];
+}
+
+- (void)setIconHaloBlur:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconHaloBlur {
+ self.layer->setIconHaloBlur(iconHaloBlur.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconHaloBlur {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getIconHaloBlur()];
+}
+
+- (void)setIconTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconTranslate {
+ self.layer->setIconTranslate(iconTranslate.mbgl_offsetPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)iconTranslate {
+ return [MGLStyleAttribute mbgl_offsetPropertyValueWith:self.layer->getIconTranslate()];
+}
+
+- (void)setIconTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)iconTranslateAnchor {
+ MGLSetEnumProperty(iconTranslateAnchor, IconTranslateAnchor, TranslateAnchorType, MGLSymbolStyleLayerIconTranslateAnchor);
+}
+
+- (id <MGLStyleAttributeValue>)iconTranslateAnchor {
+ MGLGetEnumProperty(IconTranslateAnchor, TranslateAnchorType, MGLSymbolStyleLayerIconTranslateAnchor);
+}
+
+- (void)setTextOpacity:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textOpacity {
+ self.layer->setTextOpacity(textOpacity.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textOpacity {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextOpacity()];
+}
+
+- (void)setTextColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textColor {
+ self.layer->setTextColor(textColor.mbgl_colorPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textColor {
+ return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->getTextColor()];
+}
+
+- (void)setTextHaloColor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textHaloColor {
+ self.layer->setTextHaloColor(textHaloColor.mbgl_colorPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textHaloColor {
+ return [MGLStyleAttribute mbgl_colorPropertyValueWith:self.layer->getTextHaloColor()];
+}
+
+- (void)setTextHaloWidth:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textHaloWidth {
+ self.layer->setTextHaloWidth(textHaloWidth.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textHaloWidth {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextHaloWidth()];
+}
+
+- (void)setTextHaloBlur:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textHaloBlur {
+ self.layer->setTextHaloBlur(textHaloBlur.mbgl_floatPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textHaloBlur {
+ return [MGLStyleAttribute mbgl_numberPropertyValueWith:self.layer->getTextHaloBlur()];
+}
+
+- (void)setTextTranslate:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textTranslate {
+ self.layer->setTextTranslate(textTranslate.mbgl_offsetPropertyValue);
+}
+
+- (id <MGLStyleAttributeValue>)textTranslate {
+ return [MGLStyleAttribute mbgl_offsetPropertyValueWith:self.layer->getTextTranslate()];
+}
+
+- (void)setTextTranslateAnchor:(id <MGLStyleAttributeValue, MGLStyleAttributeValue_Private>)textTranslateAnchor {
+ MGLSetEnumProperty(textTranslateAnchor, TextTranslateAnchor, TranslateAnchorType, MGLSymbolStyleLayerTextTranslateAnchor);
+}
+
+- (id <MGLStyleAttributeValue>)textTranslateAnchor {
+ MGLGetEnumProperty(TextTranslateAnchor, TranslateAnchorType, MGLSymbolStyleLayerTextTranslateAnchor);
+}
+
+@end
diff --git a/platform/darwin/src/MGLTypes.h b/platform/darwin/src/MGLTypes.h
index 2579451f2d..f63c602a53 100644
--- a/platform/darwin/src/MGLTypes.h
+++ b/platform/darwin/src/MGLTypes.h
@@ -12,6 +12,14 @@
#define _Nonnull
#endif
+#if TARGET_OS_IPHONE
+@class UIColor;
+#define MGLColor UIColor
+#else
+@class NSColor;
+#define MGLColor NSColor
+#endif
+
NS_ASSUME_NONNULL_BEGIN
/** Indicates an error occurred in the Mapbox SDK. */
diff --git a/platform/darwin/src/MGLVectorSource.h b/platform/darwin/src/MGLVectorSource.h
new file mode 100644
index 0000000000..28322e289e
--- /dev/null
+++ b/platform/darwin/src/MGLVectorSource.h
@@ -0,0 +1,5 @@
+#import "MGLSource.h"
+
+@interface MGLVectorSource : MGLSource
+
+@end
diff --git a/platform/darwin/src/MGLVectorSource.m b/platform/darwin/src/MGLVectorSource.m
new file mode 100644
index 0000000000..4d7918f5f7
--- /dev/null
+++ b/platform/darwin/src/MGLVectorSource.m
@@ -0,0 +1,5 @@
+#import "MGLVectorSource.h"
+
+@implementation MGLVectorSource
+
+@end
diff --git a/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.h
new file mode 100644
index 0000000000..fa5193acf0
--- /dev/null
+++ b/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.h
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+
+@interface NSArray (MGLStyleAttributeAdditions) <MGLStyleAttributeValue>
+
+@end
diff --git a/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.mm
new file mode 100644
index 0000000000..c0c9a4027a
--- /dev/null
+++ b/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.mm
@@ -0,0 +1,54 @@
+#import "NSArray+MGLStyleAttributeAdditions.h"
+
+#import "NSArray+MGLStyleAttributeAdditions_Private.hpp"
+#import "MGLStyleAttributeValue_Private.hpp"
+
+#include <array>
+
+@interface NSArray(Private) <MGLStyleAttributeValue_Private>
+@end
+
+@implementation NSArray (MGLStyleAttributeAdditions)
+
+- (mbgl::style::PropertyValue<std::array<float, 2>>)mbgl_offsetPropertyValue
+{
+ NSAssert(self.count == 2, @"Offset must contain 2 values (dx, dy)");
+ NSNumber *dx = self[0];
+ NSNumber *dy = self[1];
+ return {{dx.floatValue, dy.floatValue}};
+}
+
+- (mbgl::style::PropertyValue<std::array<float, 4> >)mbgl_paddingPropertyValue
+{
+ NSAssert(self.count == 4, @"Padding must contain 4 values (top, left, bottom & right)");
+ NSNumber *top = self[0];
+ NSNumber *left = self[1];
+ NSNumber *bottom = self[2];
+ NSNumber *right = self[3];
+ return {{top.floatValue, left.floatValue, bottom.floatValue, right.floatValue}};
+}
+
+- (mbgl::style::PropertyValue<std::vector<std::string> >)mbgl_stringArrayPropertyValue
+{
+ std::vector<std::string>fonts;
+
+ for (NSString *font in self) {
+ fonts.emplace_back(font.UTF8String);
+ }
+
+ return {{fonts}};
+}
+
+- (mbgl::style::PropertyValue<std::vector<float> >)mbgl_numberArrayPropertyValue
+{
+ std::vector<float>values;
+
+ for (NSNumber *n in self) {
+ values.emplace_back(n.floatValue);
+ }
+
+ return {{values}};
+}
+
+
+@end
diff --git a/platform/darwin/src/NSArray+MGLStyleAttributeAdditions_Private.hpp b/platform/darwin/src/NSArray+MGLStyleAttributeAdditions_Private.hpp
new file mode 100644
index 0000000000..1be02c01d2
--- /dev/null
+++ b/platform/darwin/src/NSArray+MGLStyleAttributeAdditions_Private.hpp
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+
+#include <mbgl/style/property_value.hpp>
+
+@interface NSArray (MGLStyleAttributeAdditions_Private) <MGLStyleAttributeValue>
+
+@end
diff --git a/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.h
new file mode 100644
index 0000000000..5a4f7af006
--- /dev/null
+++ b/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.h
@@ -0,0 +1,7 @@
+#import <Cocoa/Cocoa.h>
+
+#import "MGLStyleAttributeValue.h"
+
+@interface NSColor (MGLStyleAttributeAdditions) <MGLStyleAttributeValue>
+
+@end
diff --git a/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.m b/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.m
new file mode 100644
index 0000000000..ac330343c8
--- /dev/null
+++ b/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.m
@@ -0,0 +1,5 @@
+#import "NSColor+MGLStyleAttributeAdditions.h"
+
+@implementation NSColor (MGLStyleAttributeAdditions)
+
+@end
diff --git a/platform/darwin/src/NSColor+MGLStyleAttributeAdditions_Private.hpp b/platform/darwin/src/NSColor+MGLStyleAttributeAdditions_Private.hpp
new file mode 100644
index 0000000000..9a714cbd83
--- /dev/null
+++ b/platform/darwin/src/NSColor+MGLStyleAttributeAdditions_Private.hpp
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+
+#include <mbgl/style/property_value.hpp>
+
+@interface NSColor (MGLStyleAttributeAdditions_Private) <MGLStyleAttributeValue>
+
+@end
diff --git a/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.h
new file mode 100644
index 0000000000..162b5e94f5
--- /dev/null
+++ b/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.h
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+
+@interface NSNumber (MGLStyleAttributeAdditions) <MGLStyleAttributeValue>
+
+@end
diff --git a/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.mm
new file mode 100644
index 0000000000..163105d2fa
--- /dev/null
+++ b/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.mm
@@ -0,0 +1,22 @@
+#import "NSNumber+MGLStyleAttributeAdditions.h"
+
+#include <mbgl/style/property_value.hpp>
+
+@implementation NSNumber (MGLStyleAttributeAdditions)
+
+- (NSNumber *)numberValue
+{
+ return self;
+}
+
+- (mbgl::style::PropertyValue<bool>)mbgl_boolPropertyValue
+{
+ return mbgl::style::PropertyValue<bool> { !!self.boolValue };
+}
+
+- (mbgl::style::PropertyValue<float>)mbgl_floatPropertyValue
+{
+ return mbgl::style::PropertyValue<float> { self.floatValue };
+}
+
+@end
diff --git a/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions_Private.hpp b/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions_Private.hpp
new file mode 100644
index 0000000000..73e40bb3ad
--- /dev/null
+++ b/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions_Private.hpp
@@ -0,0 +1,13 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+
+#include <mbgl/style/property_value.hpp>
+
+@interface NSNumber (MGLStyleAttributeAdditions_Private) <MGLStyleAttributeValue>
+
+- (mbgl::style::PropertyValue<bool>)mbgl_booleanPropertyValue;
+
+- (mbgl::style::PropertyValue<float>)mbgl_numberPropertyValue;
+
+@end
diff --git a/platform/darwin/src/NSString+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSString+MGLStyleAttributeAdditions.h
new file mode 100644
index 0000000000..2126335922
--- /dev/null
+++ b/platform/darwin/src/NSString+MGLStyleAttributeAdditions.h
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+
+@interface NSString (MGLStyleAttributeAdditions) <MGLStyleAttributeValue>
+
+@end
diff --git a/platform/darwin/src/NSString+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSString+MGLStyleAttributeAdditions.mm
new file mode 100644
index 0000000000..84453217ab
--- /dev/null
+++ b/platform/darwin/src/NSString+MGLStyleAttributeAdditions.mm
@@ -0,0 +1,17 @@
+#import "NSString+MGLStyleAttributeAdditions.h"
+
+#import "NSString+MGLStyleAttributeAdditions_Private.hpp"
+
+@implementation NSString (MGLStyleAttributeAdditions)
+
+- (BOOL)isFunction
+{
+ return NO;
+}
+
+- (mbgl::style::PropertyValue<std::string>)mbgl_stringPropertyValue
+{
+ return mbgl::style::PropertyValue<std::string> {{ self.UTF8String }};
+}
+
+@end
diff --git a/platform/darwin/src/NSString+MGLStyleAttributeAdditions_Private.hpp b/platform/darwin/src/NSString+MGLStyleAttributeAdditions_Private.hpp
new file mode 100644
index 0000000000..8e401e2996
--- /dev/null
+++ b/platform/darwin/src/NSString+MGLStyleAttributeAdditions_Private.hpp
@@ -0,0 +1,11 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+
+#include <mbgl/style/property_value.hpp>
+
+@interface NSString (MGLStyleAttributeAdditions_Private) <MGLStyleAttributeValue>
+
+- (mbgl::style::PropertyValue<std::string>)mbgl_stringPropertyValue;
+
+@end
diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h
new file mode 100644
index 0000000000..0ee0c78f87
--- /dev/null
+++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+
+@interface NSValue (MGLStyleAttributeValue) <MGLStyleAttributeValue>
+
+@end
diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm
new file mode 100644
index 0000000000..3349ca211f
--- /dev/null
+++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm
@@ -0,0 +1,19 @@
+#import "NSValue+MGLStyleAttributeAdditions.h"
+
+#import "NSValue+MGLStyleAttributeAdditions_Private.hpp"
+
+@implementation NSValue (MGLStyleAttributeAdditions)
+
+- (BOOL)isFunction
+{
+ return NO;
+}
+
+- (mbgl::style::PropertyValue<uint8_t>)mbgl_enumPropertyValue
+{
+ uint8_t value = 0;
+ [self getValue:&value];
+ return mbgl::style::PropertyValue<uint8_t> { value };
+}
+
+@end
diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions_Private.hpp b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions_Private.hpp
new file mode 100644
index 0000000000..5bca9407ac
--- /dev/null
+++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions_Private.hpp
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLStyleAttributeValue.h"
+
+#include <mbgl/style/property_value.hpp>
+
+@interface NSValue (MGLStyleAttributeAdditions_Private) <MGLStyleAttributeValue>
+- (mbgl::style::PropertyValue<uint8_t>)mbgl_enumPropertyValue;
+@end
diff --git a/platform/darwin/src/UIColor+MGLStyleAttributeAdditions_Private.hpp b/platform/darwin/src/UIColor+MGLStyleAttributeAdditions_Private.hpp
new file mode 100644
index 0000000000..ef886dca5d
--- /dev/null
+++ b/platform/darwin/src/UIColor+MGLStyleAttributeAdditions_Private.hpp
@@ -0,0 +1,9 @@
+#import <UIKit/UIKit.h>
+
+#import "MGLStyleAttributeValue.h"
+
+#include <mbgl/style/property_value.hpp>
+
+@interface UIColor (MGLStyleAttributeAdditions_Private) <MGLStyleAttributeValue>
+
+@end
diff --git a/platform/darwin/test/MGLBackgroundStyleLayerTests.m b/platform/darwin/test/MGLBackgroundStyleLayerTests.m
new file mode 100644
index 0000000000..e36ca53022
--- /dev/null
+++ b/platform/darwin/test/MGLBackgroundStyleLayerTests.m
@@ -0,0 +1,29 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayerTests.h"
+
+@interface MGLBackgroundLayerTests : MGLStyleLayerTests
+@end
+
+@implementation MGLBackgroundLayerTests
+
+- (void)testBackgroundLayer {
+ NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"];
+ NSURL *url = [NSURL fileURLWithPath:filePath];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url];
+ MGLBackgroundStyleLayer *layer = [[MGLBackgroundStyleLayer alloc] initWithLayerIdentifier:@"layerID" sourceIdentifier:@"sourceID"];
+ [self.mapView.style addSource:source];
+ [self.mapView.style addLayer:layer];
+
+ layer.backgroundColor = MGLRuntimeStylingHelper.testColor;
+ layer.backgroundPattern = MGLRuntimeStylingHelper.testString;
+ layer.backgroundOpacity = MGLRuntimeStylingHelper.testNumber;
+
+ MGLBackgroundStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"];
+ XCTAssertEqualObjects(gLayer.backgroundColor, MGLRuntimeStylingHelper.testColor);
+ XCTAssertEqualObjects(gLayer.backgroundPattern, MGLRuntimeStylingHelper.testString);
+ XCTAssertEqualObjects(gLayer.backgroundOpacity, MGLRuntimeStylingHelper.testNumber);
+}
+
+@end
diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.m b/platform/darwin/test/MGLCircleStyleLayerTests.m
new file mode 100644
index 0000000000..f7ebcf822a
--- /dev/null
+++ b/platform/darwin/test/MGLCircleStyleLayerTests.m
@@ -0,0 +1,37 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayerTests.h"
+
+@interface MGLCircleLayerTests : MGLStyleLayerTests
+@end
+
+@implementation MGLCircleLayerTests
+
+- (void)testCircleLayer {
+ NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"];
+ NSURL *url = [NSURL fileURLWithPath:filePath];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url];
+ MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithLayerIdentifier:@"layerID" sourceIdentifier:@"sourceID"];
+ [self.mapView.style addSource:source];
+ [self.mapView.style addLayer:layer];
+
+ layer.circleRadius = MGLRuntimeStylingHelper.testNumber;
+ layer.circleColor = MGLRuntimeStylingHelper.testColor;
+ layer.circleBlur = MGLRuntimeStylingHelper.testNumber;
+ layer.circleOpacity = MGLRuntimeStylingHelper.testNumber;
+ layer.circleTranslate = MGLRuntimeStylingHelper.testOffset;
+ layer.circleTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCircleTranslateAnchorViewport type:@encode(MGLCircleStyleLayerCircleTranslateAnchor)];
+ layer.circlePitchScale = [MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCirclePitchScaleViewport type:@encode(MGLCircleStyleLayerCirclePitchScale)];
+
+ MGLCircleStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"];
+ XCTAssertEqualObjects(gLayer.circleRadius, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.circleColor, MGLRuntimeStylingHelper.testColor);
+ XCTAssertEqualObjects(gLayer.circleBlur, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.circleOpacity, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.circleTranslate, MGLRuntimeStylingHelper.testOffset);
+ XCTAssert([(NSValue *)gLayer.circleTranslateAnchor objCType] == [[MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCircleTranslateAnchorViewport type:@encode(MGLCircleStyleLayerCircleTranslateAnchor)] objCType]);
+ XCTAssert([(NSValue *)gLayer.circlePitchScale objCType] == [[MGLRuntimeStylingHelper testEnum:MGLCircleStyleLayerCirclePitchScaleViewport type:@encode(MGLCircleStyleLayerCirclePitchScale)] objCType]);
+}
+
+@end
diff --git a/platform/darwin/test/MGLFillStyleLayerTests.m b/platform/darwin/test/MGLFillStyleLayerTests.m
new file mode 100644
index 0000000000..5a03d96354
--- /dev/null
+++ b/platform/darwin/test/MGLFillStyleLayerTests.m
@@ -0,0 +1,37 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayerTests.h"
+
+@interface MGLFillLayerTests : MGLStyleLayerTests
+@end
+
+@implementation MGLFillLayerTests
+
+- (void)testFillLayer {
+ NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"];
+ NSURL *url = [NSURL fileURLWithPath:filePath];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url];
+ MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithLayerIdentifier:@"layerID" sourceIdentifier:@"sourceID"];
+ [self.mapView.style addSource:source];
+ [self.mapView.style addLayer:layer];
+
+ layer.fillAntialias = MGLRuntimeStylingHelper.testBool;
+ layer.fillOpacity = MGLRuntimeStylingHelper.testNumber;
+ layer.fillColor = MGLRuntimeStylingHelper.testColor;
+ layer.fillOutlineColor = MGLRuntimeStylingHelper.testColor;
+ layer.fillTranslate = MGLRuntimeStylingHelper.testOffset;
+ layer.fillTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLFillStyleLayerFillTranslateAnchorViewport type:@encode(MGLFillStyleLayerFillTranslateAnchor)];
+ layer.fillPattern = MGLRuntimeStylingHelper.testString;
+
+ MGLFillStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"];
+ XCTAssertEqualObjects(gLayer.fillAntialias, MGLRuntimeStylingHelper.testBool);
+ XCTAssertEqualObjects(gLayer.fillOpacity, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.fillColor, MGLRuntimeStylingHelper.testColor);
+ XCTAssertEqualObjects(gLayer.fillOutlineColor, MGLRuntimeStylingHelper.testColor);
+ XCTAssertEqualObjects(gLayer.fillTranslate, MGLRuntimeStylingHelper.testOffset);
+ XCTAssert([(NSValue *)gLayer.fillTranslateAnchor objCType] == [[MGLRuntimeStylingHelper testEnum:MGLFillStyleLayerFillTranslateAnchorViewport type:@encode(MGLFillStyleLayerFillTranslateAnchor)] objCType]);
+ XCTAssertEqualObjects(gLayer.fillPattern, MGLRuntimeStylingHelper.testString);
+}
+
+@end
diff --git a/platform/darwin/test/MGLLineStyleLayerTests.m b/platform/darwin/test/MGLLineStyleLayerTests.m
new file mode 100644
index 0000000000..0864c68ccd
--- /dev/null
+++ b/platform/darwin/test/MGLLineStyleLayerTests.m
@@ -0,0 +1,51 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayerTests.h"
+
+@interface MGLLineLayerTests : MGLStyleLayerTests
+@end
+
+@implementation MGLLineLayerTests
+
+- (void)testLineLayer {
+ NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"];
+ NSURL *url = [NSURL fileURLWithPath:filePath];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url];
+ MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithLayerIdentifier:@"layerID" sourceIdentifier:@"sourceID"];
+ [self.mapView.style addSource:source];
+ [self.mapView.style addLayer:layer];
+
+ layer.lineCap = [MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineCapSquare type:@encode(MGLLineStyleLayerLineCap)];
+ layer.lineJoin = [MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineJoinMiter type:@encode(MGLLineStyleLayerLineJoin)];
+ layer.lineMiterLimit = MGLRuntimeStylingHelper.testNumber;
+ layer.lineRoundLimit = MGLRuntimeStylingHelper.testNumber;
+ layer.lineOpacity = MGLRuntimeStylingHelper.testNumber;
+ layer.lineColor = MGLRuntimeStylingHelper.testColor;
+ layer.lineTranslate = MGLRuntimeStylingHelper.testOffset;
+ layer.lineTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineTranslateAnchorViewport type:@encode(MGLLineStyleLayerLineTranslateAnchor)];
+ layer.lineWidth = MGLRuntimeStylingHelper.testNumber;
+ layer.lineGapWidth = MGLRuntimeStylingHelper.testNumber;
+ layer.lineOffset = MGLRuntimeStylingHelper.testNumber;
+ layer.lineBlur = MGLRuntimeStylingHelper.testNumber;
+ layer.lineDasharray = MGLRuntimeStylingHelper.testDashArray;
+ layer.linePattern = MGLRuntimeStylingHelper.testString;
+
+ MGLLineStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"];
+ XCTAssert([(NSValue *)gLayer.lineCap objCType] == [[MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineCapSquare type:@encode(MGLLineStyleLayerLineCap)] objCType]);
+ XCTAssert([(NSValue *)gLayer.lineJoin objCType] == [[MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineJoinMiter type:@encode(MGLLineStyleLayerLineJoin)] objCType]);
+ XCTAssertEqualObjects(gLayer.lineMiterLimit, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.lineRoundLimit, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.lineOpacity, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.lineColor, MGLRuntimeStylingHelper.testColor);
+ XCTAssertEqualObjects(gLayer.lineTranslate, MGLRuntimeStylingHelper.testOffset);
+ XCTAssert([(NSValue *)gLayer.lineTranslateAnchor objCType] == [[MGLRuntimeStylingHelper testEnum:MGLLineStyleLayerLineTranslateAnchorViewport type:@encode(MGLLineStyleLayerLineTranslateAnchor)] objCType]);
+ XCTAssertEqualObjects(gLayer.lineWidth, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.lineGapWidth, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.lineOffset, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.lineBlur, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.lineDasharray, MGLRuntimeStylingHelper.testDashArray);
+ XCTAssertEqualObjects(gLayer.linePattern, MGLRuntimeStylingHelper.testString);
+}
+
+@end
diff --git a/platform/darwin/test/MGLRasterStyleLayerTests.m b/platform/darwin/test/MGLRasterStyleLayerTests.m
new file mode 100644
index 0000000000..6d5cd6293b
--- /dev/null
+++ b/platform/darwin/test/MGLRasterStyleLayerTests.m
@@ -0,0 +1,37 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayerTests.h"
+
+@interface MGLRasterLayerTests : MGLStyleLayerTests
+@end
+
+@implementation MGLRasterLayerTests
+
+- (void)testRasterLayer {
+ NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"];
+ NSURL *url = [NSURL fileURLWithPath:filePath];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url];
+ MGLRasterStyleLayer *layer = [[MGLRasterStyleLayer alloc] initWithLayerIdentifier:@"layerID" sourceIdentifier:@"sourceID"];
+ [self.mapView.style addSource:source];
+ [self.mapView.style addLayer:layer];
+
+ layer.rasterOpacity = MGLRuntimeStylingHelper.testNumber;
+ layer.rasterHueRotate = MGLRuntimeStylingHelper.testNumber;
+ layer.rasterBrightnessMin = MGLRuntimeStylingHelper.testNumber;
+ layer.rasterBrightnessMax = MGLRuntimeStylingHelper.testNumber;
+ layer.rasterSaturation = MGLRuntimeStylingHelper.testNumber;
+ layer.rasterContrast = MGLRuntimeStylingHelper.testNumber;
+ layer.rasterFadeDuration = MGLRuntimeStylingHelper.testNumber;
+
+ MGLRasterStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"];
+ XCTAssertEqualObjects(gLayer.rasterOpacity, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.rasterHueRotate, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.rasterBrightnessMin, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.rasterBrightnessMax, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.rasterSaturation, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.rasterContrast, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.rasterFadeDuration, MGLRuntimeStylingHelper.testNumber);
+}
+
+@end
diff --git a/platform/darwin/test/MGLRuntimeStylingHelper.h b/platform/darwin/test/MGLRuntimeStylingHelper.h
new file mode 100644
index 0000000000..fa1543ec47
--- /dev/null
+++ b/platform/darwin/test/MGLRuntimeStylingHelper.h
@@ -0,0 +1,25 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLTypes.h"
+
+@interface MGLRuntimeStylingHelper : NSObject
+
++ (NSArray *)testPadding;
+
++ (NSArray *)testOffset;
+
++ (NSArray *)testFont;
+
++ (NSArray *)testDashArray;
+
++ (NSNumber *)testNumber;
+
++ (NSNumber *)testBool;
+
++ (NSString *)testString;
+
++ (MGLColor *)testColor;
+
++ (NSValue *)testEnum:(NSUInteger)value type:(const char *)type;
+
+@end
diff --git a/platform/darwin/test/MGLRuntimeStylingHelper.m b/platform/darwin/test/MGLRuntimeStylingHelper.m
new file mode 100644
index 0000000000..fbdc8e5225
--- /dev/null
+++ b/platform/darwin/test/MGLRuntimeStylingHelper.m
@@ -0,0 +1,56 @@
+#import "MGLRuntimeStylingHelper.h"
+
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+#import <UIKit/UIKit.h>
+#else
+#import <Cocoa/Cocoa.h>
+#endif
+
+@implementation MGLRuntimeStylingHelper
+
++ (NSArray *)testPadding
+{
+ return @[@1.0f, @1.0f, @1.0f, @1.0f];
+}
+
++ (NSArray *)testOffset
+{
+ return @[@1.0f, @1.0f];
+}
+
++ (NSArray *)testFont
+{
+ return @[@"Open Sans Regular", @"Arial Unicode MS Regular"];
+}
+
++ (NSArray *)testDashArray
+{
+ return @[@1, @2];
+}
+
++ (NSNumber *)testNumber
+{
+ return @1;
+}
+
++ (NSNumber *)testBool
+{
+ return @YES;
+}
+
++ (NSString *)testString
+{
+ return @"test";
+}
+
++ (MGLColor *)testColor
+{
+ return [MGLColor redColor];
+}
+
++ (NSValue *)testEnum:(NSUInteger)value type:(const char *)type
+{
+ return [NSValue value:&value withObjCType:type];
+}
+
+@end
diff --git a/platform/darwin/test/MGLStyleLayerTests.h b/platform/darwin/test/MGLStyleLayerTests.h
new file mode 100644
index 0000000000..f81e075e03
--- /dev/null
+++ b/platform/darwin/test/MGLStyleLayerTests.h
@@ -0,0 +1,10 @@
+#import <Mapbox/Mapbox.h>
+#import "MGLRuntimeStylingHelper.h"
+#import <XCTest/XCTest.h>
+
+@interface MGLStyleLayerTests : XCTestCase <MGLMapViewDelegate>
+
+@property (nonatomic) IBOutlet MGLMapView *mapView;
+@property (nonatomic) XCTestExpectation *expectation;
+
+@end
diff --git a/platform/darwin/test/MGLStyleLayerTests.m b/platform/darwin/test/MGLStyleLayerTests.m
new file mode 100644
index 0000000000..ae0a59edd3
--- /dev/null
+++ b/platform/darwin/test/MGLStyleLayerTests.m
@@ -0,0 +1,21 @@
+#import "MGLStyleLayerTests.h"
+
+@implementation MGLStyleLayerTests
+
+- (void)setUp {
+ [super setUp];
+#if TARGET_OS_IPHONE
+ UIApplication *app = [[UIApplication sharedApplication] delegate];
+ UIViewController *vc = [[UIViewController alloc] init];
+ app.keyWindow.rootViewController = vc;
+ [vc view]; // Force load xib
+ _mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 256, 256)];
+ [vc.view addSubview:_mapView];
+ _mapView.delegate = self;
+#else
+ NSWindowController *windowController = [[NSWindowController alloc] initWithWindowNibName:@"MGLStyleLayerTests" owner:self];
+ [windowController showWindow:nil];
+#endif
+}
+
+@end
diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.m b/platform/darwin/test/MGLSymbolStyleLayerTests.m
new file mode 100644
index 0000000000..b8c3cdd77b
--- /dev/null
+++ b/platform/darwin/test/MGLSymbolStyleLayerTests.m
@@ -0,0 +1,119 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
+
+#import "MGLStyleLayerTests.h"
+
+@interface MGLSymbolLayerTests : MGLStyleLayerTests
+@end
+
+@implementation MGLSymbolLayerTests
+
+- (void)testSymbolLayer {
+ NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"];
+ NSURL *url = [NSURL fileURLWithPath:filePath];
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"sourceID" URL:url];
+ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifier:@"layerID" sourceIdentifier:@"sourceID"];
+ [self.mapView.style addSource:source];
+ [self.mapView.style addLayer:layer];
+
+ layer.symbolPlacement = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerSymbolPlacementLine type:@encode(MGLSymbolStyleLayerSymbolPlacement)];
+ layer.symbolSpacing = MGLRuntimeStylingHelper.testNumber;
+ layer.symbolAvoidEdges = MGLRuntimeStylingHelper.testBool;
+ layer.iconAllowOverlap = MGLRuntimeStylingHelper.testBool;
+ layer.iconIgnorePlacement = MGLRuntimeStylingHelper.testBool;
+ layer.iconOptional = MGLRuntimeStylingHelper.testBool;
+ layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerIconRotationAlignment)];
+ layer.iconSize = MGLRuntimeStylingHelper.testNumber;
+ layer.iconTextFit = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTextFitHeight type:@encode(MGLSymbolStyleLayerIconTextFit)];
+ layer.iconTextFitPadding = MGLRuntimeStylingHelper.testPadding;
+ layer.iconImage = MGLRuntimeStylingHelper.testString;
+ layer.iconRotate = MGLRuntimeStylingHelper.testNumber;
+ layer.iconPadding = MGLRuntimeStylingHelper.testNumber;
+ layer.iconKeepUpright = MGLRuntimeStylingHelper.testBool;
+ layer.iconOffset = MGLRuntimeStylingHelper.testOffset;
+ layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentViewport type:@encode(MGLSymbolStyleLayerTextPitchAlignment)];
+ layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerTextRotationAlignment)];
+ layer.textField = MGLRuntimeStylingHelper.testString;
+ layer.textFont = MGLRuntimeStylingHelper.testFont;
+ layer.textSize = MGLRuntimeStylingHelper.testNumber;
+ layer.textMaxWidth = MGLRuntimeStylingHelper.testNumber;
+ layer.textLineHeight = MGLRuntimeStylingHelper.testNumber;
+ layer.textLetterSpacing = MGLRuntimeStylingHelper.testNumber;
+ layer.textJustify = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextJustifyRight type:@encode(MGLSymbolStyleLayerTextJustify)];
+ layer.textAnchor = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextAnchorBottomRight type:@encode(MGLSymbolStyleLayerTextAnchor)];
+ layer.textMaxAngle = MGLRuntimeStylingHelper.testNumber;
+ layer.textRotate = MGLRuntimeStylingHelper.testNumber;
+ layer.textPadding = MGLRuntimeStylingHelper.testNumber;
+ layer.textKeepUpright = MGLRuntimeStylingHelper.testBool;
+ layer.textTransform = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTransformLowercase type:@encode(MGLSymbolStyleLayerTextTransform)];
+ layer.textOffset = MGLRuntimeStylingHelper.testOffset;
+ layer.textAllowOverlap = MGLRuntimeStylingHelper.testBool;
+ layer.textIgnorePlacement = MGLRuntimeStylingHelper.testBool;
+ layer.textOptional = MGLRuntimeStylingHelper.testBool;
+ layer.iconOpacity = MGLRuntimeStylingHelper.testNumber;
+ layer.iconColor = MGLRuntimeStylingHelper.testColor;
+ layer.iconHaloColor = MGLRuntimeStylingHelper.testColor;
+ layer.iconHaloWidth = MGLRuntimeStylingHelper.testNumber;
+ layer.iconHaloBlur = MGLRuntimeStylingHelper.testNumber;
+ layer.iconTranslate = MGLRuntimeStylingHelper.testOffset;
+ layer.iconTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerIconTranslateAnchor)];
+ layer.textOpacity = MGLRuntimeStylingHelper.testNumber;
+ layer.textColor = MGLRuntimeStylingHelper.testColor;
+ layer.textHaloColor = MGLRuntimeStylingHelper.testColor;
+ layer.textHaloWidth = MGLRuntimeStylingHelper.testNumber;
+ layer.textHaloBlur = MGLRuntimeStylingHelper.testNumber;
+ layer.textTranslate = MGLRuntimeStylingHelper.testOffset;
+ layer.textTranslateAnchor = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerTextTranslateAnchor)];
+
+ MGLSymbolStyleLayer *gLayer = [self.mapView.style layerWithIdentifier:@"layerID"];
+ XCTAssert([(NSValue *)gLayer.symbolPlacement objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerSymbolPlacementLine type:@encode(MGLSymbolStyleLayerSymbolPlacement)] objCType]);
+ XCTAssertEqualObjects(gLayer.symbolSpacing, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.symbolAvoidEdges, MGLRuntimeStylingHelper.testBool);
+ XCTAssertEqualObjects(gLayer.iconAllowOverlap, MGLRuntimeStylingHelper.testBool);
+ XCTAssertEqualObjects(gLayer.iconIgnorePlacement, MGLRuntimeStylingHelper.testBool);
+ XCTAssertEqualObjects(gLayer.iconOptional, MGLRuntimeStylingHelper.testBool);
+ XCTAssert([(NSValue *)gLayer.iconRotationAlignment objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerIconRotationAlignment)] objCType]);
+ XCTAssertEqualObjects(gLayer.iconSize, MGLRuntimeStylingHelper.testNumber);
+ XCTAssert([(NSValue *)gLayer.iconTextFit objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTextFitHeight type:@encode(MGLSymbolStyleLayerIconTextFit)] objCType]);
+ XCTAssertEqualObjects(gLayer.iconTextFitPadding, MGLRuntimeStylingHelper.testPadding);
+ XCTAssertEqualObjects(gLayer.iconImage, MGLRuntimeStylingHelper.testString);
+ XCTAssertEqualObjects(gLayer.iconRotate, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.iconPadding, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.iconKeepUpright, MGLRuntimeStylingHelper.testBool);
+ XCTAssertEqualObjects(gLayer.iconOffset, MGLRuntimeStylingHelper.testOffset);
+ XCTAssert([(NSValue *)gLayer.textPitchAlignment objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentViewport type:@encode(MGLSymbolStyleLayerTextPitchAlignment)] objCType]);
+ XCTAssert([(NSValue *)gLayer.textRotationAlignment objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerTextRotationAlignment)] objCType]);
+ XCTAssertEqualObjects(gLayer.textField, MGLRuntimeStylingHelper.testString);
+ XCTAssertEqualObjects(gLayer.textFont, MGLRuntimeStylingHelper.testFont);
+ XCTAssertEqualObjects(gLayer.textSize, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.textMaxWidth, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.textLineHeight, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.textLetterSpacing, MGLRuntimeStylingHelper.testNumber);
+ XCTAssert([(NSValue *)gLayer.textJustify objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextJustifyRight type:@encode(MGLSymbolStyleLayerTextJustify)] objCType]);
+ XCTAssert([(NSValue *)gLayer.textAnchor objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextAnchorBottomRight type:@encode(MGLSymbolStyleLayerTextAnchor)] objCType]);
+ XCTAssertEqualObjects(gLayer.textMaxAngle, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.textRotate, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.textPadding, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.textKeepUpright, MGLRuntimeStylingHelper.testBool);
+ XCTAssert([(NSValue *)gLayer.textTransform objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTransformLowercase type:@encode(MGLSymbolStyleLayerTextTransform)] objCType]);
+ XCTAssertEqualObjects(gLayer.textOffset, MGLRuntimeStylingHelper.testOffset);
+ XCTAssertEqualObjects(gLayer.textAllowOverlap, MGLRuntimeStylingHelper.testBool);
+ XCTAssertEqualObjects(gLayer.textIgnorePlacement, MGLRuntimeStylingHelper.testBool);
+ XCTAssertEqualObjects(gLayer.textOptional, MGLRuntimeStylingHelper.testBool);
+ XCTAssertEqualObjects(gLayer.iconOpacity, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.iconColor, MGLRuntimeStylingHelper.testColor);
+ XCTAssertEqualObjects(gLayer.iconHaloColor, MGLRuntimeStylingHelper.testColor);
+ XCTAssertEqualObjects(gLayer.iconHaloWidth, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.iconHaloBlur, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.iconTranslate, MGLRuntimeStylingHelper.testOffset);
+ XCTAssert([(NSValue *)gLayer.iconTranslateAnchor objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerIconTranslateAnchor)] objCType]);
+ XCTAssertEqualObjects(gLayer.textOpacity, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.textColor, MGLRuntimeStylingHelper.testColor);
+ XCTAssertEqualObjects(gLayer.textHaloColor, MGLRuntimeStylingHelper.testColor);
+ XCTAssertEqualObjects(gLayer.textHaloWidth, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.textHaloBlur, MGLRuntimeStylingHelper.testNumber);
+ XCTAssertEqualObjects(gLayer.textTranslate, MGLRuntimeStylingHelper.testOffset);
+ XCTAssert([(NSValue *)gLayer.textTranslateAnchor objCType] == [[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextTranslateAnchorViewport type:@encode(MGLSymbolStyleLayerTextTranslateAnchor)] objCType]);
+}
+
+@end