From 37703f4bf19c4e8b90d5d10c29e44470568a718b Mon Sep 17 00:00:00 2001 From: Max Buster Date: Wed, 13 May 2020 09:10:53 -0700 Subject: [PATCH 01/33] Added source and layers --- .../java/com/mapbox/mapboxgl/Convert.java | 247 ++++++++++++++++++ .../mapbox/mapboxgl/MapboxMapController.java | 59 +++++ example/lib/layer.dart | 83 ++++++ example/lib/main.dart | 2 + ios/Classes/Convert.swift | 166 ++++++++++++ ios/Classes/MapboxMapController.swift | 32 +++ lib/src/controller.dart | 15 ++ 7 files changed, 604 insertions(+) create mode 100644 example/lib/layer.dart diff --git a/android/src/main/java/com/mapbox/mapboxgl/Convert.java b/android/src/main/java/com/mapbox/mapboxgl/Convert.java index ca22c4b54..9a5eb09bc 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/Convert.java +++ b/android/src/main/java/com/mapbox/mapboxgl/Convert.java @@ -13,13 +13,25 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.log.Logger; import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.PropertyFactory; +import com.mapbox.mapboxsdk.style.layers.PropertyValue; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; +import io.flutter.plugin.common.JSONUtil; + /** * Conversions between JSON-like values and MapboxMaps data types. */ @@ -545,5 +557,240 @@ static void interpretFillOptions(Object o, FillOptionsSink sink) { if (draggable != null) { sink.setDraggable(toBoolean(draggable)); } + static PropertyValue[] interpretSymbolLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + case "icon-allow-overlap": + properties.add(PropertyFactory.iconAllowOverlap(expression)); + break; + case "icon-anchor": + properties.add(PropertyFactory.iconAnchor(expression)); + break; + case "icon-color": + properties.add(PropertyFactory.iconColor(expression)); + break; + case "icon-halo-blur": + properties.add(PropertyFactory.iconHaloBlur(expression)); + break; + case "icon-halo-color": + properties.add(PropertyFactory.iconHaloColor(expression)); + break; + case "icon-halo-width": + properties.add(PropertyFactory.iconHaloWidth(expression)); + break; + case "icon-ignore-placement": + properties.add(PropertyFactory.iconIgnorePlacement(expression)); + break; + case "icon-image": + properties.add(PropertyFactory.iconImage(expression)); + break; + case "icon-keep-upright": + properties.add(PropertyFactory.iconKeepUpright(expression)); + break; + case "icon-offset": + properties.add(PropertyFactory.iconOffset(expression)); + break; + case "icon-opacity": + properties.add(PropertyFactory.iconOpacity(expression)); + break; + case "icon-optional": + properties.add(PropertyFactory.iconOptional(expression)); + break; + case "icon-padding": + properties.add(PropertyFactory.iconPadding(expression)); + break; + case "icon-pitch-alignment": + properties.add(PropertyFactory.iconPitchAlignment(expression)); + break; + case "icon-rotate": + properties.add(PropertyFactory.iconRotate(expression)); + break; + case "icon-rotation-alignment": + properties.add(PropertyFactory.iconRotationAlignment(expression)); + break; + case "icon-size": + properties.add(PropertyFactory.iconSize(expression)); + break; + case "icon-text-fit": + properties.add(PropertyFactory.iconTextFit(expression)); + break; + case "icon-text-fit-padding": + properties.add(PropertyFactory.iconTextFitPadding(expression)); + break; + case "icon-translate": + properties.add(PropertyFactory.iconTranslate(expression)); + break; + case "icon-translate-anchor": + properties.add(PropertyFactory.iconTranslateAnchor(expression)); + break; + case "symbol-avoid-edges": + properties.add(PropertyFactory.symbolAvoidEdges(expression)); + break; + case "symbol-placement": + properties.add(PropertyFactory.symbolPlacement(expression)); + break; + case "symbol-sort-key": + properties.add(PropertyFactory.symbolSortKey(expression)); + break; + case "symbol-spacing": + properties.add(PropertyFactory.symbolSpacing(expression)); + break; + case "symbol-z-order": + properties.add(PropertyFactory.symbolZOrder(expression)); + break; + case "text-allow-overlap": + properties.add(PropertyFactory.textAllowOverlap(expression)); + break; + case "text-anchor": + properties.add(PropertyFactory.textAnchor(expression)); + break; + case "text-color": + properties.add(PropertyFactory.textColor(expression)); + break; + case "text-field": + properties.add(PropertyFactory.textField(expression)); + break; + case "text-font": + properties.add(PropertyFactory.textFont(expression)); + break; + case "text-halo-blur": + properties.add(PropertyFactory.textHaloBlur(expression)); + break; + case "text-halo-color": + properties.add(PropertyFactory.textHaloColor(expression)); + break; + case "text-halo-width": + properties.add(PropertyFactory.textHaloWidth(expression)); + break; + case "text-ignore-placement": + properties.add(PropertyFactory.textIgnorePlacement(expression)); + break; + case "text-justify": + properties.add(PropertyFactory.textJustify(expression)); + break; + case "text-keep-upright": + properties.add(PropertyFactory.textKeepUpright(expression)); + break; + case "text-letter-spacing": + properties.add(PropertyFactory.textLetterSpacing(expression)); + break; + case "text-line-height": + properties.add(PropertyFactory.textLineHeight(expression)); + break; + case "text-max-angle": + properties.add(PropertyFactory.textMaxAngle(expression)); + break; + case "text-max-width": + properties.add(PropertyFactory.textMaxWidth(expression)); + break; + case "text-offset": + properties.add(PropertyFactory.textOffset(expression)); + break; + case "text-opacity": + properties.add(PropertyFactory.textOpacity(expression)); + break; + case "text-optional": + properties.add(PropertyFactory.textOptional(expression)); + break; + case "text-padding": + properties.add(PropertyFactory.textPadding(expression)); + break; + case "text-pitch-alignment": + properties.add(PropertyFactory.textPitchAlignment(expression)); + break; + case "text-radial-offset": + properties.add(PropertyFactory.textRadialOffset(expression)); + break; + case "text-rotate": + properties.add(PropertyFactory.textRotate(expression)); + break; + case "text-rotation-alignment": + properties.add(PropertyFactory.textRotationAlignment(expression)); + break; + case "text-size": + properties.add(PropertyFactory.textSize(expression)); + break; + case "text-transform": + properties.add(PropertyFactory.textTransform(expression)); + break; + case "text-translate": + properties.add(PropertyFactory.textTranslate(expression)); + break; + case "text-translate-anchor": + properties.add(PropertyFactory.textTranslateAnchor(expression)); + break; + case "text-variable-anchor": + properties.add(PropertyFactory.textVariableAnchor(expression)); + break; + case "text-writing-mode": + properties.add(PropertyFactory.textWritingMode(expression)); + break; + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + + static PropertyValue[] interpretLineLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch(entry.getKey()) { + case "line-blur": + properties.add(PropertyFactory.lineBlur(expression)); + break; + case "line-cap": + properties.add(PropertyFactory.lineCap(expression)); + break; + case "line-color": + properties.add(PropertyFactory.lineColor(expression)); + break; + case "line-dasharray": + properties.add(PropertyFactory.lineDasharray(expression)); + break; + case "line-gap-width": + properties.add(PropertyFactory.lineGapWidth(expression)); + break; + case "line-gradient": + properties.add(PropertyFactory.lineGradient(expression)); + break; + case "line-join": + properties.add(PropertyFactory.lineJoin(expression)); + break; + case "line-miter-limit": + properties.add(PropertyFactory.lineMiterLimit(expression)); + break; + case "line-offset": + properties.add(PropertyFactory.lineOffset(expression)); + break; + case "line-pattern": + properties.add(PropertyFactory.linePattern(expression)); + break; + case "line-round-limit": + properties.add(PropertyFactory.lineRoundLimit(expression)); + break; + case "line-translate": + properties.add(PropertyFactory.lineTranslate(expression)); + break; + case "line-translate-anchor": + properties.add(PropertyFactory.lineTranslateAnchor(expression)); + break; + case "line-width": + properties.add(PropertyFactory.lineWidth(expression)); + break; + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); } } \ No newline at end of file diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index 62b3cbd75..3cb928f31 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -34,6 +34,7 @@ import com.mapbox.android.core.location.LocationEngineResult; import com.mapbox.android.telemetry.TelemetryEnabler; import com.mapbox.geojson.Feature; +import com.mapbox.geojson.FeatureCollection; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdate; @@ -71,6 +72,17 @@ import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.RasterLayer; import com.mapbox.mapboxsdk.style.sources.ImageSource; +import com.mapbox.mapboxsdk.style.layers.LineLayer; +import com.mapbox.mapboxsdk.style.layers.Property; +import com.mapbox.mapboxsdk.style.layers.PropertyFactory; +import com.mapbox.mapboxsdk.style.layers.PropertyValue; +import com.mapbox.mapboxsdk.style.layers.SymbolLayer; +import com.mapbox.mapboxsdk.style.sources.GeoJsonSource; + +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.common.PluginRegistry; +import io.flutter.plugin.platform.PlatformView; import java.io.IOException; import java.io.InputStream; @@ -374,6 +386,35 @@ private void onUserLocationUpdate(Location location){ arguments.put("userLocation", userLocation); methodChannel.invokeMethod("map#onUserLocationUpdated", arguments); } + + private void addSource(String sourceName, String geojson) { + FeatureCollection featureCollection = FeatureCollection.fromJson(geojson); + GeoJsonSource geoJsonSource = new GeoJsonSource(sourceName, featureCollection); + + mapStyle.addSource(geoJsonSource); + } + + private void addSymbolLayer(String layerName, + String sourceName, + PropertyValue[] properties, + Expression filter) { + SymbolLayer symbolLayer = new SymbolLayer(layerName, sourceName); + + symbolLayer.setProperties(properties); + + mapStyle.addLayer(symbolLayer); + } + + private void addLineLayer(String layerName, + String sourceName, + PropertyValue[] properties, + Expression filter) { + LineLayer lineLayer = new LineLayer(layerName, sourceName); + + lineLayer.setProperties(properties); + + mapStyle.addLayer(lineLayer); + } private void enableSymbolManager(@NonNull Style style) { if (symbolManager == null) { @@ -905,6 +946,24 @@ public void onError(@NonNull String message) { Convert.interpretFillOptions(call.argument("options"), fill); fill.update(fillManager); result.success(null); + case "source#add": { + final String sourceId = call.argument("sourceId"); + final String geojson = call.argument("geojson"); + addSource(sourceId, geojson); + break; + } + case "symbolLayer#add": { + final String sourceId = call.argument("sourceId"); + final String layerId = call.argument("layerId"); + final PropertyValue[] properties = Convert.interpretSymbolLayerProperties(call.argument("properties")); + addSymbolLayer(layerId, sourceId, properties, null); + break; + } + case "lineLayer#add": { + final String sourceId = call.argument("sourceId"); + final String layerId = call.argument("layerId"); + final PropertyValue[] properties = Convert.interpretLineLayerProperties(call.argument("properties")); + addLineLayer(layerId, sourceId, properties, null); break; } case "locationComponent#getLastLocation": { diff --git a/example/lib/layer.dart b/example/lib/layer.dart new file mode 100644 index 000000000..3fca317a8 --- /dev/null +++ b/example/lib/layer.dart @@ -0,0 +1,83 @@ +import 'package:flutter/material.dart'; +import 'package:mapbox_gl_example/page.dart'; +import 'package:mapbox_gl/mapbox_gl.dart'; + +class LayerPage extends Page { + + LayerPage() : super(const Icon(Icons.share), 'Layer'); + + @override + Widget build(BuildContext context) => LayerBody(); +} + +class LayerBody extends StatefulWidget { + + @override + State createState() => LayerState(); +} + +class LayerState extends State { + static final LatLng center = const LatLng(-33.86711, 151.1947171); + static final String geojson = ''' +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 151.19213104248047, + -33.87112820031405 + ], + [ + 151.21770858764648, + -33.853737857223145 + ] + ] + } + } + ] +} + '''; + + MapboxMapController controller; + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Center( + child: SizedBox( + width: 300.0, + height: 500.0, + child: MapboxMap( + onMapCreated: _onMapCreated, + onStyleLoadedCallback: _onStyleLoadedCallback, + initialCameraPosition: CameraPosition( + target: center, + zoom: 11.0, + ), + ), + ), + ), + ] + ); + } + + void _onMapCreated(MapboxMapController controller) { + this.controller = controller; + } + + void _onStyleLoadedCallback() { + controller.addSource("source_1", geojson); + controller.addLineLayer("source_1", "layer_1", { + 'line-color': "[\"rgb\", 171, 72, 33]", + 'line-width': "[\"to-number\", 5]" + }); + } +} \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index de06ee3ee..7ab20be1a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -9,6 +9,7 @@ import 'package:mapbox_gl_example/custom_marker.dart'; import 'package:mapbox_gl_example/full_map.dart'; import 'package:mapbox_gl_example/offline_regions.dart'; import 'package:mapbox_gl_example/place_batch.dart'; +import 'package:mapbox_gl_example/layer.dart'; import 'animate_camera.dart'; import 'annotation_order_maps.dart'; @@ -33,6 +34,7 @@ final List _allPages = [ PlaceSourcePage(), LinePage(), LocalStylePage(), + LayerPage(), PlaceCirclePage(), PlaceFillPage(), ScrollingMapPage(), diff --git a/ios/Classes/Convert.swift b/ios/Classes/Convert.swift index bcaed1638..6897a7540 100644 --- a/ios/Classes/Convert.swift +++ b/ios/Classes/Convert.swift @@ -355,4 +355,170 @@ class Convert { } return polygons } + class func addSymbolProperties(symbolLayer: MGLSymbolStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + case "icon-allow-overlap": + symbolLayer.iconAllowsOverlap = expression + case "icon-anchor": + symbolLayer.iconAnchor = expression + case "icon-color": + symbolLayer.iconColor = expression + case "icon-halo-blur": + symbolLayer.iconHaloBlur = expression + case "icon-halo-color": + symbolLayer.iconHaloColor = expression + case "icon-halo-width": + symbolLayer.iconHaloWidth = expression + case "icon-ignore-placement": + symbolLayer.iconIgnoresPlacement = expression + case "icon-image": + symbolLayer.iconImageName = expression + case "icon-keep-upright": + symbolLayer.keepsIconUpright = expression + case "icon-offset": + symbolLayer.iconOffset = expression + case "icon-opacity": + symbolLayer.iconOpacity = expression + case "icon-optional": + symbolLayer.iconOptional = expression + case "icon-padding": + symbolLayer.iconPadding = expression + case "icon-pitch-alignment": + symbolLayer.iconPitchAlignment = expression + case "icon-rotate": + symbolLayer.iconRotation = expression + case "icon-rotation-alignment": + symbolLayer.iconRotationAlignment = expression + case "icon-size": + symbolLayer.iconScale = expression + case "icon-text-fit": + symbolLayer.iconTextFit = expression + case "icon-text-fit-padding": + symbolLayer.iconTextFitPadding = expression + case "icon-translate": + symbolLayer.iconTranslation = expression + case "icon-translate-anchor": + symbolLayer.iconTranslationAnchor = expression + case "symbol-avoid-edges": + symbolLayer.symbolAvoidsEdges = expression + case "symbol-placement": + symbolLayer.symbolPlacement = expression + case "symbol-sort-key": + symbolLayer.symbolSortKey = expression + case "symbol-spacing": + symbolLayer.symbolSpacing = expression + case "symbol-z-order": + symbolLayer.symbolZOrder = expression + case "text-allow-overlap": + symbolLayer.textAllowsOverlap = expression + case "text-anchor": + symbolLayer.textAnchor = expression + case "text-color": + symbolLayer.textColor = expression + case "text-field": + symbolLayer.text = expression + case "text-font": + symbolLayer.textFontNames = expression + case "text-halo-blur": + symbolLayer.textHaloBlur = expression + case "text-halo-color": + symbolLayer.textHaloColor = expression + case "text-halo-width": + symbolLayer.textHaloWidth = expression + case "text-ignore-placement": + symbolLayer.textIgnoresPlacement = expression + case "text-justify": + symbolLayer.textJustification = expression + case "text-keep-upright": + symbolLayer.keepsTextUpright = expression + case "text-letter-spacing": + symbolLayer.textLetterSpacing = expression + case "text-line-height": + symbolLayer.textLineHeight = expression + case "text-max-angle": + symbolLayer.maximumTextAngle = expression + case "text-max-width": + symbolLayer.maximumTextWidth = expression + case "text-offset": + symbolLayer.textOffset = expression + case "text-opacity": + symbolLayer.textOpacity = expression + case "text-optional": + symbolLayer.textOptional = expression + case "text-padding": + symbolLayer.textPadding = expression + case "text-pitch-alignment": + symbolLayer.textPitchAlignment = expression + case "text-radial-offset": + symbolLayer.textRadialOffset = expression + case "text-rotate": + symbolLayer.textRotation = expression + case "text-rotation-alignment": + symbolLayer.textRotationAlignment = expression + case "text-size": + symbolLayer.textFontSize = expression + case "text-transform": + symbolLayer.textTransform = expression + case "text-translate": + symbolLayer.textTranslation = expression + case "text-translate-anchor": + symbolLayer.textTranslationAnchor = expression + case "text-variable-anchor": + symbolLayer.textVariableAnchor = expression + case "text-writing-mode": + symbolLayer.textWritingModes = expression + default: + break + } + } + } + + class func addLineProperties(lineLayer: MGLLineStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + case "line-blur": + lineLayer.lineBlur = expression + case "line-cap": + lineLayer.lineCap = expression + case "line-color": + lineLayer.lineColor = expression + case "line-dasharray": + lineLayer.lineDashPattern = expression + case "line-gap-width": + lineLayer.lineGapWidth = expression + case "line-gradient": + lineLayer.lineGradient = expression + case "line-join": + lineLayer.lineJoin = expression + case "line-miter-limit": + lineLayer.lineMiterLimit = expression + case "line-offset": + lineLayer.lineOffset = expression + case "line-pattern": + lineLayer.linePattern = expression + case "line-round-limit": + lineLayer.lineRoundLimit = expression + case "line-translate": + lineLayer.lineTranslation = expression + case "line-translate-anchor": + lineLayer.lineTranslationAnchor = expression + case "line-width": + lineLayer.lineWidth = expression + default: + break + } + } + } + + private class func interpretExpression(expression: String) -> NSExpression? { + do { + let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: []) + return NSExpression.init(mglJSONObject: json) + } catch { + } + return nil + } } diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index 73482bbb7..d7c279135 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -700,6 +700,22 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma guard let imageLayerId = arguments["imageLayerId"] as? String else { return } guard let layer = self.mapView.style?.layer(withIdentifier: imageLayerId) else { return } self.mapView.style?.removeLayer(layer) + case "source#add": + guard let arguments = methodCall.arguments as? [String: Any] else { return } + guard let sourceId = arguments["sourceId"] as? String else { return } + guard let geojson = arguments["geojson"] as? String else { return } + + addSource(sourceId: sourceId, geojson: geojson) + + result(nil) + case "lineLayer#add": + guard let arguments = methodCall.arguments as? [String: Any] else { return } + guard let sourceId = arguments["sourceId"] as? String else { return } + guard let layerId = arguments["layerId"] as? String else { return } + guard let properties = arguments["properties"] as? [String: String] else { return } + + addLineLayer(sourceId: sourceId, layerId: layerId, properties: properties) + result(nil) default: result(FlutterMethodNotImplemented) @@ -986,6 +1002,22 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } } + func addSource(sourceId: String, geojson: String) { + do { + let parsed = try MGLShape.init(data: geojson.data(using: .utf8)!, encoding: String.Encoding.utf8.rawValue) + let source = MGLShapeSource(identifier: sourceId, shape: parsed, options: [:]) + mapView.style?.addSource(source) + } catch { + } + } + + func addLineLayer(sourceId: String, layerId: String, properties: [String: String]) { + let source = mapView.style?.source(withIdentifier: sourceId) + let layer = MGLLineStyleLayer(identifier: layerId, source: source!) + Convert.addLineProperties(lineLayer: layer, properties: properties) + mapView.style?.addLayer(layer) + } + /* * MapboxMapOptionsSink */ diff --git a/lib/src/controller.dart b/lib/src/controller.dart index c91402d01..54610bd84 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -259,6 +259,21 @@ class MapboxMapController extends ChangeNotifier { return _mapboxGlPlatform.moveCamera(cameraUpdate); } + Future addSource(String sourceId, String geojson) async { + await _channel.invokeMethod('source#add', { + 'sourceId': sourceId, + 'geojson': geojson, + }); + } + + Future addLineLayer(String sourceId, String layerId, Map properties) async { + await _channel.invokeMethod('lineLayer#add', { + 'sourceId': sourceId, + 'layerId': layerId, + 'properties': properties + }); + } + /// Updates user location tracking mode. /// /// The returned [Future] completes after the change has been made on the From d9c6599898a98ef7ed77d928d866629bbb3a9e7f Mon Sep 17 00:00:00 2001 From: Max Buster Date: Wed, 26 Aug 2020 18:38:17 -0700 Subject: [PATCH 02/33] updates --- .../mapbox/mapboxgl/MapboxMapController.java | 6 ++--- example/ios/Podfile | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 8 +++++-- example/lib/layer.dart | 11 +++++---- example/lib/main.dart | 2 +- ios/Classes/MapboxMapController.swift | 23 +++++++++++++++++-- ios/mapbox_gl.podspec | 2 +- lib/src/controller.dart | 11 ++------- .../lib/src/mapbox_gl_platform_interface.dart | 9 ++++++++ .../lib/src/method_channel_mapbox_gl.dart | 15 ++++++++++++ pubspec.lock | 7 ++++++ 11 files changed, 72 insertions(+), 24 deletions(-) diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index 3cb928f31..c68cad4cc 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -391,7 +391,7 @@ private void addSource(String sourceName, String geojson) { FeatureCollection featureCollection = FeatureCollection.fromJson(geojson); GeoJsonSource geoJsonSource = new GeoJsonSource(sourceName, featureCollection); - mapStyle.addSource(geoJsonSource); + style.addSource(geoJsonSource); } private void addSymbolLayer(String layerName, @@ -402,7 +402,7 @@ private void addSymbolLayer(String layerName, symbolLayer.setProperties(properties); - mapStyle.addLayer(symbolLayer); + style.addLayer(symbolLayer); } private void addLineLayer(String layerName, @@ -413,7 +413,7 @@ private void addLineLayer(String layerName, lineLayer.setProperties(properties); - mapStyle.addLayer(lineLayer); + style.addLayer(lineLayer); } private void enableSymbolManager(@NonNull Style style) { diff --git a/example/ios/Podfile b/example/ios/Podfile index 4e9b84d6a..e8dcdf52f 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '9.0' +platform :ios, '10.0' use_frameworks! # CocoaPods analytics sends network stats synchronously affecting flutter build latency. diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 4de76e90b..80df58e2a 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -248,8 +248,10 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework", + "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework.dSYM", + "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/1C04753A-6715-3177-9FDA-8F75B4324E0C.bcsymbolmap", + "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/EE5140C5-686C-3DED-8916-3717EC675952.bcsymbolmap", "${BUILT_PRODUCTS_DIR}/MapboxAnnotationExtension/MapboxAnnotationExtension.framework", - "${BUILT_PRODUCTS_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework", "${BUILT_PRODUCTS_DIR}/location/location.framework", "${BUILT_PRODUCTS_DIR}/mapbox_gl/mapbox_gl.framework", "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", @@ -257,8 +259,10 @@ name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework", + "${DWARF_DSYM_FOLDER_PATH}/Mapbox.framework.dSYM", + "${BUILT_PRODUCTS_DIR}/1C04753A-6715-3177-9FDA-8F75B4324E0C.bcsymbolmap", + "${BUILT_PRODUCTS_DIR}/EE5140C5-686C-3DED-8916-3717EC675952.bcsymbolmap", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxAnnotationExtension.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/location.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/mapbox_gl.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 3fca317a8..101a76564 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:mapbox_gl_example/page.dart'; import 'package:mapbox_gl/mapbox_gl.dart'; +import 'package:mapbox_gl_example/main.dart'; +import 'package:mapbox_gl_example/page.dart'; -class LayerPage extends Page { +class LayerPage extends ExamplePage { LayerPage() : super(const Icon(Icons.share), 'Layer'); @@ -33,7 +34,7 @@ class LayerState extends State { -33.87112820031405 ], [ - 151.21770858764648, + 151.4770858764648, -33.853737857223145 ] ] @@ -56,6 +57,7 @@ class LayerState extends State { width: 300.0, height: 500.0, child: MapboxMap( + accessToken: MapsDemo.ACCESS_TOKEN, onMapCreated: _onMapCreated, onStyleLoadedCallback: _onStyleLoadedCallback, initialCameraPosition: CameraPosition( @@ -76,8 +78,7 @@ class LayerState extends State { void _onStyleLoadedCallback() { controller.addSource("source_1", geojson); controller.addLineLayer("source_1", "layer_1", { - 'line-color': "[\"rgb\", 171, 72, 33]", - 'line-width': "[\"to-number\", 5]" + 'line-width': "[\"interpolate\", [\"linear\"], [\"zoom\"], 15.0, 1.0, 23.0, 10.0]" }); } } \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 7ab20be1a..7cfeb7b20 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -46,7 +46,7 @@ final List _allPages = [ class MapsDemo extends StatelessWidget { //FIXME: Add your Mapbox access token here - static const String ACCESS_TOKEN = "YOUR_TOKEN_HERE"; + static const String ACCESS_TOKEN = "pk.eyJ1Ijoib3V0d2F5LWFkbWluIiwiYSI6ImNrMnRxYnQ3bzFlNTEzbXVpNXIxZG00dG0ifQ.jt1gMJMirDNJneqN3G1O8w"; void _pushPage(BuildContext context, ExamplePage page) async { if (!kIsWeb) { diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index d7c279135..e826a5010 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -31,7 +31,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma init(withFrame frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?, registrar: FlutterPluginRegistrar) { if let args = args as? [String: Any] { - if let token = args["accessToken"] as? String { + if let token = args["accessToken"] as? String? { MGLAccountManager.accessToken = token } } @@ -971,7 +971,26 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } } } - + + func addSource(sourceId: String, geojson: String) { + do { + let parsed = try MGLShape.init(data: geojson.data(using: .utf8)!, encoding: String.Encoding.utf8.rawValue) + let source = MGLShapeSource(identifier: sourceId, shape: parsed, options: [:]) + mapView.style?.addSource(source) + } catch { + } + } + + func addLineLayer(sourceId: String, layerId: String, properties: [String: String]) { + if let style = mapView.style { + if let source = style.source(withIdentifier: sourceId) { + let layer = MGLLineStyleLayer(identifier: layerId, source: source) + Convert.addLineProperties(lineLayer: layer, properties: properties) + style.addLayer(layer) + } + } + } + func mapViewDidBecomeIdle(_ mapView: MGLMapView) { if let channel = channel { channel.invokeMethod("map#onIdle", arguments: []); diff --git a/ios/mapbox_gl.podspec b/ios/mapbox_gl.podspec index c4f46d333..c64e3879e 100644 --- a/ios/mapbox_gl.podspec +++ b/ios/mapbox_gl.podspec @@ -18,6 +18,6 @@ A new Flutter plugin. s.dependency 'MapboxAnnotationExtension', '~> 0.0.1-beta.1' s.dependency 'Mapbox-iOS-SDK', '~> 6.3.0' s.swift_version = '4.2' - s.ios.deployment_target = '9.0' + s.ios.deployment_target = '12.0' end diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 54610bd84..c89b10d66 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -260,18 +260,11 @@ class MapboxMapController extends ChangeNotifier { } Future addSource(String sourceId, String geojson) async { - await _channel.invokeMethod('source#add', { - 'sourceId': sourceId, - 'geojson': geojson, - }); + await MapboxGlPlatform.getInstance(_id).addSource(sourceId, geojson); } Future addLineLayer(String sourceId, String layerId, Map properties) async { - await _channel.invokeMethod('lineLayer#add', { - 'sourceId': sourceId, - 'layerId': layerId, - 'properties': properties - }); + await MapboxGlPlatform.getInstance(_id).addLineLayer(sourceId, layerId, properties); } /// Updates user location tracking mode. diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index 42bd76a95..66b2632b5 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -278,4 +278,13 @@ abstract class MapboxGlPlatform { throw UnimplementedError( 'getMetersPerPixelAtLatitude() has not been implemented.'); } + Future addSource(String sourceId, String geojson) async { + throw UnimplementedError( + 'setSymbolTextIgnorePlacement() has not been implemented.'); + } + + Future addLineLayer(String sourceId, String layerId, Map properties) async { + throw UnimplementedError( + 'setSymbolTextIgnorePlacement() has not been implemented.'); + } } diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index 5cc04f8dd..cc8255821 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -719,4 +719,19 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { return new Future.error(e); } } + Future addSource(String sourceId, String geojson) async { + await _channel.invokeMethod('source#add', { + 'sourceId': sourceId, + 'geojson': geojson, + }); + } + + @override + Future addLineLayer(String sourceId, String layerId, Map properties) async { + await _channel.invokeMethod('lineLayer#add', { + 'sourceId': sourceId, + 'layerId': layerId, + 'properties': properties + }); + } } diff --git a/pubspec.lock b/pubspec.lock index 6307528c2..fdedccae0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -22,6 +22,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" crypto: dependency: transitive description: From a4b167f1ac748a0911189f8c217881c621798c06 Mon Sep 17 00:00:00 2001 From: Max Buster Date: Mon, 7 Sep 2020 10:19:32 -0700 Subject: [PATCH 03/33] Changes --- example/ios/Runner.xcodeproj/project.pbxproj | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 80df58e2a..2b34efff2 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -249,9 +249,12 @@ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework", "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework.dSYM", - "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/1C04753A-6715-3177-9FDA-8F75B4324E0C.bcsymbolmap", - "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/EE5140C5-686C-3DED-8916-3717EC675952.bcsymbolmap", + "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/4794199C-B164-3A2D-A3B4-553B7D49EDD5.bcsymbolmap", + "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/097AD13C-9FDA-310F-8B76-64CB67B06A27.bcsymbolmap", + "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/491A77E9-7DBC-3309-A93C-BADAE0DDBC6E.bcsymbolmap", + "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/3F114CA8-302D-327F-87C3-670E0EC63C9A.bcsymbolmap", "${BUILT_PRODUCTS_DIR}/MapboxAnnotationExtension/MapboxAnnotationExtension.framework", + "${BUILT_PRODUCTS_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework", "${BUILT_PRODUCTS_DIR}/location/location.framework", "${BUILT_PRODUCTS_DIR}/mapbox_gl/mapbox_gl.framework", "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", @@ -260,9 +263,12 @@ outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework", "${DWARF_DSYM_FOLDER_PATH}/Mapbox.framework.dSYM", - "${BUILT_PRODUCTS_DIR}/1C04753A-6715-3177-9FDA-8F75B4324E0C.bcsymbolmap", - "${BUILT_PRODUCTS_DIR}/EE5140C5-686C-3DED-8916-3717EC675952.bcsymbolmap", + "${BUILT_PRODUCTS_DIR}/4794199C-B164-3A2D-A3B4-553B7D49EDD5.bcsymbolmap", + "${BUILT_PRODUCTS_DIR}/097AD13C-9FDA-310F-8B76-64CB67B06A27.bcsymbolmap", + "${BUILT_PRODUCTS_DIR}/491A77E9-7DBC-3309-A93C-BADAE0DDBC6E.bcsymbolmap", + "${BUILT_PRODUCTS_DIR}/3F114CA8-302D-327F-87C3-670E0EC63C9A.bcsymbolmap", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxAnnotationExtension.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/location.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/mapbox_gl.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", From bad73b379100290fa55bd6fce88a5fa0293a34aa Mon Sep 17 00:00:00 2001 From: Max Buster Date: Mon, 7 Sep 2020 19:26:28 -0700 Subject: [PATCH 04/33] added symbol layer to ios --- example/ios/Flutter/.last_build_id | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 15 +++++-------- ios/Classes/MapboxMapController.swift | 22 +++++++++++++++++++ lib/src/controller.dart | 4 ++++ .../lib/src/mapbox_gl_platform_interface.dart | 5 +++++ .../lib/src/method_channel_mapbox_gl.dart | 9 ++++++++ 6 files changed, 46 insertions(+), 11 deletions(-) diff --git a/example/ios/Flutter/.last_build_id b/example/ios/Flutter/.last_build_id index 8b03e2375..1345a4034 100644 --- a/example/ios/Flutter/.last_build_id +++ b/example/ios/Flutter/.last_build_id @@ -1 +1 @@ -f3c426b614f84ca0c48298bfc9934d56 \ No newline at end of file +03fcf93a7807ed5ca7e1593e013555e0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 2b34efff2..2c4ace91c 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -247,14 +247,12 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${PODS_ROOT}/../.symlinks/flutter/ios-release/Flutter.framework", "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework", "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework.dSYM", - "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/4794199C-B164-3A2D-A3B4-553B7D49EDD5.bcsymbolmap", - "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/097AD13C-9FDA-310F-8B76-64CB67B06A27.bcsymbolmap", - "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/491A77E9-7DBC-3309-A93C-BADAE0DDBC6E.bcsymbolmap", - "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/3F114CA8-302D-327F-87C3-670E0EC63C9A.bcsymbolmap", + "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/1C04753A-6715-3177-9FDA-8F75B4324E0C.bcsymbolmap", + "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/EE5140C5-686C-3DED-8916-3717EC675952.bcsymbolmap", "${BUILT_PRODUCTS_DIR}/MapboxAnnotationExtension/MapboxAnnotationExtension.framework", - "${BUILT_PRODUCTS_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework", "${BUILT_PRODUCTS_DIR}/location/location.framework", "${BUILT_PRODUCTS_DIR}/mapbox_gl/mapbox_gl.framework", "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", @@ -263,12 +261,9 @@ outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework", "${DWARF_DSYM_FOLDER_PATH}/Mapbox.framework.dSYM", - "${BUILT_PRODUCTS_DIR}/4794199C-B164-3A2D-A3B4-553B7D49EDD5.bcsymbolmap", - "${BUILT_PRODUCTS_DIR}/097AD13C-9FDA-310F-8B76-64CB67B06A27.bcsymbolmap", - "${BUILT_PRODUCTS_DIR}/491A77E9-7DBC-3309-A93C-BADAE0DDBC6E.bcsymbolmap", - "${BUILT_PRODUCTS_DIR}/3F114CA8-302D-327F-87C3-670E0EC63C9A.bcsymbolmap", + "${BUILT_PRODUCTS_DIR}/1C04753A-6715-3177-9FDA-8F75B4324E0C.bcsymbolmap", + "${BUILT_PRODUCTS_DIR}/EE5140C5-686C-3DED-8916-3717EC675952.bcsymbolmap", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxAnnotationExtension.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/location.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/mapbox_gl.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index e826a5010..be39145a9 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -499,6 +499,18 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma removeAllForController(controller:lineAnnotationController, ids:ids) result(nil) + case "symbolLayer#add": + guard let arguments = methodCall.arguments as? [String: Any] else { return } + guard let sourceId = arguments["sourceId"] as? String else { return } + guard let layerId = arguments["layerId"] as? String else { return } + guard let properties = arguments["properties"] as? [String: String] else { return } + + addSymbolLayer(sourceId: sourceId, layerId: layerId, properties: properties) + case "lineLayer#add": + guard let arguments = methodCall.arguments as? [String: Any] else { return } + guard let sourceId = arguments["sourceId"] as? String else { return } + guard let layerId = arguments["layerId"] as? String else { return } + guard let properties = arguments["properties"] as? [String: String] else { return } case "line#getGeometry": guard let lineAnnotationController = lineAnnotationController else { return } @@ -981,6 +993,16 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } } + func addSymbolLayer(sourceId: String, layerId: String, properties: [String: String]) { + if let style = mapView.style { + if let source = style.source(withIdentifier: sourceId) { + let layer = MGLSymbolStyleLayer(identifier: layerId, source: source) + Convert.addSymbolProperties(symbolLayer: layer, properties: properties) + style.addLayer(layer) + } + } + } + func addLineLayer(sourceId: String, layerId: String, properties: [String: String]) { if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { diff --git a/lib/src/controller.dart b/lib/src/controller.dart index c89b10d66..04a792ca9 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -263,6 +263,10 @@ class MapboxMapController extends ChangeNotifier { await MapboxGlPlatform.getInstance(_id).addSource(sourceId, geojson); } + Future addSymbolLayer(String sourceId, String layerId, Map properties) async { + await MapboxGlPlatform.getInstance(_id).addSymbolLayer(sourceId, layerId, properties); + } + Future addLineLayer(String sourceId, String layerId, Map properties) async { await MapboxGlPlatform.getInstance(_id).addLineLayer(sourceId, layerId, properties); } diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index 66b2632b5..54c7bcc40 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -283,6 +283,11 @@ abstract class MapboxGlPlatform { 'setSymbolTextIgnorePlacement() has not been implemented.'); } + Future addSymbolLayer(String sourceId, String layerId, Map properties) async { + throw UnimplementedError( + 'setSymbolTextIgnorePlacement() has not been implemented.'); + } + Future addLineLayer(String sourceId, String layerId, Map properties) async { throw UnimplementedError( 'setSymbolTextIgnorePlacement() has not been implemented.'); diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index cc8255821..4aa583510 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -726,6 +726,15 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { }); } + @override + Future addSymbolLayer(String sourceId, String layerId, Map properties) async { + await _channel.invokeMethod('symbolLayer#add', { + 'sourceId': sourceId, + 'layerId': layerId, + 'properties': properties + }); + } + @override Future addLineLayer(String sourceId, String layerId, Map properties) async { await _channel.invokeMethod('lineLayer#add', { From f61797a921f4d3f317d4670d16b8ae5396480539 Mon Sep 17 00:00:00 2001 From: Max Buster Date: Wed, 10 Jun 2020 22:26:18 -0700 Subject: [PATCH 05/33] example code gen with mustache --- .../mapboxgl/LayerPropertyConverter.java | 83 + scripts/.dart_tool/package_config.json | 26 + scripts/input/style.json | 5806 +++++++++++++++++ scripts/lib/generate_style_converters.dart | 24 + scripts/pubspec.lock | 19 + scripts/pubspec.yaml | 11 + scripts/templates/dart_template.txt | 0 scripts/templates/java_template.txt | 37 + scripts/templates/swift_template.txt | 0 9 files changed, 6006 insertions(+) create mode 100644 android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java create mode 100644 scripts/.dart_tool/package_config.json create mode 100644 scripts/input/style.json create mode 100644 scripts/lib/generate_style_converters.dart create mode 100644 scripts/pubspec.lock create mode 100644 scripts/pubspec.yaml create mode 100644 scripts/templates/dart_template.txt create mode 100644 scripts/templates/java_template.txt create mode 100644 scripts/templates/swift_template.txt diff --git a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java new file mode 100644 index 000000000..ec8094c27 --- /dev/null +++ b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java @@ -0,0 +1,83 @@ +// This file is generated. + +package com.mapbox.mapboxgl; + +import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.PropertyFactory; +import com.mapbox.mapboxsdk.style.layers.PropertyValue; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import static com.mapbox.mapboxgl.Convert.toMap; + +class LayerPropertyConverter { + + static PropertyValue[] interpretLineLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + case "line-cap": + properties.add(PropertyFactory.lineCap(expression)); + break; + case "line-join": + properties.add(PropertyFactory.lineJoin(expression)); + break; + case "line-miter-limit": + properties.add(PropertyFactory.lineMiterLimit(expression)); + break; + case "line-round-limit": + properties.add(PropertyFactory.lineRoundLimit(expression)); + break; + case "line-sort-key": + properties.add(PropertyFactory.lineSortKey(expression)); + break; + case "visibility": + properties.add(PropertyFactory.visibility(expression)); + break; + case "line-opacity": + properties.add(PropertyFactory.lineOpacity(expression)); + break; + case "line-color": + properties.add(PropertyFactory.lineColor(expression)); + break; + case "line-translate": + properties.add(PropertyFactory.lineTranslate(expression)); + break; + case "line-translate-anchor": + properties.add(PropertyFactory.lineTranslateAnchor(expression)); + break; + case "line-width": + properties.add(PropertyFactory.lineWidth(expression)); + break; + case "line-gap-width": + properties.add(PropertyFactory.lineGapWidth(expression)); + break; + case "line-offset": + properties.add(PropertyFactory.lineOffset(expression)); + break; + case "line-blur": + properties.add(PropertyFactory.lineBlur(expression)); + break; + case "line-dasharray": + properties.add(PropertyFactory.lineDasharray(expression)); + break; + case "line-pattern": + properties.add(PropertyFactory.linePattern(expression)); + break; + case "line-gradient": + properties.add(PropertyFactory.lineGradient(expression)); + break; + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + +} \ No newline at end of file diff --git a/scripts/.dart_tool/package_config.json b/scripts/.dart_tool/package_config.json new file mode 100644 index 000000000..b2ad6f247 --- /dev/null +++ b/scripts/.dart_tool/package_config.json @@ -0,0 +1,26 @@ +{ + "configVersion": 2, + "packages": [ + { + "name": "mustache", + "rootUri": "file:///Users/max/.pub-cache/hosted/pub.dartlang.org/mustache-1.1.1", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "recase", + "rootUri": "file:///Users/max/.pub-cache/hosted/pub.dartlang.org/recase-3.0.0", + "packageUri": "lib/", + "languageVersion": "2.6" + }, + { + "name": "mapbox_code_gen", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.0" + } + ], + "generated": "2020-06-10T15:23:39.710811Z", + "generator": "pub", + "generatorVersion": "2.8.4" +} diff --git a/scripts/input/style.json b/scripts/input/style.json new file mode 100644 index 000000000..f04cf74c7 --- /dev/null +++ b/scripts/input/style.json @@ -0,0 +1,5806 @@ +{ + "$version":8, + "$root":{ + "version":{ + "required":true, + "type":"enum", + "values":[ + 8 + ], + "doc":"Style specification version number. Must be 8.", + "example":8 + }, + "name":{ + "type":"string", + "doc":"A human-readable name for the style.", + "example":"Bright" + }, + "metadata":{ + "type":"*", + "doc":"Arbitrary properties useful to track with the stylesheet, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'mapbox:'." + }, + "center":{ + "type":"array", + "value":"number", + "doc":"Default map center in longitude and latitude. The style center will be used only if the map has not been positioned by other means (e.g. map options or user interaction).", + "example":[ + -73.9749, + 40.7736 + ] + }, + "zoom":{ + "type":"number", + "doc":"Default zoom level. The style zoom will be used only if the map has not been positioned by other means (e.g. map options or user interaction).", + "example":12.5 + }, + "bearing":{ + "type":"number", + "default":0, + "period":360, + "units":"degrees", + "doc":"Default bearing, in degrees. The bearing is the compass direction that is \"up\"; for example, a bearing of 90° orients the map so that east is up. This value will be used only if the map has not been positioned by other means (e.g. map options or user interaction).", + "example":29 + }, + "pitch":{ + "type":"number", + "default":0, + "units":"degrees", + "doc":"Default pitch, in degrees. Zero is perpendicular to the surface, for a look straight down at the map, while a greater value like 60 looks ahead towards the horizon. The style pitch will be used only if the map has not been positioned by other means (e.g. map options or user interaction).", + "example":50 + }, + "light":{ + "type":"light", + "doc":"The global light source.", + "example":{ + "anchor":"viewport", + "color":"white", + "intensity":0.4 + } + }, + "sources":{ + "required":true, + "type":"sources", + "doc":"Data source specifications.", + "example":{ + "mapbox-streets":{ + "type":"vector", + "url":"mapbox://mapbox.mapbox-streets-v6" + } + } + }, + "sprite":{ + "type":"string", + "doc":"A base URL for retrieving the sprite image and metadata. The extensions `.png`, `.json` and scale factor `@2x.png` will be automatically appended. This property is required if any layer uses the `background-pattern`, `fill-pattern`, `line-pattern`, `fill-extrusion-pattern`, or `icon-image` properties. The URL must be absolute, containing the [scheme, authority and path components](https://en.wikipedia.org/wiki/URL#Syntax).", + "example":"mapbox://sprites/mapbox/bright-v8" + }, + "glyphs":{ + "type":"string", + "doc":"A URL template for loading signed-distance-field glyph sets in PBF format. The URL must include `{fontstack}` and `{range}` tokens. This property is required if any layer uses the `text-field` layout property. The URL must be absolute, containing the [scheme, authority and path components](https://en.wikipedia.org/wiki/URL#Syntax).", + "example":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf" + }, + "transition":{ + "type":"transition", + "doc":"A global transition definition to use as a default across properties, to be used for timing transitions between one value and the next when no property-specific transition is set. Collision-based symbol fading is controlled independently of the style's `transition` property.", + "example":{ + "duration":300, + "delay":0 + } + }, + "layers":{ + "required":true, + "type":"array", + "value":"layer", + "doc":"Layers will be drawn in the order of this array.", + "example":[ + { + "id":"water", + "source":"mapbox-streets", + "source-layer":"water", + "type":"fill", + "paint":{ + "fill-color":"#00ffff" + } + } + ] + } + }, + "sources":{ + "*":{ + "type":"source", + "doc":"Specification of a data source. For vector and raster sources, either TileJSON or a URL to a TileJSON must be provided. For image and video sources, a URL must be provided. For GeoJSON sources, a URL or inline GeoJSON must be provided." + } + }, + "source":[ + "source_vector", + "source_raster", + "source_raster_dem", + "source_geojson", + "source_video", + "source_image" + ], + "source_vector":{ + "type":{ + "required":true, + "type":"enum", + "values":{ + "vector":{ + "doc":"A vector tile source." + } + }, + "doc":"The type of the source." + }, + "url":{ + "type":"string", + "doc":"A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://`." + }, + "tiles":{ + "type":"array", + "value":"string", + "doc":"An array of one or more tile source URLs, as in the TileJSON spec." + }, + "bounds":{ + "type":"array", + "value":"number", + "length":4, + "default":[ + -180, + -85.051129, + 180, + 85.051129 + ], + "doc":"An array containing the longitude and latitude of the southwest and northeast corners of the source's bounding box in the following order: `[sw.lng, sw.lat, ne.lng, ne.lat]`. When this property is included in a source, no tiles outside of the given bounds are requested by Mapbox GL." + }, + "scheme":{ + "type":"enum", + "values":{ + "xyz":{ + "doc":"Slippy map tilenames scheme." + }, + "tms":{ + "doc":"OSGeo spec scheme." + } + }, + "default":"xyz", + "doc":"Influences the y direction of the tile coordinates. The global-mercator (aka Spherical Mercator) profile is assumed." + }, + "minzoom":{ + "type":"number", + "default":0, + "doc":"Minimum zoom level for which tiles are available, as in the TileJSON spec." + }, + "maxzoom":{ + "type":"number", + "default":22, + "doc":"Maximum zoom level for which tiles are available, as in the TileJSON spec. Data from tiles at the maxzoom are used when displaying the map at higher zoom levels." + }, + "attribution":{ + "type":"string", + "doc":"Contains an attribution to be displayed when the map is shown to a user." + }, + "promoteId":{ + "type":"promoteId", + "doc":"A property to use as a feature id (for feature state). Either a property name, or an object of the form `{: }`. If specified as a string for a vector tile source, the same property is used across all its source layers." + }, + "*":{ + "type":"*", + "doc":"Other keys to configure the data source." + } + }, + "source_raster":{ + "type":{ + "required":true, + "type":"enum", + "values":{ + "raster":{ + "doc":"A raster tile source." + } + }, + "doc":"The type of the source." + }, + "url":{ + "type":"string", + "doc":"A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://`." + }, + "tiles":{ + "type":"array", + "value":"string", + "doc":"An array of one or more tile source URLs, as in the TileJSON spec." + }, + "bounds":{ + "type":"array", + "value":"number", + "length":4, + "default":[ + -180, + -85.051129, + 180, + 85.051129 + ], + "doc":"An array containing the longitude and latitude of the southwest and northeast corners of the source's bounding box in the following order: `[sw.lng, sw.lat, ne.lng, ne.lat]`. When this property is included in a source, no tiles outside of the given bounds are requested by Mapbox GL." + }, + "minzoom":{ + "type":"number", + "default":0, + "doc":"Minimum zoom level for which tiles are available, as in the TileJSON spec." + }, + "maxzoom":{ + "type":"number", + "default":22, + "doc":"Maximum zoom level for which tiles are available, as in the TileJSON spec. Data from tiles at the maxzoom are used when displaying the map at higher zoom levels." + }, + "tileSize":{ + "type":"number", + "default":512, + "units":"pixels", + "doc":"The minimum visual size to display tiles for this layer. Only configurable for raster layers." + }, + "scheme":{ + "type":"enum", + "values":{ + "xyz":{ + "doc":"Slippy map tilenames scheme." + }, + "tms":{ + "doc":"OSGeo spec scheme." + } + }, + "default":"xyz", + "doc":"Influences the y direction of the tile coordinates. The global-mercator (aka Spherical Mercator) profile is assumed." + }, + "attribution":{ + "type":"string", + "doc":"Contains an attribution to be displayed when the map is shown to a user." + }, + "*":{ + "type":"*", + "doc":"Other keys to configure the data source." + } + }, + "source_raster_dem":{ + "type":{ + "required":true, + "type":"enum", + "values":{ + "raster-dem":{ + "doc":"A RGB-encoded raster DEM source" + } + }, + "doc":"The type of the source." + }, + "url":{ + "type":"string", + "doc":"A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://`." + }, + "tiles":{ + "type":"array", + "value":"string", + "doc":"An array of one or more tile source URLs, as in the TileJSON spec." + }, + "bounds":{ + "type":"array", + "value":"number", + "length":4, + "default":[ + -180, + -85.051129, + 180, + 85.051129 + ], + "doc":"An array containing the longitude and latitude of the southwest and northeast corners of the source's bounding box in the following order: `[sw.lng, sw.lat, ne.lng, ne.lat]`. When this property is included in a source, no tiles outside of the given bounds are requested by Mapbox GL." + }, + "minzoom":{ + "type":"number", + "default":0, + "doc":"Minimum zoom level for which tiles are available, as in the TileJSON spec." + }, + "maxzoom":{ + "type":"number", + "default":22, + "doc":"Maximum zoom level for which tiles are available, as in the TileJSON spec. Data from tiles at the maxzoom are used when displaying the map at higher zoom levels." + }, + "tileSize":{ + "type":"number", + "default":512, + "units":"pixels", + "doc":"The minimum visual size to display tiles for this layer. Only configurable for raster layers." + }, + "attribution":{ + "type":"string", + "doc":"Contains an attribution to be displayed when the map is shown to a user." + }, + "encoding":{ + "type":"enum", + "values":{ + "terrarium":{ + "doc":"Terrarium format PNG tiles. See https://aws.amazon.com/es/public-datasets/terrain/ for more info." + }, + "mapbox":{ + "doc":"Mapbox Terrain RGB tiles. See https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb for more info." + } + }, + "default":"mapbox", + "doc":"The encoding used by this source. Mapbox Terrain RGB is used by default" + }, + "*":{ + "type":"*", + "doc":"Other keys to configure the data source." + } + }, + "source_geojson":{ + "type":{ + "required":true, + "type":"enum", + "values":{ + "geojson":{ + "doc":"A GeoJSON data source." + } + }, + "doc":"The data type of the GeoJSON source." + }, + "data":{ + "type":"*", + "doc":"A URL to a GeoJSON file, or inline GeoJSON." + }, + "maxzoom":{ + "type":"number", + "default":18, + "doc":"Maximum zoom level at which to create vector tiles (higher means greater detail at high zoom levels)." + }, + "attribution":{ + "type":"string", + "doc":"Contains an attribution to be displayed when the map is shown to a user." + }, + "buffer":{ + "type":"number", + "default":128, + "maximum":512, + "minimum":0, + "doc":"Size of the tile buffer on each side. A value of 0 produces no buffer. A value of 512 produces a buffer as wide as the tile itself. Larger values produce fewer rendering artifacts near tile edges and slower performance." + }, + "tolerance":{ + "type":"number", + "default":0.375, + "doc":"Douglas-Peucker simplification tolerance (higher means simpler geometries and faster performance)." + }, + "cluster":{ + "type":"boolean", + "default":false, + "doc":"If the data is a collection of point features, setting this to true clusters the points by radius into groups. Cluster groups become new `Point` features in the source with additional properties:\n * `cluster` Is `true` if the point is a cluster \n * `cluster_id` A unqiue id for the cluster to be used in conjunction with the [cluster inspection methods](https://www.mapbox.com/mapbox-gl-js/api/#geojsonsource#getclusterexpansionzoom)\n * `point_count` Number of original points grouped into this cluster\n * `point_count_abbreviated` An abbreviated point count" + }, + "clusterRadius":{ + "type":"number", + "default":50, + "minimum":0, + "doc":"Radius of each cluster if clustering is enabled. A value of 512 indicates a radius equal to the width of a tile." + }, + "clusterMaxZoom":{ + "type":"number", + "doc":"Max zoom on which to cluster points if clustering is enabled. Defaults to one zoom less than maxzoom (so that last zoom features are not clustered)." + }, + "clusterProperties":{ + "type":"*", + "doc":"An object defining custom properties on the generated clusters if clustering is enabled, aggregating values from clustered points. Has the form `{\"property_name\": [operator, map_expression]}`. `operator` is any expression function that accepts at least 2 operands (e.g. `\"+\"` or `\"max\"`) — it accumulates the property value from clusters/points the cluster contains; `map_expression` produces the value of a single point.\n\nExample: `{\"sum\": [\"+\", [\"get\", \"scalerank\"]]}`.\n\nFor more advanced use cases, in place of `operator`, you can use a custom reduce expression that references a special `[\"accumulated\"]` value, e.g.:\n`{\"sum\": [[\"+\", [\"accumulated\"], [\"get\", \"sum\"]], [\"get\", \"scalerank\"]]}`" + }, + "lineMetrics":{ + "type":"boolean", + "default":false, + "doc":"Whether to calculate line distance metrics. This is required for line layers that specify `line-gradient` values." + }, + "generateId":{ + "type":"boolean", + "default":false, + "doc":"Whether to generate ids for the geojson features. When enabled, the `feature.id` property will be auto assigned based on its index in the `features` array, over-writing any previous values." + }, + "promoteId":{ + "type":"promoteId", + "doc":"A property to use as a feature id (for feature state). Either a property name, or an object of the form `{: }`." + } + }, + "source_video":{ + "type":{ + "required":true, + "type":"enum", + "values":{ + "video":{ + "doc":"A video data source." + } + }, + "doc":"The data type of the video source." + }, + "urls":{ + "required":true, + "type":"array", + "value":"string", + "doc":"URLs to video content in order of preferred format." + }, + "coordinates":{ + "required":true, + "doc":"Corners of video specified in longitude, latitude pairs.", + "type":"array", + "length":4, + "value":{ + "type":"array", + "length":2, + "value":"number", + "doc":"A single longitude, latitude pair." + } + } + }, + "source_image":{ + "type":{ + "required":true, + "type":"enum", + "values":{ + "image":{ + "doc":"An image data source." + } + }, + "doc":"The data type of the image source." + }, + "url":{ + "required":true, + "type":"string", + "doc":"URL that points to an image." + }, + "coordinates":{ + "required":true, + "doc":"Corners of image specified in longitude, latitude pairs.", + "type":"array", + "length":4, + "value":{ + "type":"array", + "length":2, + "value":"number", + "doc":"A single longitude, latitude pair." + } + } + }, + "layer":{ + "id":{ + "type":"string", + "doc":"Unique layer name.", + "required":true + }, + "type":{ + "type":"enum", + "values":{ + "fill":{ + "doc":"A filled polygon with an optional stroked border.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + } + }, + "line":{ + "doc":"A stroked line.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + } + }, + "symbol":{ + "doc":"An icon or a text label.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + } + }, + "circle":{ + "doc":"A filled circle.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + } + }, + "heatmap":{ + "doc":"A heatmap.", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "fill-extrusion":{ + "doc":"An extruded (3D) polygon.", + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + } + }, + "raster":{ + "doc":"Raster map textures such as satellite imagery.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + } + }, + "hillshade":{ + "doc":"Client-side hillshading visualization based on DEM data. Currently, the implementation only supports Mapbox Terrain RGB and Mapzen Terrarium tiles.", + "sdk-support":{ + "basic functionality":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "background":{ + "doc":"The background color or pattern of the map.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + } + } + }, + "doc":"Rendering type of this layer.", + "required":true + }, + "metadata":{ + "type":"*", + "doc":"Arbitrary properties useful to track with the layer, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'mapbox:'." + }, + "source":{ + "type":"string", + "doc":"Name of a source description to be used for this layer. Required for all layer types except `background`." + }, + "source-layer":{ + "type":"string", + "doc":"Layer to use from a vector tile source. Required for vector tile sources; prohibited for all other source types, including GeoJSON sources." + }, + "minzoom":{ + "type":"number", + "minimum":0, + "maximum":24, + "doc":"The minimum zoom level for the layer. At zoom levels less than the minzoom, the layer will be hidden." + }, + "maxzoom":{ + "type":"number", + "minimum":0, + "maximum":24, + "doc":"The maximum zoom level for the layer. At zoom levels equal to or greater than the maxzoom, the layer will be hidden." + }, + "filter":{ + "type":"filter", + "doc":"A expression specifying conditions on source features. Only features that match the filter are displayed. Zoom expressions in filters are only evaluated at integer zoom levels. The `feature-state` expression is not supported in filter expressions." + }, + "layout":{ + "type":"layout", + "doc":"Layout properties for the layer." + }, + "paint":{ + "type":"paint", + "doc":"Default paint properties for this layer." + } + }, + "layout":[ + "layout_fill", + "layout_line", + "layout_circle", + "layout_heatmap", + "layout_fill-extrusion", + "layout_symbol", + "layout_raster", + "layout_hillshade", + "layout_background" + ], + "layout_background":{ + "visibility":{ + "type":"enum", + "values":{ + "visible":{ + "doc":"The layer is shown." + }, + "none":{ + "doc":"The layer is not shown." + } + }, + "default":"visible", + "doc":"Whether this layer is displayed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "property-type":"constant" + } + }, + "layout_fill":{ + "fill-sort-key":{ + "type":"number", + "doc":"Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.", + "sdk-support":{ + "basic functionality":{ + "js":"1.2.0" + }, + "data-driven styling":{ + "js":"1.2.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "visibility":{ + "type":"enum", + "values":{ + "visible":{ + "doc":"The layer is shown." + }, + "none":{ + "doc":"The layer is not shown." + } + }, + "default":"visible", + "doc":"Whether this layer is displayed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "property-type":"constant" + } + }, + "layout_circle":{ + "circle-sort-key":{ + "type":"number", + "doc":"Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.", + "sdk-support":{ + "basic functionality":{ + "js":"1.2.0" + }, + "data-driven styling":{ + "js":"1.2.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "visibility":{ + "type":"enum", + "values":{ + "visible":{ + "doc":"The layer is shown." + }, + "none":{ + "doc":"The layer is not shown." + } + }, + "default":"visible", + "doc":"Whether this layer is displayed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "property-type":"constant" + } + }, + "layout_heatmap":{ + "visibility":{ + "type":"enum", + "values":{ + "visible":{ + "doc":"The layer is shown." + }, + "none":{ + "doc":"The layer is not shown." + } + }, + "default":"visible", + "doc":"Whether this layer is displayed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "property-type":"constant" + } + }, + "layout_fill-extrusion":{ + "visibility":{ + "type":"enum", + "values":{ + "visible":{ + "doc":"The layer is shown." + }, + "none":{ + "doc":"The layer is not shown." + } + }, + "default":"visible", + "doc":"Whether this layer is displayed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "property-type":"constant" + } + }, + "layout_line":{ + "line-cap":{ + "type":"enum", + "values":{ + "butt":{ + "doc":"A cap with a squared-off end which is drawn to the exact endpoint of the line." + }, + "round":{ + "doc":"A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line." + }, + "square":{ + "doc":"A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width." + } + }, + "default":"butt", + "doc":"The display of line endings.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "line-join":{ + "type":"enum", + "values":{ + "bevel":{ + "doc":"A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width." + }, + "round":{ + "doc":"A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line." + }, + "miter":{ + "doc":"A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet." + } + }, + "default":"miter", + "doc":"The display of lines when joining.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.40.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "line-miter-limit":{ + "type":"number", + "default":2, + "doc":"Used to automatically convert miter joins to bevel joins for sharp angles.", + "requires":[ + { + "line-join":"miter" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "line-round-limit":{ + "type":"number", + "default":1.05, + "doc":"Used to automatically convert round joins to miter joins for shallow angles.", + "requires":[ + { + "line-join":"round" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "line-sort-key":{ + "type":"number", + "doc":"Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.", + "sdk-support":{ + "basic functionality":{ + "js":"1.2.0" + }, + "data-driven styling":{ + "js":"1.2.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "visibility":{ + "type":"enum", + "values":{ + "visible":{ + "doc":"The layer is shown." + }, + "none":{ + "doc":"The layer is not shown." + } + }, + "default":"visible", + "doc":"Whether this layer is displayed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "property-type":"constant" + } + }, + "layout_symbol":{ + "symbol-placement":{ + "type":"enum", + "values":{ + "point":{ + "doc":"The label is placed at the point where the geometry is located." + }, + "line":{ + "doc":"The label is placed along the line of the geometry. Can only be used on `LineString` and `Polygon` geometries." + }, + "line-center":{ + "doc":"The label is placed at the center of the line of the geometry. Can only be used on `LineString` and `Polygon` geometries. Note that a single feature in a vector tile may contain multiple line geometries." + } + }, + "default":"point", + "doc":"Label placement relative to its geometry.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "`line-center` value":{ + "js":"0.47.0", + "android":"6.4.0", + "ios":"4.3.0", + "macos":"0.10.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "symbol-spacing":{ + "type":"number", + "default":250, + "minimum":1, + "units":"pixels", + "doc":"Distance between two symbol anchors.", + "requires":[ + { + "symbol-placement":"line" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "symbol-avoid-edges":{ + "type":"boolean", + "default":false, + "doc":"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. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "symbol-sort-key":{ + "type":"number", + "doc":"Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When `icon-allow-overlap` or `text-allow-overlap` is `false`, features with a lower sort key will have priority during placement. When `icon-allow-overlap` or `text-allow-overlap` is set to `true`, features with a higher sort key will overlap over features with a lower sort key.", + "sdk-support":{ + "basic functionality":{ + "js":"0.53.0", + "android":"7.4.0", + "ios":"4.11.0", + "macos":"0.14.0" + }, + "data-driven styling":{ + "js":"0.53.0", + "android":"7.4.0", + "ios":"4.11.0", + "macos":"0.14.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "symbol-z-order":{ + "type":"enum", + "values":{ + "auto":{ + "doc":"If `symbol-sort-key` is set, sort based on that. Otherwise sort symbols by their y-position relative to the viewport." + }, + "viewport-y":{ + "doc":"Symbols will be sorted by their y-position relative to the viewport." + }, + "source":{ + "doc":"Symbols will be rendered in the same order as the source data with no sorting applied." + } + }, + "default":"auto", + "doc":"Controls the order in which overlapping symbols in the same layer are rendered", + "sdk-support":{ + "basic functionality":{ + "js":"0.49.0", + "android":"6.6.0", + "ios":"4.5.0", + "macos":"0.12.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-allow-overlap":{ + "type":"boolean", + "default":false, + "doc":"If true, the icon will be visible even if it collides with other previously drawn symbols.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-ignore-placement":{ + "type":"boolean", + "default":false, + "doc":"If true, other symbols can be visible even if they collide with the icon.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-optional":{ + "type":"boolean", + "default":false, + "doc":"If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not.", + "requires":[ + "icon-image", + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-rotation-alignment":{ + "type":"enum", + "values":{ + "map":{ + "doc":"When `symbol-placement` is set to `point`, aligns icons east-west. When `symbol-placement` is set to `line` or `line-center`, aligns icon x-axes with the line." + }, + "viewport":{ + "doc":"Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`." + }, + "auto":{ + "doc":"When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line` or `line-center`, this is equivalent to `map`." + } + }, + "default":"auto", + "doc":"In combination with `symbol-placement`, determines the rotation behavior of icons.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "`auto` value":{ + "js":"0.25.0", + "android":"4.2.0", + "ios":"3.4.0", + "macos":"0.3.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-size":{ + "type":"number", + "default":1, + "minimum":0, + "units":"factor of the original icon size", + "doc":"Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.35.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "icon-text-fit":{ + "type":"enum", + "values":{ + "none":{ + "doc":"The icon is displayed at its intrinsic aspect ratio." + }, + "width":{ + "doc":"The icon is scaled in the x-dimension to fit the width of the text." + }, + "height":{ + "doc":"The icon is scaled in the y-dimension to fit the height of the text." + }, + "both":{ + "doc":"The icon is scaled in both x- and y-dimensions." + } + }, + "default":"none", + "doc":"Scales the icon to fit around the associated text.", + "requires":[ + "icon-image", + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.21.0", + "android":"4.2.0", + "ios":"3.4.0", + "macos":"0.2.1" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-text-fit-padding":{ + "type":"array", + "value":"number", + "length":4, + "default":[ + 0, + 0, + 0, + 0 + ], + "units":"pixels", + "doc":"Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left.", + "requires":[ + "icon-image", + "text-field", + { + "icon-text-fit":[ + "both", + "width", + "height" + ] + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.21.0", + "android":"4.2.0", + "ios":"3.4.0", + "macos":"0.2.1" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-image":{ + "type":"resolvedImage", + "doc":"Name of image in sprite to use for drawing an image background.", + "tokens":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.35.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "icon-rotate":{ + "type":"number", + "default":0, + "period":360, + "units":"degrees", + "doc":"Rotates the icon clockwise.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.21.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "icon-padding":{ + "type":"number", + "default":2, + "minimum":0, + "units":"pixels", + "doc":"Size of the additional area around the icon bounding box used for detecting symbol collisions.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-keep-upright":{ + "type":"boolean", + "default":false, + "doc":"If true, the icon may be flipped to prevent it from being rendered upside-down.", + "requires":[ + "icon-image", + { + "icon-rotation-alignment":"map" + }, + { + "symbol-placement":[ + "line", + "line-center" + ] + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-offset":{ + "type":"array", + "value":"number", + "length":2, + "default":[ + 0, + 0 + ], + "doc":"Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `icon-size` to obtain the final offset in pixels. When combined with `icon-rotate` the offset will be as if the rotated direction was up.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "icon-anchor":{ + "type":"enum", + "values":{ + "center":{ + "doc":"The center of the icon is placed closest to the anchor." + }, + "left":{ + "doc":"The left side of the icon is placed closest to the anchor." + }, + "right":{ + "doc":"The right side of the icon is placed closest to the anchor." + }, + "top":{ + "doc":"The top of the icon is placed closest to the anchor." + }, + "bottom":{ + "doc":"The bottom of the icon is placed closest to the anchor." + }, + "top-left":{ + "doc":"The top left corner of the icon is placed closest to the anchor." + }, + "top-right":{ + "doc":"The top right corner of the icon is placed closest to the anchor." + }, + "bottom-left":{ + "doc":"The bottom left corner of the icon is placed closest to the anchor." + }, + "bottom-right":{ + "doc":"The bottom right corner of the icon is placed closest to the anchor." + } + }, + "default":"center", + "doc":"Part of the icon placed closest to the anchor.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.40.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + }, + "data-driven styling":{ + "js":"0.40.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "icon-pitch-alignment":{ + "type":"enum", + "values":{ + "map":{ + "doc":"The icon is aligned to the plane of the map." + }, + "viewport":{ + "doc":"The icon is aligned to the plane of the viewport." + }, + "auto":{ + "doc":"Automatically matches the value of `icon-rotation-alignment`." + } + }, + "default":"auto", + "doc":"Orientation of icon when map is pitched.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.39.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-pitch-alignment":{ + "type":"enum", + "values":{ + "map":{ + "doc":"The text is aligned to the plane of the map." + }, + "viewport":{ + "doc":"The text is aligned to the plane of the viewport." + }, + "auto":{ + "doc":"Automatically matches the value of `text-rotation-alignment`." + } + }, + "default":"auto", + "doc":"Orientation of text when map is pitched.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.21.0", + "android":"4.2.0", + "ios":"3.4.0", + "macos":"0.2.1" + }, + "`auto` value":{ + "js":"0.25.0", + "android":"4.2.0", + "ios":"3.4.0", + "macos":"0.3.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-rotation-alignment":{ + "type":"enum", + "values":{ + "map":{ + "doc":"When `symbol-placement` is set to `point`, aligns text east-west. When `symbol-placement` is set to `line` or `line-center`, aligns text x-axes with the line." + }, + "viewport":{ + "doc":"Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`." + }, + "auto":{ + "doc":"When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line` or `line-center`, this is equivalent to `map`." + } + }, + "default":"auto", + "doc":"In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "`auto` value":{ + "js":"0.25.0", + "android":"4.2.0", + "ios":"3.4.0", + "macos":"0.3.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-field":{ + "type":"formatted", + "default":"", + "tokens":true, + "doc":"Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-font":{ + "type":"array", + "value":"string", + "default":[ + "Open Sans Regular", + "Arial Unicode MS Regular" + ], + "doc":"Font stack to use for displaying text.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-size":{ + "type":"number", + "default":16, + "minimum":0, + "units":"pixels", + "doc":"Font size.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.35.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-max-width":{ + "type":"number", + "default":10, + "minimum":0, + "units":"ems", + "doc":"The maximum line width for text wrapping.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.40.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-line-height":{ + "type":"number", + "default":1.2, + "units":"ems", + "doc":"Text leading value for multi-line text.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-letter-spacing":{ + "type":"number", + "default":0, + "units":"ems", + "doc":"Text tracking amount.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.40.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-justify":{ + "type":"enum", + "values":{ + "auto":{ + "doc":"The text is aligned towards the anchor position." + }, + "left":{ + "doc":"The text is aligned to the left." + }, + "center":{ + "doc":"The text is centered." + }, + "right":{ + "doc":"The text is aligned to the right." + } + }, + "default":"center", + "doc":"Text justification options.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.39.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + }, + "auto":{ + "js":"0.54.0", + "android":"7.4.0", + "ios":"4.10.0", + "macos":"0.14.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-radial-offset":{ + "type":"number", + "units":"ems", + "default":0, + "doc":"Radial offset of text, in the direction of the symbol's anchor. Useful in combination with `text-variable-anchor`, which defaults to using the two-dimensional `text-offset` if present.", + "sdk-support":{ + "basic functionality":{ + "js":"0.54.0", + "android":"7.4.0", + "ios":"4.10.0", + "macos":"0.14.0" + }, + "data-driven styling":{ + "js":"0.54.0", + "android":"7.4.0", + "ios":"4.10.0", + "macos":"0.14.0" + } + }, + "requires":[ + "text-field" + ], + "property-type":"data-driven", + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature" + ] + } + }, + "text-variable-anchor":{ + "type":"array", + "value":"enum", + "values":{ + "center":{ + "doc":"The center of the text is placed closest to the anchor." + }, + "left":{ + "doc":"The left side of the text is placed closest to the anchor." + }, + "right":{ + "doc":"The right side of the text is placed closest to the anchor." + }, + "top":{ + "doc":"The top of the text is placed closest to the anchor." + }, + "bottom":{ + "doc":"The bottom of the text is placed closest to the anchor." + }, + "top-left":{ + "doc":"The top left corner of the text is placed closest to the anchor." + }, + "top-right":{ + "doc":"The top right corner of the text is placed closest to the anchor." + }, + "bottom-left":{ + "doc":"The bottom left corner of the text is placed closest to the anchor." + }, + "bottom-right":{ + "doc":"The bottom right corner of the text is placed closest to the anchor." + } + }, + "requires":[ + "text-field", + { + "symbol-placement":[ + "point" + ] + } + ], + "doc":"To increase the chance of placing high-priority labels on the map, you can provide an array of `text-anchor` locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the `text-radial-offset` or the two-dimensional `text-offset`.", + "sdk-support":{ + "basic functionality":{ + "js":"0.54.0", + "android":"7.4.0", + "ios":"4.10.0", + "macos":"0.14.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-anchor":{ + "type":"enum", + "values":{ + "center":{ + "doc":"The center of the text is placed closest to the anchor." + }, + "left":{ + "doc":"The left side of the text is placed closest to the anchor." + }, + "right":{ + "doc":"The right side of the text is placed closest to the anchor." + }, + "top":{ + "doc":"The top of the text is placed closest to the anchor." + }, + "bottom":{ + "doc":"The bottom of the text is placed closest to the anchor." + }, + "top-left":{ + "doc":"The top left corner of the text is placed closest to the anchor." + }, + "top-right":{ + "doc":"The top right corner of the text is placed closest to the anchor." + }, + "bottom-left":{ + "doc":"The bottom left corner of the text is placed closest to the anchor." + }, + "bottom-right":{ + "doc":"The bottom right corner of the text is placed closest to the anchor." + } + }, + "default":"center", + "doc":"Part of the text placed closest to the anchor.", + "requires":[ + "text-field", + { + "!":"text-variable-anchor" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.39.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-max-angle":{ + "type":"number", + "default":45, + "units":"degrees", + "doc":"Maximum angle change between adjacent characters.", + "requires":[ + "text-field", + { + "symbol-placement":[ + "line", + "line-center" + ] + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-writing-mode":{ + "type":"array", + "value":"enum", + "values":{ + "horizontal":{ + "doc":"If a text's language supports horizontal writing mode, symbols with point placement would be laid out horizontally." + }, + "vertical":{ + "doc":"If a text's language supports vertical writing mode, symbols with point placement would be laid out vertically." + } + }, + "doc":"The property allows control over a symbol's orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single 'vertical' enum value. The order of elements in an array define priority order for the placement of an orientation variant.", + "requires":[ + "text-field", + { + "symbol-placement":[ + "point" + ] + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"1.3.0", + "android":"8.3.0", + "ios":"5.3.0", + "macos":"0.14.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-rotate":{ + "type":"number", + "default":0, + "period":360, + "units":"degrees", + "doc":"Rotates the text clockwise.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.35.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-padding":{ + "type":"number", + "default":2, + "minimum":0, + "units":"pixels", + "doc":"Size of the additional area around the text bounding box used for detecting symbol collisions.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-keep-upright":{ + "type":"boolean", + "default":true, + "doc":"If true, the text may be flipped vertically to prevent it from being rendered upside-down.", + "requires":[ + "text-field", + { + "text-rotation-alignment":"map" + }, + { + "symbol-placement":[ + "line", + "line-center" + ] + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-transform":{ + "type":"enum", + "values":{ + "none":{ + "doc":"The text is not altered." + }, + "uppercase":{ + "doc":"Forces all letters to be displayed in uppercase." + }, + "lowercase":{ + "doc":"Forces all letters to be displayed in lowercase." + } + }, + "default":"none", + "doc":"Specifies how to capitalize text, similar to the CSS `text-transform` property.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-offset":{ + "type":"array", + "doc":"Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position.", + "value":"number", + "units":"ems", + "length":2, + "default":[ + 0, + 0 + ], + "requires":[ + "text-field", + { + "!":"text-radial-offset" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.35.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"data-driven" + }, + "text-allow-overlap":{ + "type":"boolean", + "default":false, + "doc":"If true, the text will be visible even if it collides with other previously drawn symbols.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-ignore-placement":{ + "type":"boolean", + "default":false, + "doc":"If true, other symbols can be visible even if they collide with the text.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-optional":{ + "type":"boolean", + "default":false, + "doc":"If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not.", + "requires":[ + "text-field", + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "visibility":{ + "type":"enum", + "values":{ + "visible":{ + "doc":"The layer is shown." + }, + "none":{ + "doc":"The layer is not shown." + } + }, + "default":"visible", + "doc":"Whether this layer is displayed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "property-type":"constant" + } + }, + "layout_raster":{ + "visibility":{ + "type":"enum", + "values":{ + "visible":{ + "doc":"The layer is shown." + }, + "none":{ + "doc":"The layer is not shown." + } + }, + "default":"visible", + "doc":"Whether this layer is displayed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "property-type":"constant" + } + }, + "layout_hillshade":{ + "visibility":{ + "type":"enum", + "values":{ + "visible":{ + "doc":"The layer is shown." + }, + "none":{ + "doc":"The layer is not shown." + } + }, + "default":"visible", + "doc":"Whether this layer is displayed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "property-type":"constant" + } + }, + "filter":{ + "type":"array", + "value":"*", + "doc":"A filter selects specific features from a layer." + }, + "filter_operator":{ + "type":"enum", + "values":{ + "==":{ + "doc":"`[\"==\", key, value]` equality: `feature[key] = value`" + }, + "!=":{ + "doc":"`[\"!=\", key, value]` inequality: `feature[key] ≠ value`" + }, + ">":{ + "doc":"`[\">\", key, value]` greater than: `feature[key] > value`" + }, + ">=":{ + "doc":"`[\">=\", key, value]` greater than or equal: `feature[key] ≥ value`" + }, + "<":{ + "doc":"`[\"<\", key, value]` less than: `feature[key] < value`" + }, + "<=":{ + "doc":"`[\"<=\", key, value]` less than or equal: `feature[key] ≤ value`" + }, + "in":{ + "doc":"`[\"in\", key, v0, ..., vn]` set inclusion: `feature[key] ∈ {v0, ..., vn}`" + }, + "!in":{ + "doc":"`[\"!in\", key, v0, ..., vn]` set exclusion: `feature[key] ∉ {v0, ..., vn}`" + }, + "all":{ + "doc":"`[\"all\", f0, ..., fn]` logical `AND`: `f0 ∧ ... ∧ fn`" + }, + "any":{ + "doc":"`[\"any\", f0, ..., fn]` logical `OR`: `f0 ∨ ... ∨ fn`" + }, + "none":{ + "doc":"`[\"none\", f0, ..., fn]` logical `NOR`: `¬f0 ∧ ... ∧ ¬fn`" + }, + "has":{ + "doc":"`[\"has\", key]` `feature[key]` exists" + }, + "!has":{ + "doc":"`[\"!has\", key]` `feature[key]` does not exist" + } + }, + "doc":"The filter operator." + }, + "geometry_type":{ + "type":"enum", + "values":{ + "Point":{ + "doc":"Filter to point geometries." + }, + "LineString":{ + "doc":"Filter to line geometries." + }, + "Polygon":{ + "doc":"Filter to polygon geometries." + } + }, + "doc":"The geometry type for the filter to select." + }, + "function":{ + "expression":{ + "type":"expression", + "doc":"An expression." + }, + "stops":{ + "type":"array", + "doc":"An array of stops.", + "value":"function_stop" + }, + "base":{ + "type":"number", + "default":1, + "minimum":0, + "doc":"The exponential base of the interpolation curve. It controls the rate at which the result increases. Higher values make the result increase more towards the high end of the range. With `1` the stops are interpolated linearly." + }, + "property":{ + "type":"string", + "doc":"The name of a feature property to use as the function input.", + "default":"$zoom" + }, + "type":{ + "type":"enum", + "values":{ + "identity":{ + "doc":"Return the input value as the output value." + }, + "exponential":{ + "doc":"Generate an output by interpolating between stops just less than and just greater than the function input." + }, + "interval":{ + "doc":"Return the output value of the stop just less than the function input." + }, + "categorical":{ + "doc":"Return the output value of the stop equal to the function input." + } + }, + "doc":"The interpolation strategy to use in function evaluation.", + "default":"exponential" + }, + "colorSpace":{ + "type":"enum", + "values":{ + "rgb":{ + "doc":"Use the RGB color space to interpolate color values" + }, + "lab":{ + "doc":"Use the LAB color space to interpolate color values." + }, + "hcl":{ + "doc":"Use the HCL color space to interpolate color values, interpolating the Hue, Chroma, and Luminance channels individually." + } + }, + "doc":"The color space in which colors interpolated. Interpolating colors in perceptual color spaces like LAB and HCL tend to produce color ramps that look more consistent and produce colors that can be differentiated more easily than those interpolated in RGB space.", + "default":"rgb" + }, + "default":{ + "type":"*", + "required":false, + "doc":"A value to serve as a fallback function result when a value isn't otherwise available. It is used in the following circumstances:\n* In categorical functions, when the feature value does not match any of the stop domain values.\n* In property and zoom-and-property functions, when a feature does not contain a value for the specified property.\n* In identity functions, when the feature value is not valid for the style property (for example, if the function is being used for a `circle-color` property but the feature property value is not a string or not a valid color).\n* In interval or exponential property and zoom-and-property functions, when the feature value is not numeric.\nIf no default is provided, the style property's default is used in these circumstances." + } + }, + "function_stop":{ + "type":"array", + "minimum":0, + "maximum":24, + "value":[ + "number", + "color" + ], + "length":2, + "doc":"Zoom level and value pair." + }, + "expression":{ + "type":"array", + "value":"*", + "minimum":1, + "doc":"An expression defines a function that can be used for data-driven style properties or feature filters." + }, + "expression_name":{ + "doc":"", + "type":"enum", + "values":{ + "let":{ + "doc":"Binds expressions to named variables, which can then be referenced in the result expression using [\"var\", \"variable_name\"].", + "group":"Variable binding", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "var":{ + "doc":"References variable bound using \"let\".", + "group":"Variable binding", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "literal":{ + "doc":"Provides a literal array or object value.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "array":{ + "doc":"Asserts that the input is an array (optionally with a specific item type and length). If, when the input expression is evaluated, it is not of the asserted type, then this assertion will cause the whole expression to be aborted.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "at":{ + "doc":"Retrieves an item from an array.", + "group":"Lookup", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "in":{ + "doc":"Determines whether an item exists in an array or a substring exists in a string.", + "group":"Lookup", + "sdk-support":{ + "basic functionality":{ + "js":"1.6.0" + } + } + }, + "case":{ + "doc":"Selects the first output whose corresponding test condition evaluates to true, or the fallback value otherwise.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "match":{ + "doc":"Selects the output whose label value matches the input value, or the fallback value if no match is found. The input can be any expression (e.g. `[\"get\", \"building_type\"]`). Each label must be either:\n * a single literal value; or\n * an array of literal values, whose values must be all strings or all numbers (e.g. `[100, 101]` or `[\"c\", \"b\"]`). The input matches if any of the values in the array matches, similar to the `\"in\"` operator.\n\nEach label must be unique. If the input type does not match the type of the labels, the result will be the fallback value.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "coalesce":{ + "doc":"Evaluates each expression in turn until the first non-null value is obtained, and returns that value.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "step":{ + "doc":"Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first output if the input is less than the first stop.", + "group":"Ramps, scales, curves", + "sdk-support":{ + "basic functionality":{ + "js":"0.42.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "interpolate":{ + "doc":"Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. The output type must be `number`, `array`, or `color`.\n\nInterpolation types:\n- `[\"linear\"]`: interpolates linearly between the pair of stops just less than and just greater than the input.\n- `[\"exponential\", base]`: interpolates exponentially between the stops just less than and just greater than the input. `base` controls the rate at which the output increases: higher values make the output increase more towards the high end of the range. With values close to 1 the output increases linearly.\n- `[\"cubic-bezier\", x1, y1, x2, y2]`: interpolates using the cubic bezier curve defined by the given control points.", + "group":"Ramps, scales, curves", + "sdk-support":{ + "basic functionality":{ + "js":"0.42.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "interpolate-hcl":{ + "doc":"Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\"). Works like `interpolate`, but the output type must be `color`, and the interpolation is performed in the Hue-Chroma-Luminance color space.", + "group":"Ramps, scales, curves", + "sdk-support":{ + "basic functionality":{ + "js":"0.49.0" + } + } + }, + "interpolate-lab":{ + "doc":"Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\"). Works like `interpolate`, but the output type must be `color`, and the interpolation is performed in the CIELAB color space.", + "group":"Ramps, scales, curves", + "sdk-support":{ + "basic functionality":{ + "js":"0.49.0" + } + } + }, + "ln2":{ + "doc":"Returns mathematical constant ln(2).", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "pi":{ + "doc":"Returns the mathematical constant pi.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "e":{ + "doc":"Returns the mathematical constant e.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "typeof":{ + "doc":"Returns a string describing the type of the given value.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "string":{ + "doc":"Asserts that the input value is a string. If multiple values are provided, each one is evaluated in order until a string is obtained. If none of the inputs are strings, the expression is an error.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "number":{ + "doc":"Asserts that the input value is a number. If multiple values are provided, each one is evaluated in order until a number is obtained. If none of the inputs are numbers, the expression is an error.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "boolean":{ + "doc":"Asserts that the input value is a boolean. If multiple values are provided, each one is evaluated in order until a boolean is obtained. If none of the inputs are booleans, the expression is an error.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "object":{ + "doc":"Asserts that the input value is an object. If multiple values are provided, each one is evaluated in order until an object is obtained. If none of the inputs are objects, the expression is an error.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "collator":{ + "doc":"Returns a `collator` for use in locale-dependent comparison operations. The `case-sensitive` and `diacritic-sensitive` options default to `false`. The `locale` argument specifies the IETF language tag of the locale to use. If none is provided, the default locale is used. If the requested locale is not available, the `collator` will use a system-defined fallback locale. Use `resolved-locale` to test the results of locale fallback behavior.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.2.0", + "macos":"0.9.0" + } + } + }, + "format":{ + "doc":"Returns `formatted` text containing annotations for use in mixed-format `text-field` entries. For a `text-field` entries of a string type, following option object's properties are supported: If set, the `text-font` value overrides the font specified by the root layout properties. If set, the `font-scale` value specifies a scaling factor relative to the `text-size` specified in the root layout properties. If set, the `text-color` value overrides the color specified by the root paint properties for this layer.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.48.0", + "android":"6.7.0", + "ios":"4.6.0", + "macos":"0.12.0" + }, + "text-font":{ + "js":"0.48.0", + "android":"6.7.0", + "ios":"4.6.0", + "macos":"0.12.0" + }, + "font-scale":{ + "js":"0.48.0", + "android":"6.7.0", + "ios":"4.6.0", + "macos":"0.12.0" + }, + "text-color":{ + "js":"1.3.0", + "android":"7.3.0", + "ios":"4.10.0", + "macos":"0.14.0" + }, + "image":{ + "js":"1.6.0" + } + } + }, + "image":{ + "doc":"Returns an `image` type for use in `icon-image`, `*-pattern` entries and as a section in the `format` expression. If set, the `image` argument will check that the requested image exists in the style and will return either the resolved image name or `null`, depending on whether or not the image is currently in the style. This validation process is synchronous and requires the image to have been added to the style before requesting it in the `image` argument.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"1.4.0", + "android":"8.6.0", + "ios":"5.6.0" + } + } + }, + "number-format":{ + "doc":"Converts the input number into a string representation using the providing formatting rules. If set, the `locale` argument specifies the locale to use, as a BCP 47 language tag. If set, the `currency` argument specifies an ISO 4217 code to use for currency-style formatting. If set, the `min-fraction-digits` and `max-fraction-digits` arguments specify the minimum and maximum number of fractional digits to include.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.54.0" + } + } + }, + "to-string":{ + "doc":"Converts the input value to a string. If the input is `null`, the result is `\"\"`. If the input is a boolean, the result is `\"true\"` or `\"false\"`. If the input is a number, it is converted to a string as specified by the [\"NumberToString\" algorithm](https://tc39.github.io/ecma262/#sec-tostring-applied-to-the-number-type) of the ECMAScript Language Specification. If the input is a color, it is converted to a string of the form `\"rgba(r,g,b,a)\"`, where `r`, `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from 0 to 1. Otherwise, the input is converted to a string in the format specified by the [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) function of the ECMAScript Language Specification.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "to-number":{ + "doc":"Converts the input value to a number, if possible. If the input is `null` or `false`, the result is 0. If the input is `true`, the result is 1. If the input is a string, it is converted to a number as specified by the [\"ToNumber Applied to the String Type\" algorithm](https://tc39.github.io/ecma262/#sec-tonumber-applied-to-the-string-type) of the ECMAScript Language Specification. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "to-boolean":{ + "doc":"Converts the input value to a boolean. The result is `false` when then input is an empty string, 0, `false`, `null`, or `NaN`; otherwise it is `true`.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "to-rgba":{ + "doc":"Returns a four-element array containing the input color's red, green, blue, and alpha components, in that order.", + "group":"Color", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "to-color":{ + "doc":"Converts the input value to a color. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.", + "group":"Types", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "rgb":{ + "doc":"Creates a color value from red, green, and blue components, which must range between 0 and 255, and an alpha component of 1. If any component is out of range, the expression is an error.", + "group":"Color", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "rgba":{ + "doc":"Creates a color value from red, green, blue components, which must range between 0 and 255, and an alpha component which must range between 0 and 1. If any component is out of range, the expression is an error.", + "group":"Color", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "get":{ + "doc":"Retrieves a property value from the current feature's properties, or from another object if a second argument is provided. Returns null if the requested property is missing.", + "group":"Lookup", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "has":{ + "doc":"Tests for the presence of an property value in the current feature's properties, or from another object if a second argument is provided.", + "group":"Lookup", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "length":{ + "doc":"Gets the length of an array or string.", + "group":"Lookup", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "properties":{ + "doc":"Gets the feature properties object. Note that in some cases, it may be more efficient to use [\"get\", \"property_name\"] directly.", + "group":"Feature data", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "feature-state":{ + "doc":"Retrieves a property value from the current feature's state. Returns null if the requested property is not present on the feature's state. A feature's state is not part of the GeoJSON or vector tile data, and must be set programmatically on each feature. Features are identified by their `id` attribute, which must be an integer or a string that can be cast to an integer. Note that [\"feature-state\"] can only be used with paint properties that support data-driven styling.", + "group":"Feature data", + "sdk-support":{ + "basic functionality":{ + "js":"0.46.0" + } + } + }, + "geometry-type":{ + "doc":"Gets the feature's geometry type: Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon.", + "group":"Feature data", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "id":{ + "doc":"Gets the feature's id, if it has one.", + "group":"Feature data", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "zoom":{ + "doc":"Gets the current zoom level. Note that in style layout and paint properties, [\"zoom\"] may only appear as the input to a top-level \"step\" or \"interpolate\" expression.", + "group":"Zoom", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "heatmap-density":{ + "doc":"Gets the kernel density estimation of a pixel in a heatmap layer, which is a relative measure of how many data points are crowded around a particular pixel. Can only be used in the `heatmap-color` property.", + "group":"Heatmap", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "line-progress":{ + "doc":"Gets the progress along a gradient line. Can only be used in the `line-gradient` property.", + "group":"Feature data", + "sdk-support":{ + "basic functionality":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.6.0", + "macos":"0.12.0" + } + } + }, + "accumulated":{ + "doc":"Gets the value of a cluster property accumulated so far. Can only be used in the `clusterProperties` option of a clustered GeoJSON source.", + "group":"Feature data", + "sdk-support":{ + "basic functionality":{ + "js":"0.53.0" + } + } + }, + "+":{ + "doc":"Returns the sum of the inputs.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "*":{ + "doc":"Returns the product of the inputs.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "-":{ + "doc":"For two inputs, returns the result of subtracting the second input from the first. For a single input, returns the result of subtracting it from 0.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "/":{ + "doc":"Returns the result of floating point division of the first input by the second.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "%":{ + "doc":"Returns the remainder after integer division of the first input by the second.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "^":{ + "doc":"Returns the result of raising the first input to the power specified by the second.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "sqrt":{ + "doc":"Returns the square root of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.42.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "log10":{ + "doc":"Returns the base-ten logarithm of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "ln":{ + "doc":"Returns the natural logarithm of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "log2":{ + "doc":"Returns the base-two logarithm of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "sin":{ + "doc":"Returns the sine of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "cos":{ + "doc":"Returns the cosine of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "tan":{ + "doc":"Returns the tangent of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "asin":{ + "doc":"Returns the arcsine of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "acos":{ + "doc":"Returns the arccosine of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "atan":{ + "doc":"Returns the arctangent of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "min":{ + "doc":"Returns the minimum value of the inputs.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "max":{ + "doc":"Returns the maximum value of the inputs.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "round":{ + "doc":"Rounds the input to the nearest integer. Halfway values are rounded away from zero. For example, `[\"round\", -1.5]` evaluates to -2.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.45.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "abs":{ + "doc":"Returns the absolute value of the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.45.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "ceil":{ + "doc":"Returns the smallest integer that is greater than or equal to the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.45.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "floor":{ + "doc":"Returns the largest integer that is less than or equal to the input.", + "group":"Math", + "sdk-support":{ + "basic functionality":{ + "js":"0.45.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "==":{ + "doc":"Returns `true` if the input values are equal, `false` otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + }, + "collator":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.2.0", + "macos":"0.9.0" + } + } + }, + "!=":{ + "doc":"Returns `true` if the input values are not equal, `false` otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + }, + "collator":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.2.0", + "macos":"0.9.0" + } + } + }, + ">":{ + "doc":"Returns `true` if the first input is strictly greater than the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + }, + "collator":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.2.0", + "macos":"0.9.0" + } + } + }, + "<":{ + "doc":"Returns `true` if the first input is strictly less than the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + }, + "collator":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.2.0", + "macos":"0.9.0" + } + } + }, + ">=":{ + "doc":"Returns `true` if the first input is greater than or equal to the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + }, + "collator":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.2.0", + "macos":"0.9.0" + } + } + }, + "<=":{ + "doc":"Returns `true` if the first input is less than or equal to the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + }, + "collator":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.2.0", + "macos":"0.9.0" + } + } + }, + "all":{ + "doc":"Returns `true` if all the inputs are `true`, `false` otherwise. The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates to `false`, the result is `false` and no further input expressions are evaluated.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "any":{ + "doc":"Returns `true` if any of the inputs are `true`, `false` otherwise. The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates to `true`, the result is `true` and no further input expressions are evaluated.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "!":{ + "doc":"Logical negation. Returns `true` if the input is `false`, and `false` if the input is `true`.", + "group":"Decision", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "is-supported-script":{ + "doc":"Returns `true` if the input string is expected to render legibly. Returns `false` if the input string contains sections that cannot be rendered without potential loss of meaning (e.g. Indic scripts that require complex text shaping, or right-to-left scripts if the the `mapbox-gl-rtl-text` plugin is not in use in Mapbox GL JS).", + "group":"String", + "sdk-support":{ + "basic functionality":{ + "js":"0.45.0", + "android":"6.6.0" + } + } + }, + "upcase":{ + "doc":"Returns the input string converted to uppercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.", + "group":"String", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "downcase":{ + "doc":"Returns the input string converted to lowercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.", + "group":"String", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "concat":{ + "doc":"Returns a `string` consisting of the concatenation of the inputs. Each input is converted to a string as if by `to-string`.", + "group":"String", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + } + }, + "resolved-locale":{ + "doc":"Returns the IETF language tag of the locale being used by the provided `collator`. This can be used to determine the default system locale, or to determine if a requested locale was successfully loaded.", + "group":"String", + "sdk-support":{ + "basic functionality":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.2.0", + "macos":"0.9.0" + } + } + } + } + }, + "light":{ + "anchor":{ + "type":"enum", + "default":"viewport", + "values":{ + "map":{ + "doc":"The position of the light source is aligned to the rotation of the map." + }, + "viewport":{ + "doc":"The position of the light source is aligned to the rotation of the viewport." + } + }, + "property-type":"data-constant", + "transition":false, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "doc":"Whether extruded geometries are lit relative to the map or viewport.", + "example":"map", + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + } + }, + "position":{ + "type":"array", + "default":[ + 1.15, + 210, + 30 + ], + "length":3, + "value":"number", + "property-type":"data-constant", + "transition":true, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "doc":"Position of the light source relative to lit (extruded) geometries, in [r radial coordinate, a azimuthal angle, p polar angle] where r indicates the distance from the center of the base of an object to its light, a indicates the position of the light relative to 0° (0° when `light.anchor` is set to `viewport` corresponds to the top of the viewport, or 0° when `light.anchor` is set to `map` corresponds to due north, and degrees proceed clockwise), and p indicates the height of the light (from 0°, directly above, to 180°, directly below).", + "example":[ + 1.5, + 90, + 80 + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + } + }, + "color":{ + "type":"color", + "property-type":"data-constant", + "default":"#ffffff", + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "transition":true, + "doc":"Color tint for lighting extruded geometries.", + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + } + }, + "intensity":{ + "type":"number", + "property-type":"data-constant", + "default":0.5, + "minimum":0, + "maximum":1, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "transition":true, + "doc":"Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast.", + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + } + } + }, + "paint":[ + "paint_fill", + "paint_line", + "paint_circle", + "paint_heatmap", + "paint_fill-extrusion", + "paint_symbol", + "paint_raster", + "paint_hillshade", + "paint_background" + ], + "paint_fill":{ + "fill-antialias":{ + "type":"boolean", + "default":true, + "doc":"Whether or not the fill should be antialiased.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "fill-opacity":{ + "type":"number", + "default":1, + "minimum":0, + "maximum":1, + "doc":"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.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.21.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "fill-color":{ + "type":"color", + "default":"#000000", + "doc":"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.", + "transition":true, + "requires":[ + { + "!":"fill-pattern" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.19.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "fill-outline-color":{ + "type":"color", + "doc":"The outline color of the fill. Matches the value of `fill-color` if unspecified.", + "transition":true, + "requires":[ + { + "!":"fill-pattern" + }, + { + "fill-antialias":true + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.19.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "fill-translate":{ + "type":"array", + "value":"number", + "length":2, + "default":[ + 0, + 0 + ], + "transition":true, + "units":"pixels", + "doc":"The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "fill-translate-anchor":{ + "type":"enum", + "values":{ + "map":{ + "doc":"The fill is translated relative to the map." + }, + "viewport":{ + "doc":"The fill is translated relative to the viewport." + } + }, + "doc":"Controls the frame of reference for `fill-translate`.", + "default":"map", + "requires":[ + "fill-translate" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "fill-pattern":{ + "type":"resolvedImage", + "transition":true, + "doc":"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). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.49.0", + "android":"6.5.0", + "macos":"0.11.0", + "ios":"4.4.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"cross-faded-data-driven" + } + }, + "paint_fill-extrusion":{ + "fill-extrusion-opacity":{ + "type":"number", + "default":1, + "minimum":0, + "maximum":1, + "doc":"The opacity of the entire fill extrusion layer. This is rendered on a per-layer, not per-feature, basis, and data-driven styling is not available.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "fill-extrusion-color":{ + "type":"color", + "default":"#000000", + "doc":"The base color of the extruded fill. The extrusion's surfaces will be shaded differently based on this color in combination with the root `light` settings. If this color is specified as `rgba` with an alpha component, the alpha component will be ignored; use `fill-extrusion-opacity` to set layer opacity.", + "transition":true, + "requires":[ + { + "!":"fill-extrusion-pattern" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + }, + "data-driven styling":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "fill-extrusion-translate":{ + "type":"array", + "value":"number", + "length":2, + "default":[ + 0, + 0 + ], + "transition":true, + "units":"pixels", + "doc":"The geometry's offset. Values are [x, y] where negatives indicate left and up (on the flat plane), respectively.", + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "fill-extrusion-translate-anchor":{ + "type":"enum", + "values":{ + "map":{ + "doc":"The fill extrusion is translated relative to the map." + }, + "viewport":{ + "doc":"The fill extrusion is translated relative to the viewport." + } + }, + "doc":"Controls the frame of reference for `fill-extrusion-translate`.", + "default":"map", + "requires":[ + "fill-extrusion-translate" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "fill-extrusion-pattern":{ + "type":"resolvedImage", + "transition":true, + "doc":"Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + }, + "data-driven styling":{ + "js":"0.49.0", + "android":"6.5.0", + "macos":"0.11.0", + "ios":"4.4.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"cross-faded-data-driven" + }, + "fill-extrusion-height":{ + "type":"number", + "default":0, + "minimum":0, + "units":"meters", + "doc":"The height with which to extrude this layer.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + }, + "data-driven styling":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "fill-extrusion-base":{ + "type":"number", + "default":0, + "minimum":0, + "units":"meters", + "doc":"The height with which to extrude the base of this layer. Must be less than or equal to `fill-extrusion-height`.", + "transition":true, + "requires":[ + "fill-extrusion-height" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + }, + "data-driven styling":{ + "js":"0.27.0", + "android":"5.1.0", + "ios":"3.6.0", + "macos":"0.5.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "fill-extrusion-vertical-gradient":{ + "type":"boolean", + "default":true, + "doc":"Whether to apply a vertical gradient to the sides of a fill-extrusion layer. If true, sides will be shaded slightly darker farther down.", + "transition":false, + "sdk-support":{ + "basic functionality":{ + "js":"0.50.0", + "ios":"4.7.0", + "macos":"0.13.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + } + }, + "paint_line":{ + "line-opacity":{ + "type":"number", + "doc":"The opacity at which the line will be drawn.", + "default":1, + "minimum":0, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "line-color":{ + "type":"color", + "doc":"The color with which the line will be drawn.", + "default":"#000000", + "transition":true, + "requires":[ + { + "!":"line-pattern" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.23.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "line-translate":{ + "type":"array", + "value":"number", + "length":2, + "default":[ + 0, + 0 + ], + "transition":true, + "units":"pixels", + "doc":"The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "line-translate-anchor":{ + "type":"enum", + "values":{ + "map":{ + "doc":"The line is translated relative to the map." + }, + "viewport":{ + "doc":"The line is translated relative to the viewport." + } + }, + "doc":"Controls the frame of reference for `line-translate`.", + "default":"map", + "requires":[ + "line-translate" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "line-width":{ + "type":"number", + "default":1, + "minimum":0, + "transition":true, + "units":"pixels", + "doc":"Stroke thickness.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.39.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "line-gap-width":{ + "type":"number", + "default":0, + "minimum":0, + "doc":"Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap.", + "transition":true, + "units":"pixels", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "line-offset":{ + "type":"number", + "default":0, + "doc":"The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset.", + "transition":true, + "units":"pixels", + "sdk-support":{ + "basic functionality":{ + "js":"0.12.1", + "android":"3.0.0", + "ios":"3.1.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "line-blur":{ + "type":"number", + "default":0, + "minimum":0, + "transition":true, + "units":"pixels", + "doc":"Blur applied to the line, in pixels.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "line-dasharray":{ + "type":"array", + "value":"number", + "doc":"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. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels.", + "minimum":0, + "transition":true, + "units":"line widths", + "requires":[ + { + "!":"line-pattern" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"cross-faded" + }, + "line-pattern":{ + "type":"resolvedImage", + "transition":true, + "doc":"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). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.49.0", + "android":"6.5.0", + "macos":"0.11.0", + "ios":"4.4.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom", + "feature" + ] + }, + "property-type":"cross-faded-data-driven" + }, + "line-gradient":{ + "type":"color", + "doc":"Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `\"lineMetrics\": true`.", + "transition":false, + "requires":[ + { + "!":"line-dasharray" + }, + { + "!":"line-pattern" + }, + { + "source":"geojson", + "has":{ + "lineMetrics":true + } + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.45.0", + "android":"6.5.0", + "ios":"4.4.0", + "macos":"0.11.0" + }, + "data-driven styling":{ + + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "line-progress" + ] + }, + "property-type":"color-ramp" + } + }, + "paint_circle":{ + "circle-radius":{ + "type":"number", + "default":5, + "minimum":0, + "transition":true, + "units":"pixels", + "doc":"Circle radius.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.18.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "circle-color":{ + "type":"color", + "default":"#000000", + "doc":"The fill color of the circle.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.18.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "circle-blur":{ + "type":"number", + "default":0, + "doc":"Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.20.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "circle-opacity":{ + "type":"number", + "doc":"The opacity at which the circle will be drawn.", + "default":1, + "minimum":0, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.20.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "circle-translate":{ + "type":"array", + "value":"number", + "length":2, + "default":[ + 0, + 0 + ], + "transition":true, + "units":"pixels", + "doc":"The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "circle-translate-anchor":{ + "type":"enum", + "values":{ + "map":{ + "doc":"The circle is translated relative to the map." + }, + "viewport":{ + "doc":"The circle is translated relative to the viewport." + } + }, + "doc":"Controls the frame of reference for `circle-translate`.", + "default":"map", + "requires":[ + "circle-translate" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "circle-pitch-scale":{ + "type":"enum", + "values":{ + "map":{ + "doc":"Circles are scaled according to their apparent distance to the camera." + }, + "viewport":{ + "doc":"Circles are not scaled." + } + }, + "default":"map", + "doc":"Controls the scaling behavior of the circle when the map is pitched.", + "sdk-support":{ + "basic functionality":{ + "js":"0.21.0", + "android":"4.2.0", + "ios":"3.4.0", + "macos":"0.2.1" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "circle-pitch-alignment":{ + "type":"enum", + "values":{ + "map":{ + "doc":"The circle is aligned to the plane of the map." + }, + "viewport":{ + "doc":"The circle is aligned to the plane of the viewport." + } + }, + "default":"viewport", + "doc":"Orientation of circle when map is pitched.", + "sdk-support":{ + "basic functionality":{ + "js":"0.39.0", + "android":"5.2.0", + "ios":"3.7.0", + "macos":"0.6.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "circle-stroke-width":{ + "type":"number", + "default":0, + "minimum":0, + "transition":true, + "units":"pixels", + "doc":"The width of the circle's stroke. Strokes are placed outside of the `circle-radius`.", + "sdk-support":{ + "basic functionality":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + }, + "data-driven styling":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "circle-stroke-color":{ + "type":"color", + "default":"#000000", + "doc":"The stroke color of the circle.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + }, + "data-driven styling":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "circle-stroke-opacity":{ + "type":"number", + "doc":"The opacity of the circle's stroke.", + "default":1, + "minimum":0, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + }, + "data-driven styling":{ + "js":"0.29.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + } + }, + "paint_heatmap":{ + "heatmap-radius":{ + "type":"number", + "default":30, + "minimum":1, + "transition":true, + "units":"pixels", + "doc":"Radius of influence of one heatmap point in pixels. Increasing the value makes the heatmap smoother, but less detailed.", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + }, + "data-driven styling":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "heatmap-weight":{ + "type":"number", + "default":1, + "minimum":0, + "transition":false, + "doc":"A measure of how much an individual point contributes to the heatmap. A value of 10 would be equivalent to having 10 points of weight 1 in the same spot. Especially useful when combined with clustering.", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + }, + "data-driven styling":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "heatmap-intensity":{ + "type":"number", + "default":1, + "minimum":0, + "transition":true, + "doc":"Similar to `heatmap-weight` but controls the intensity of the heatmap globally. Primarily used for adjusting the heatmap based on zoom level.", + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "heatmap-color":{ + "type":"color", + "default":[ + "interpolate", + [ + "linear" + ], + [ + "heatmap-density" + ], + 0, + "rgba(0, 0, 255, 0)", + 0.1, + "royalblue", + 0.3, + "cyan", + 0.5, + "lime", + 0.7, + "yellow", + 1, + "red" + ], + "doc":"Defines the color of each pixel based on its density value in a heatmap. Should be an expression that uses `[\"heatmap-density\"]` as input.", + "transition":false, + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + }, + "data-driven styling":{ + + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "heatmap-density" + ] + }, + "property-type":"color-ramp" + }, + "heatmap-opacity":{ + "type":"number", + "doc":"The global opacity at which the heatmap layer will be drawn.", + "default":1, + "minimum":0, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.41.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + } + }, + "paint_symbol":{ + "icon-opacity":{ + "doc":"The opacity at which the icon will be drawn.", + "type":"number", + "default":1, + "minimum":0, + "maximum":1, + "transition":true, + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "icon-color":{ + "type":"color", + "default":"#000000", + "transition":true, + "doc":"The color of the icon. This can only be used with sdf icons.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "icon-halo-color":{ + "type":"color", + "default":"rgba(0, 0, 0, 0)", + "transition":true, + "doc":"The color of the icon's halo. Icon halos can only be used with SDF icons.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "icon-halo-width":{ + "type":"number", + "default":0, + "minimum":0, + "transition":true, + "units":"pixels", + "doc":"Distance of halo to the icon outline.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "icon-halo-blur":{ + "type":"number", + "default":0, + "minimum":0, + "transition":true, + "units":"pixels", + "doc":"Fade out the halo towards the outside.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "icon-translate":{ + "type":"array", + "value":"number", + "length":2, + "default":[ + 0, + 0 + ], + "transition":true, + "units":"pixels", + "doc":"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.", + "requires":[ + "icon-image" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "icon-translate-anchor":{ + "type":"enum", + "values":{ + "map":{ + "doc":"Icons are translated relative to the map." + }, + "viewport":{ + "doc":"Icons are translated relative to the viewport." + } + }, + "doc":"Controls the frame of reference for `icon-translate`.", + "default":"map", + "requires":[ + "icon-image", + "icon-translate" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-opacity":{ + "type":"number", + "doc":"The opacity at which the text will be drawn.", + "default":1, + "minimum":0, + "maximum":1, + "transition":true, + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "text-color":{ + "type":"color", + "doc":"The color with which the text will be drawn.", + "default":"#000000", + "transition":true, + "overridable":true, + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "text-halo-color":{ + "type":"color", + "default":"rgba(0, 0, 0, 0)", + "transition":true, + "doc":"The color of the text's halo, which helps it stand out from backgrounds.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "text-halo-width":{ + "type":"number", + "default":0, + "minimum":0, + "transition":true, + "units":"pixels", + "doc":"Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "text-halo-blur":{ + "type":"number", + "default":0, + "minimum":0, + "transition":true, + "units":"pixels", + "doc":"The halo's fadeout distance towards the outside.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + "js":"0.33.0", + "android":"5.0.0", + "ios":"3.5.0", + "macos":"0.4.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom", + "feature", + "feature-state" + ] + }, + "property-type":"data-driven" + }, + "text-translate":{ + "type":"array", + "value":"number", + "length":2, + "default":[ + 0, + 0 + ], + "transition":true, + "units":"pixels", + "doc":"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.", + "requires":[ + "text-field" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "text-translate-anchor":{ + "type":"enum", + "values":{ + "map":{ + "doc":"The text is translated relative to the map." + }, + "viewport":{ + "doc":"The text is translated relative to the viewport." + } + }, + "doc":"Controls the frame of reference for `text-translate`.", + "default":"map", + "requires":[ + "text-field", + "text-translate" + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + } + }, + "paint_raster":{ + "raster-opacity":{ + "type":"number", + "doc":"The opacity at which the image will be drawn.", + "default":1, + "minimum":0, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "raster-hue-rotate":{ + "type":"number", + "default":0, + "period":360, + "transition":true, + "units":"degrees", + "doc":"Rotates hues around the color wheel.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "raster-brightness-min":{ + "type":"number", + "doc":"Increase or reduce the brightness of the image. The value is the minimum brightness.", + "default":0, + "minimum":0, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "raster-brightness-max":{ + "type":"number", + "doc":"Increase or reduce the brightness of the image. The value is the maximum brightness.", + "default":1, + "minimum":0, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "raster-saturation":{ + "type":"number", + "doc":"Increase or reduce the saturation of the image.", + "default":0, + "minimum":-1, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "raster-contrast":{ + "type":"number", + "doc":"Increase or reduce the contrast of the image.", + "default":0, + "minimum":-1, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "raster-resampling":{ + "type":"enum", + "doc":"The resampling/interpolation method to use for overscaling, also known as texture magnification filter", + "values":{ + "linear":{ + "doc":"(Bi)linear filtering interpolates pixel values using the weighted average of the four closest original source pixels creating a smooth but blurry look when overscaled" + }, + "nearest":{ + "doc":"Nearest neighbor filtering interpolates pixel values using the nearest original source pixel creating a sharp but pixelated look when overscaled" + } + }, + "default":"linear", + "sdk-support":{ + "basic functionality":{ + "js":"0.47.0", + "android":"6.3.0", + "ios":"4.2.0", + "macos":"0.9.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "raster-fade-duration":{ + "type":"number", + "default":300, + "minimum":0, + "transition":false, + "units":"milliseconds", + "doc":"Fade duration when a new tile is added.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + } + }, + "paint_hillshade":{ + "hillshade-illumination-direction":{ + "type":"number", + "default":335, + "minimum":0, + "maximum":359, + "doc":"The direction of the light source used to generate the hillshading with 0 as the top of the viewport if `hillshade-illumination-anchor` is set to `viewport` and due north if `hillshade-illumination-anchor` is set to `map`.", + "transition":false, + "sdk-support":{ + "basic functionality":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "hillshade-illumination-anchor":{ + "type":"enum", + "values":{ + "map":{ + "doc":"The hillshade illumination is relative to the north direction." + }, + "viewport":{ + "doc":"The hillshade illumination is relative to the top of the viewport." + } + }, + "default":"viewport", + "doc":"Direction of light source when map is rotated.", + "sdk-support":{ + "basic functionality":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "hillshade-exaggeration":{ + "type":"number", + "doc":"Intensity of the hillshade", + "default":0.5, + "minimum":0, + "maximum":1, + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "hillshade-shadow-color":{ + "type":"color", + "default":"#000000", + "doc":"The shading color of areas that face away from the light source.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "hillshade-highlight-color":{ + "type":"color", + "default":"#FFFFFF", + "doc":"The shading color of areas that faces towards the light source.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "hillshade-accent-color":{ + "type":"color", + "default":"#000000", + "doc":"The shading color used to accentuate rugged terrain like sharp cliffs and gorges.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.43.0", + "android":"6.0.0", + "ios":"4.0.0", + "macos":"0.7.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + } + }, + "paint_background":{ + "background-color":{ + "type":"color", + "default":"#000000", + "doc":"The color with which the background will be drawn.", + "transition":true, + "requires":[ + { + "!":"background-pattern" + } + ], + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + }, + "background-pattern":{ + "type":"resolvedImage", + "transition":true, + "doc":"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). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + }, + "data-driven styling":{ + + } + }, + "expression":{ + "interpolated":false, + "parameters":[ + "zoom" + ] + }, + "property-type":"cross-faded" + }, + "background-opacity":{ + "type":"number", + "default":1, + "minimum":0, + "maximum":1, + "doc":"The opacity at which the background will be drawn.", + "transition":true, + "sdk-support":{ + "basic functionality":{ + "js":"0.10.0", + "android":"2.0.1", + "ios":"2.0.0", + "macos":"0.1.0" + } + }, + "expression":{ + "interpolated":true, + "parameters":[ + "zoom" + ] + }, + "property-type":"data-constant" + } + }, + "transition":{ + "duration":{ + "type":"number", + "default":300, + "minimum":0, + "units":"milliseconds", + "doc":"Time allotted for transitions to complete." + }, + "delay":{ + "type":"number", + "default":0, + "minimum":0, + "units":"milliseconds", + "doc":"Length of time before a transition begins." + } + }, + "property-type":{ + "data-driven":{ + "type":"property-type", + "doc":"Property is interpolable and can be represented using a property expression." + }, + "cross-faded":{ + "type":"property-type", + "doc":"Property is non-interpolable; rather, its values will be cross-faded to smoothly transition between integer zooms." + }, + "cross-faded-data-driven":{ + "type":"property-type", + "doc":"Property is non-interpolable; rather, its values will be cross-faded to smoothly transition between integer zooms. It can be represented using a property expression." + }, + "color-ramp":{ + "type":"property-type", + "doc":"Property should be specified using a color ramp from which the output color can be sampled based on a property calculation." + }, + "data-constant":{ + "type":"property-type", + "doc":"Property is interpolable but cannot be represented using a property expression." + }, + "constant":{ + "type":"property-type", + "doc":"Property is constant across all zoom levels and property values." + } + }, + "promoteId":{ + "*":{ + "type":"string", + "doc":"A name of a feature property to use as ID for feature state." + } + } +} \ No newline at end of file diff --git a/scripts/lib/generate_style_converters.dart b/scripts/lib/generate_style_converters.dart new file mode 100644 index 000000000..02b28ee50 --- /dev/null +++ b/scripts/lib/generate_style_converters.dart @@ -0,0 +1,24 @@ +import 'dart:io'; +import 'dart:convert'; + +import 'package:mustache/mustache.dart'; +import 'package:recase/recase.dart'; + +main() async { + var properties = []; + + var styleJson = jsonDecode(await new File('./scripts/input/style.json').readAsString()); + properties.addAll(styleJson["layout_line"].keys.followedBy(styleJson["paint_line"].keys) + .map((f) => { + 'hyphen': f, + 'camel': new ReCase(f).camelCase + }).toList()); + + var javaTemplate = await new File('./scripts/templates/java_template.txt').readAsString(); + var template = new Template(javaTemplate); + + var outputFile = new File('./android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java'); + outputFile.writeAsString(template.renderString({ + 'lineStyles': properties + })); +} \ No newline at end of file diff --git a/scripts/pubspec.lock b/scripts/pubspec.lock new file mode 100644 index 000000000..ddab59885 --- /dev/null +++ b/scripts/pubspec.lock @@ -0,0 +1,19 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + mustache: + dependency: "direct main" + description: + name: mustache + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + recase: + dependency: "direct main" + description: + name: recase + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" +sdks: + dart: ">=2.6.0 <3.0.0" diff --git a/scripts/pubspec.yaml b/scripts/pubspec.yaml new file mode 100644 index 000000000..d4c160b6e --- /dev/null +++ b/scripts/pubspec.yaml @@ -0,0 +1,11 @@ +name: mapbox_code_gen +description: Just a place to practice +version: 0.0.1 +author: suragch + +environment: + sdk: ">=2.0.0-dev.68.0 <3.0.0" + +dependencies: + mustache: 1.1.1 + recase: 3.0.0 diff --git a/scripts/templates/dart_template.txt b/scripts/templates/dart_template.txt new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/templates/java_template.txt b/scripts/templates/java_template.txt new file mode 100644 index 000000000..12b8172d5 --- /dev/null +++ b/scripts/templates/java_template.txt @@ -0,0 +1,37 @@ +// This file is generated. + +package com.mapbox.mapboxgl; + +import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.PropertyFactory; +import com.mapbox.mapboxsdk.style.layers.PropertyValue; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import static com.mapbox.mapboxgl.Convert.toMap; + +class LayerPropertyConverter { + + static PropertyValue[] interpretLineLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + {{#lineStyles}} + case "{{hyphen}}": + properties.add(PropertyFactory.{{camel}}(expression)); + break; + {{/lineStyles}} + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + +} \ No newline at end of file diff --git a/scripts/templates/swift_template.txt b/scripts/templates/swift_template.txt new file mode 100644 index 000000000..e69de29bb From 50736a48f989dd352816a68e653d0ca613a03a33 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Fri, 15 Oct 2021 22:41:48 +0200 Subject: [PATCH 06/33] added swift and full java generation --- .../mapboxgl/LayerPropertyConverter.java | 282 +++++++++++++- ios/Classes/LayerPropertyConverter.swift | 343 ++++++++++++++++++ pubspec.lock | 9 +- scripts/.dart_tool/package_config.json | 8 +- scripts/lib/generate_style_converters.dart | 56 ++- scripts/pubspec.yaml | 7 +- .../LayerPropertyConverter.template.java | 98 +++++ .../LayerPropertyConverter.template.swift | 78 ++++ scripts/templates/java_template.txt | 37 -- scripts/templates/swift_template.txt | 0 10 files changed, 847 insertions(+), 71 deletions(-) create mode 100644 ios/Classes/LayerPropertyConverter.swift create mode 100644 scripts/templates/LayerPropertyConverter.template.java create mode 100644 scripts/templates/LayerPropertyConverter.template.swift delete mode 100644 scripts/templates/java_template.txt delete mode 100644 scripts/templates/swift_template.txt diff --git a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java index ec8094c27..46e83d22e 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java +++ b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java @@ -1,4 +1,5 @@ -// This file is generated. +// This file is generated by +// ./scripts/lib/generate_style_converters.dart package com.mapbox.mapboxgl; @@ -80,4 +81,283 @@ static PropertyValue[] interpretLineLayerProperties(Object o) { return properties.toArray(new PropertyValue[properties.size()]); } + static PropertyValue[] interpretSymbolLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + case "symbol-placement": + properties.add(PropertyFactory.symbolPlacement(expression)); + break; + case "symbol-spacing": + properties.add(PropertyFactory.symbolSpacing(expression)); + break; + case "symbol-avoid-edges": + properties.add(PropertyFactory.symbolAvoidEdges(expression)); + break; + case "symbol-sort-key": + properties.add(PropertyFactory.symbolSortKey(expression)); + break; + case "symbol-z-order": + properties.add(PropertyFactory.symbolZOrder(expression)); + break; + case "icon-allow-overlap": + properties.add(PropertyFactory.iconAllowOverlap(expression)); + break; + case "icon-ignore-placement": + properties.add(PropertyFactory.iconIgnorePlacement(expression)); + break; + case "icon-optional": + properties.add(PropertyFactory.iconOptional(expression)); + break; + case "icon-rotation-alignment": + properties.add(PropertyFactory.iconRotationAlignment(expression)); + break; + case "icon-size": + properties.add(PropertyFactory.iconSize(expression)); + break; + case "icon-text-fit": + properties.add(PropertyFactory.iconTextFit(expression)); + break; + case "icon-text-fit-padding": + properties.add(PropertyFactory.iconTextFitPadding(expression)); + break; + case "icon-image": + properties.add(PropertyFactory.iconImage(expression)); + break; + case "icon-rotate": + properties.add(PropertyFactory.iconRotate(expression)); + break; + case "icon-padding": + properties.add(PropertyFactory.iconPadding(expression)); + break; + case "icon-keep-upright": + properties.add(PropertyFactory.iconKeepUpright(expression)); + break; + case "icon-offset": + properties.add(PropertyFactory.iconOffset(expression)); + break; + case "icon-anchor": + properties.add(PropertyFactory.iconAnchor(expression)); + break; + case "icon-pitch-alignment": + properties.add(PropertyFactory.iconPitchAlignment(expression)); + break; + case "text-pitch-alignment": + properties.add(PropertyFactory.textPitchAlignment(expression)); + break; + case "text-rotation-alignment": + properties.add(PropertyFactory.textRotationAlignment(expression)); + break; + case "text-field": + properties.add(PropertyFactory.textField(expression)); + break; + case "text-font": + properties.add(PropertyFactory.textFont(expression)); + break; + case "text-size": + properties.add(PropertyFactory.textSize(expression)); + break; + case "text-max-width": + properties.add(PropertyFactory.textMaxWidth(expression)); + break; + case "text-line-height": + properties.add(PropertyFactory.textLineHeight(expression)); + break; + case "text-letter-spacing": + properties.add(PropertyFactory.textLetterSpacing(expression)); + break; + case "text-justify": + properties.add(PropertyFactory.textJustify(expression)); + break; + case "text-radial-offset": + properties.add(PropertyFactory.textRadialOffset(expression)); + break; + case "text-variable-anchor": + properties.add(PropertyFactory.textVariableAnchor(expression)); + break; + case "text-anchor": + properties.add(PropertyFactory.textAnchor(expression)); + break; + case "text-max-angle": + properties.add(PropertyFactory.textMaxAngle(expression)); + break; + case "text-writing-mode": + properties.add(PropertyFactory.textWritingMode(expression)); + break; + case "text-rotate": + properties.add(PropertyFactory.textRotate(expression)); + break; + case "text-padding": + properties.add(PropertyFactory.textPadding(expression)); + break; + case "text-keep-upright": + properties.add(PropertyFactory.textKeepUpright(expression)); + break; + case "text-transform": + properties.add(PropertyFactory.textTransform(expression)); + break; + case "text-offset": + properties.add(PropertyFactory.textOffset(expression)); + break; + case "text-allow-overlap": + properties.add(PropertyFactory.textAllowOverlap(expression)); + break; + case "text-ignore-placement": + properties.add(PropertyFactory.textIgnorePlacement(expression)); + break; + case "text-optional": + properties.add(PropertyFactory.textOptional(expression)); + break; + case "visibility": + properties.add(PropertyFactory.visibility(expression)); + break; + case "icon-opacity": + properties.add(PropertyFactory.iconOpacity(expression)); + break; + case "icon-color": + properties.add(PropertyFactory.iconColor(expression)); + break; + case "icon-halo-color": + properties.add(PropertyFactory.iconHaloColor(expression)); + break; + case "icon-halo-width": + properties.add(PropertyFactory.iconHaloWidth(expression)); + break; + case "icon-halo-blur": + properties.add(PropertyFactory.iconHaloBlur(expression)); + break; + case "icon-translate": + properties.add(PropertyFactory.iconTranslate(expression)); + break; + case "icon-translate-anchor": + properties.add(PropertyFactory.iconTranslateAnchor(expression)); + break; + case "text-opacity": + properties.add(PropertyFactory.textOpacity(expression)); + break; + case "text-color": + properties.add(PropertyFactory.textColor(expression)); + break; + case "text-halo-color": + properties.add(PropertyFactory.textHaloColor(expression)); + break; + case "text-halo-width": + properties.add(PropertyFactory.textHaloWidth(expression)); + break; + case "text-halo-blur": + properties.add(PropertyFactory.textHaloBlur(expression)); + break; + case "text-translate": + properties.add(PropertyFactory.textTranslate(expression)); + break; + case "text-translate-anchor": + properties.add(PropertyFactory.textTranslateAnchor(expression)); + break; + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + + static PropertyValue[] interpretCircleLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + case "circle-sort-key": + properties.add(PropertyFactory.circleSortKey(expression)); + break; + case "visibility": + properties.add(PropertyFactory.visibility(expression)); + break; + case "circle-radius": + properties.add(PropertyFactory.circleRadius(expression)); + break; + case "circle-color": + properties.add(PropertyFactory.circleColor(expression)); + break; + case "circle-blur": + properties.add(PropertyFactory.circleBlur(expression)); + break; + case "circle-opacity": + properties.add(PropertyFactory.circleOpacity(expression)); + break; + case "circle-translate": + properties.add(PropertyFactory.circleTranslate(expression)); + break; + case "circle-translate-anchor": + properties.add(PropertyFactory.circleTranslateAnchor(expression)); + break; + case "circle-pitch-scale": + properties.add(PropertyFactory.circlePitchScale(expression)); + break; + case "circle-pitch-alignment": + properties.add(PropertyFactory.circlePitchAlignment(expression)); + break; + case "circle-stroke-width": + properties.add(PropertyFactory.circleStrokeWidth(expression)); + break; + case "circle-stroke-color": + properties.add(PropertyFactory.circleStrokeColor(expression)); + break; + case "circle-stroke-opacity": + properties.add(PropertyFactory.circleStrokeOpacity(expression)); + break; + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + + static PropertyValue[] interpretFillLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + case "fill-sort-key": + properties.add(PropertyFactory.fillSortKey(expression)); + break; + case "visibility": + properties.add(PropertyFactory.visibility(expression)); + break; + case "fill-antialias": + properties.add(PropertyFactory.fillAntialias(expression)); + break; + case "fill-opacity": + properties.add(PropertyFactory.fillOpacity(expression)); + break; + case "fill-color": + properties.add(PropertyFactory.fillColor(expression)); + break; + case "fill-outline-color": + properties.add(PropertyFactory.fillOutlineColor(expression)); + break; + case "fill-translate": + properties.add(PropertyFactory.fillTranslate(expression)); + break; + case "fill-translate-anchor": + properties.add(PropertyFactory.fillTranslateAnchor(expression)); + break; + case "fill-pattern": + properties.add(PropertyFactory.fillPattern(expression)); + break; + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + } \ No newline at end of file diff --git a/ios/Classes/LayerPropertyConverter.swift b/ios/Classes/LayerPropertyConverter.swift new file mode 100644 index 000000000..bfb4cac97 --- /dev/null +++ b/ios/Classes/LayerPropertyConverter.swift @@ -0,0 +1,343 @@ +// This file is generated by +// ./scripts/lib/generate_style_converters.dart + +import Mapbox +import MapboxAnnotationExtension + +class LayerPropertyConverter { + class func addLineProperties(lineLayer: MGLLineStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + case "line-cap": + lineLayer.lineCap = expression; + break; + case "line-join": + lineLayer.lineJoin = expression; + break; + case "line-miter-limit": + lineLayer.lineMiterLimit = expression; + break; + case "line-round-limit": + lineLayer.lineRoundLimit = expression; + break; + case "line-sort-key": + lineLayer.lineSortKey = expression; + break; + case "visibility": + lineLayer.visibility = expression; + break; + case "line-opacity": + lineLayer.lineOpacity = expression; + break; + case "line-color": + lineLayer.lineColor = expression; + break; + case "line-translate": + lineLayer.lineTranslate = expression; + break; + case "line-translate-anchor": + lineLayer.lineTranslateAnchor = expression; + break; + case "line-width": + lineLayer.lineWidth = expression; + break; + case "line-gap-width": + lineLayer.lineGapWidth = expression; + break; + case "line-offset": + lineLayer.lineOffset = expression; + break; + case "line-blur": + lineLayer.lineBlur = expression; + break; + case "line-dasharray": + lineLayer.lineDasharray = expression; + break; + case "line-pattern": + lineLayer.linePattern = expression; + break; + case "line-gradient": + lineLayer.lineGradient = expression; + break; + case "line-blur": + lineLayer.lineBlur = expression + default: + break + } + } + } + + class func addCircleProperties(circleLayer: MGLCircleStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + case "circle-sort-key": + lineLayer.circleSortKey = expression; + break; + case "visibility": + lineLayer.visibility = expression; + break; + case "circle-radius": + lineLayer.circleRadius = expression; + break; + case "circle-color": + lineLayer.circleColor = expression; + break; + case "circle-blur": + lineLayer.circleBlur = expression; + break; + case "circle-opacity": + lineLayer.circleOpacity = expression; + break; + case "circle-translate": + lineLayer.circleTranslate = expression; + break; + case "circle-translate-anchor": + lineLayer.circleTranslateAnchor = expression; + break; + case "circle-pitch-scale": + lineLayer.circlePitchScale = expression; + break; + case "circle-pitch-alignment": + lineLayer.circlePitchAlignment = expression; + break; + case "circle-stroke-width": + lineLayer.circleStrokeWidth = expression; + break; + case "circle-stroke-color": + lineLayer.circleStrokeColor = expression; + break; + case "circle-stroke-opacity": + lineLayer.circleStrokeOpacity = expression; + break; + default: + break + } + } + } + + class func addSymbolProperties(symbolLayer: MGLSymbolStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + case "symbol-placement": + lineLayer.symbolPlacement = expression; + break; + case "symbol-spacing": + lineLayer.symbolSpacing = expression; + break; + case "symbol-avoid-edges": + lineLayer.symbolAvoidEdges = expression; + break; + case "symbol-sort-key": + lineLayer.symbolSortKey = expression; + break; + case "symbol-z-order": + lineLayer.symbolZOrder = expression; + break; + case "icon-allow-overlap": + lineLayer.iconAllowOverlap = expression; + break; + case "icon-ignore-placement": + lineLayer.iconIgnorePlacement = expression; + break; + case "icon-optional": + lineLayer.iconOptional = expression; + break; + case "icon-rotation-alignment": + lineLayer.iconRotationAlignment = expression; + break; + case "icon-size": + lineLayer.iconSize = expression; + break; + case "icon-text-fit": + lineLayer.iconTextFit = expression; + break; + case "icon-text-fit-padding": + lineLayer.iconTextFitPadding = expression; + break; + case "icon-image": + lineLayer.iconImage = expression; + break; + case "icon-rotate": + lineLayer.iconRotate = expression; + break; + case "icon-padding": + lineLayer.iconPadding = expression; + break; + case "icon-keep-upright": + lineLayer.iconKeepUpright = expression; + break; + case "icon-offset": + lineLayer.iconOffset = expression; + break; + case "icon-anchor": + lineLayer.iconAnchor = expression; + break; + case "icon-pitch-alignment": + lineLayer.iconPitchAlignment = expression; + break; + case "text-pitch-alignment": + lineLayer.textPitchAlignment = expression; + break; + case "text-rotation-alignment": + lineLayer.textRotationAlignment = expression; + break; + case "text-field": + lineLayer.textField = expression; + break; + case "text-font": + lineLayer.textFont = expression; + break; + case "text-size": + lineLayer.textSize = expression; + break; + case "text-max-width": + lineLayer.textMaxWidth = expression; + break; + case "text-line-height": + lineLayer.textLineHeight = expression; + break; + case "text-letter-spacing": + lineLayer.textLetterSpacing = expression; + break; + case "text-justify": + lineLayer.textJustify = expression; + break; + case "text-radial-offset": + lineLayer.textRadialOffset = expression; + break; + case "text-variable-anchor": + lineLayer.textVariableAnchor = expression; + break; + case "text-anchor": + lineLayer.textAnchor = expression; + break; + case "text-max-angle": + lineLayer.textMaxAngle = expression; + break; + case "text-writing-mode": + lineLayer.textWritingMode = expression; + break; + case "text-rotate": + lineLayer.textRotate = expression; + break; + case "text-padding": + lineLayer.textPadding = expression; + break; + case "text-keep-upright": + lineLayer.textKeepUpright = expression; + break; + case "text-transform": + lineLayer.textTransform = expression; + break; + case "text-offset": + lineLayer.textOffset = expression; + break; + case "text-allow-overlap": + lineLayer.textAllowOverlap = expression; + break; + case "text-ignore-placement": + lineLayer.textIgnorePlacement = expression; + break; + case "text-optional": + lineLayer.textOptional = expression; + break; + case "visibility": + lineLayer.visibility = expression; + break; + case "icon-opacity": + lineLayer.iconOpacity = expression; + break; + case "icon-color": + lineLayer.iconColor = expression; + break; + case "icon-halo-color": + lineLayer.iconHaloColor = expression; + break; + case "icon-halo-width": + lineLayer.iconHaloWidth = expression; + break; + case "icon-halo-blur": + lineLayer.iconHaloBlur = expression; + break; + case "icon-translate": + lineLayer.iconTranslate = expression; + break; + case "icon-translate-anchor": + lineLayer.iconTranslateAnchor = expression; + break; + case "text-opacity": + lineLayer.textOpacity = expression; + break; + case "text-color": + lineLayer.textColor = expression; + break; + case "text-halo-color": + lineLayer.textHaloColor = expression; + break; + case "text-halo-width": + lineLayer.textHaloWidth = expression; + break; + case "text-halo-blur": + lineLayer.textHaloBlur = expression; + break; + case "text-translate": + lineLayer.textTranslate = expression; + break; + case "text-translate-anchor": + lineLayer.textTranslateAnchor = expression; + break; + default: + break + } + } + } + + class func addFillProperties(fillLayer: MGLSFillStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + case "fill-sort-key": + fillLayer.fillSortKey = expression; + break; + case "visibility": + fillLayer.visibility = expression; + break; + case "fill-antialias": + fillLayer.fillAntialias = expression; + break; + case "fill-opacity": + fillLayer.fillOpacity = expression; + break; + case "fill-color": + fillLayer.fillColor = expression; + break; + case "fill-outline-color": + fillLayer.fillOutlineColor = expression; + break; + case "fill-translate": + fillLayer.fillTranslate = expression; + break; + case "fill-translate-anchor": + fillLayer.fillTranslateAnchor = expression; + break; + case "fill-pattern": + fillLayer.fillPattern = expression; + break; + default: + break + } + } + } + + private class func interpretExpression(expression: String) -> NSExpression? { + do { + let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: []) + return NSExpression.init(mglJSONObject: json) + } catch { + } + return nil + } +} diff --git a/pubspec.lock b/pubspec.lock index fdedccae0..9c562782d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -22,13 +22,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" crypto: dependency: transitive description: @@ -87,7 +80,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" path: dependency: transitive description: diff --git a/scripts/.dart_tool/package_config.json b/scripts/.dart_tool/package_config.json index b2ad6f247..4a2ee0818 100644 --- a/scripts/.dart_tool/package_config.json +++ b/scripts/.dart_tool/package_config.json @@ -3,13 +3,13 @@ "packages": [ { "name": "mustache", - "rootUri": "file:///Users/max/.pub-cache/hosted/pub.dartlang.org/mustache-1.1.1", + "rootUri": "file:///Users/ocell/.pub-cache/hosted/pub.dartlang.org/mustache-1.1.1", "packageUri": "lib/", "languageVersion": "2.0" }, { "name": "recase", - "rootUri": "file:///Users/max/.pub-cache/hosted/pub.dartlang.org/recase-3.0.0", + "rootUri": "file:///Users/ocell/.pub-cache/hosted/pub.dartlang.org/recase-3.0.0", "packageUri": "lib/", "languageVersion": "2.6" }, @@ -20,7 +20,7 @@ "languageVersion": "2.0" } ], - "generated": "2020-06-10T15:23:39.710811Z", + "generated": "2021-10-15T19:19:48.011972Z", "generator": "pub", - "generatorVersion": "2.8.4" + "generatorVersion": "2.14.3" } diff --git a/scripts/lib/generate_style_converters.dart b/scripts/lib/generate_style_converters.dart index 02b28ee50..4bda42c93 100644 --- a/scripts/lib/generate_style_converters.dart +++ b/scripts/lib/generate_style_converters.dart @@ -5,20 +5,42 @@ import 'package:mustache/mustache.dart'; import 'package:recase/recase.dart'; main() async { - var properties = []; - - var styleJson = jsonDecode(await new File('./scripts/input/style.json').readAsString()); - properties.addAll(styleJson["layout_line"].keys.followedBy(styleJson["paint_line"].keys) - .map((f) => { - 'hyphen': f, - 'camel': new ReCase(f).camelCase - }).toList()); - - var javaTemplate = await new File('./scripts/templates/java_template.txt').readAsString(); - var template = new Template(javaTemplate); - - var outputFile = new File('./android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java'); - outputFile.writeAsString(template.renderString({ - 'lineStyles': properties - })); -} \ No newline at end of file + var styleJson = + jsonDecode(await new File('./scripts/input/style.json').readAsString()); + + await renderTemplate(styleJson, "LayerPropertyConverter.template.java", + './android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java'); + + await renderTemplate(styleJson, "LayerPropertyConverter.template.swift", + "./ios/Classes/LayerPropertyConverter.swift"); +} + +Future renderTemplate(Map styleJson, String templateName, + String outputPath) async { + var javaTemplate = + await File('./scripts/templates/$templateName').readAsString(); + var template = Template(javaTemplate); + + var outputFile = File(outputPath); + final renderContext = { + 'lineStyles': buildStyleProperties(styleJson, "layout_line", "paint_line"), + 'fillStyles': buildStyleProperties(styleJson, "layout_fill", "paint_fill"), + 'circleStyles': + buildStyleProperties(styleJson, "layout_circle", "paint_circle"), + 'symbolStyles': + buildStyleProperties(styleJson, "layout_symbol", "paint_symbol") + }; + outputFile.writeAsString(template.renderString(renderContext)); +} + +List> buildStyleProperties( + Map styleJson, String layoutKey, String paintKey) { + final Map layout = styleJson[layoutKey]; + final Map paint = styleJson[paintKey]; + + return layout.keys + .followedBy(paint.keys) + .map((f) => + {'property': f, 'function': new ReCase(f).camelCase}) + .toList(); +} diff --git a/scripts/pubspec.yaml b/scripts/pubspec.yaml index d4c160b6e..49e28bd98 100644 --- a/scripts/pubspec.yaml +++ b/scripts/pubspec.yaml @@ -1,11 +1,10 @@ name: mapbox_code_gen description: Just a place to practice version: 0.0.1 -author: suragch environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: - mustache: 1.1.1 - recase: 3.0.0 + mustache_template: 1.1.1 + recase: 4.0.0 diff --git a/scripts/templates/LayerPropertyConverter.template.java b/scripts/templates/LayerPropertyConverter.template.java new file mode 100644 index 000000000..75ec99f10 --- /dev/null +++ b/scripts/templates/LayerPropertyConverter.template.java @@ -0,0 +1,98 @@ +// This file is generated by +// ./scripts/lib/generate_style_converters.dart + +package com.mapbox.mapboxgl; + +import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.PropertyFactory; +import com.mapbox.mapboxsdk.style.layers.PropertyValue; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import static com.mapbox.mapboxgl.Convert.toMap; + +class LayerPropertyConverter { + + static PropertyValue[] interpretLineLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + {{#lineStyles}} + case "{{property}}": + properties.add(PropertyFactory.{{function}}(expression)); + break; + {{/lineStyles}} + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + + static PropertyValue[] interpretSymbolLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + {{#symbolStyles}} + case "{{property}}": + properties.add(PropertyFactory.{{function}}(expression)); + break; + {{/symbolStyles}} + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + + static PropertyValue[] interpretCircleLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + {{#circleStyles}} + case "{{property}}": + properties.add(PropertyFactory.{{function}}(expression)); + break; + {{/circleStyles}} + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + + static PropertyValue[] interpretFillLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + {{#fillStyles}} + case "{{property}}": + properties.add(PropertyFactory.{{function}}(expression)); + break; + {{/fillStyles}} + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + +} \ No newline at end of file diff --git a/scripts/templates/LayerPropertyConverter.template.swift b/scripts/templates/LayerPropertyConverter.template.swift new file mode 100644 index 000000000..e5fd929ef --- /dev/null +++ b/scripts/templates/LayerPropertyConverter.template.swift @@ -0,0 +1,78 @@ +// This file is generated by +// ./scripts/lib/generate_style_converters.dart + +import Mapbox +import MapboxAnnotationExtension + +class LayerPropertyConverter { + class func addLineProperties(lineLayer: MGLLineStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + {{#lineStyles}} + case "{{property}}": + lineLayer.{{function}} = expression; + break; + {{/lineStyles}} + case "line-blur": + lineLayer.lineBlur = expression + default: + break + } + } + } + + class func addCircleProperties(circleLayer: MGLCircleStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + {{#circleStyles}} + case "{{property}}": + lineLayer.{{function}} = expression; + break; + {{/circleStyles}} + default: + break + } + } + } + + class func addSymbolProperties(symbolLayer: MGLSymbolStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + {{#symbolStyles}} + case "{{property}}": + lineLayer.{{function}} = expression; + break; + {{/symbolStyles}} + default: + break + } + } + } + + class func addFillProperties(fillLayer: MGLSFillStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + {{#fillStyles}} + case "{{property}}": + fillLayer.{{function}} = expression; + break; + {{/fillStyles}} + default: + break + } + } + } + + private class func interpretExpression(expression: String) -> NSExpression? { + do { + let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: []) + return NSExpression.init(mglJSONObject: json) + } catch { + } + return nil + } +} diff --git a/scripts/templates/java_template.txt b/scripts/templates/java_template.txt deleted file mode 100644 index 12b8172d5..000000000 --- a/scripts/templates/java_template.txt +++ /dev/null @@ -1,37 +0,0 @@ -// This file is generated. - -package com.mapbox.mapboxgl; - -import com.mapbox.mapboxsdk.style.expressions.Expression; -import com.mapbox.mapboxsdk.style.layers.PropertyFactory; -import com.mapbox.mapboxsdk.style.layers.PropertyValue; - -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import static com.mapbox.mapboxgl.Convert.toMap; - -class LayerPropertyConverter { - - static PropertyValue[] interpretLineLayerProperties(Object o) { - final Map data = (Map) toMap(o); - final List properties = new LinkedList(); - - for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); - switch (entry.getKey()) { - {{#lineStyles}} - case "{{hyphen}}": - properties.add(PropertyFactory.{{camel}}(expression)); - break; - {{/lineStyles}} - default: - break; - } - } - - return properties.toArray(new PropertyValue[properties.size()]); - } - -} \ No newline at end of file diff --git a/scripts/templates/swift_template.txt b/scripts/templates/swift_template.txt deleted file mode 100644 index e69de29bb..000000000 From 204bde1085f376d412f7e996ef5edf149cad8152 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Sat, 16 Oct 2021 00:47:06 +0200 Subject: [PATCH 07/33] cleaned generator code added dart template --- .../mapboxgl/LayerPropertyConverter.java | 2 +- ios/Classes/LayerPropertyConverter.swift | 2 +- lib/src/layer_helper.dart | 191 ++++++++++++++++++ scripts/.dart_tool/package_config.json | 14 +- scripts/lib/generate.dart | 104 ++++++++++ scripts/lib/generate_style_converters.dart | 46 ----- scripts/pubspec.lock | 10 +- scripts/pubspec.yaml | 4 +- ...a => LayerPropertyConverter.java.template} | 34 ++-- ... => LayerPropertyConverter.swift.template} | 34 ++-- scripts/templates/dart_template.txt | 0 scripts/templates/layer_helper.dart.template | 32 +++ 12 files changed, 377 insertions(+), 96 deletions(-) create mode 100644 lib/src/layer_helper.dart create mode 100644 scripts/lib/generate.dart delete mode 100644 scripts/lib/generate_style_converters.dart rename scripts/templates/{LayerPropertyConverter.template.java => LayerPropertyConverter.java.template} (78%) rename scripts/templates/{LayerPropertyConverter.template.swift => LayerPropertyConverter.swift.template} (73%) delete mode 100644 scripts/templates/dart_template.txt create mode 100644 scripts/templates/layer_helper.dart.template diff --git a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java index 46e83d22e..7b58664d1 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java +++ b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java @@ -1,5 +1,5 @@ // This file is generated by -// ./scripts/lib/generate_style_converters.dart +// ./scripts/lib/generate.dart package com.mapbox.mapboxgl; diff --git a/ios/Classes/LayerPropertyConverter.swift b/ios/Classes/LayerPropertyConverter.swift index bfb4cac97..45cf3efc3 100644 --- a/ios/Classes/LayerPropertyConverter.swift +++ b/ios/Classes/LayerPropertyConverter.swift @@ -1,5 +1,5 @@ // This file is generated by -// ./scripts/lib/generate_style_converters.dart +// ./scripts/lib/generate.dart import Mapbox import MapboxAnnotationExtension diff --git a/lib/src/layer_helper.dart b/lib/src/layer_helper.dart new file mode 100644 index 000000000..ed80f2db6 --- /dev/null +++ b/lib/src/layer_helper.dart @@ -0,0 +1,191 @@ +// This file is generated by +// ./scripts/lib/generate.dart + +class FillProperties{ + static const fillSortKey = "fill-sort-key"; + static const visibility = "visibility"; + static const fillAntialias = "fill-antialias"; + static const fillOpacity = "fill-opacity"; + static const fillColor = "fill-color"; + static const fillOutlineColor = "fill-outline-color"; + static const fillTranslate = "fill-translate"; + static const fillTranslateAnchor = "fill-translate-anchor"; + static const fillPattern = "fill-pattern"; +} + +class LineProperties{ + static const lineCap = "line-cap"; + static const lineJoin = "line-join"; + static const lineMiterLimit = "line-miter-limit"; + static const lineRoundLimit = "line-round-limit"; + static const lineSortKey = "line-sort-key"; + static const visibility = "visibility"; + static const lineOpacity = "line-opacity"; + static const lineColor = "line-color"; + static const lineTranslate = "line-translate"; + static const lineTranslateAnchor = "line-translate-anchor"; + static const lineWidth = "line-width"; + static const lineGapWidth = "line-gap-width"; + static const lineOffset = "line-offset"; + static const lineBlur = "line-blur"; + static const lineDasharray = "line-dasharray"; + static const linePattern = "line-pattern"; + static const lineGradient = "line-gradient"; +} + +class CricleProperties{ + static const circleSortKey = "circle-sort-key"; + static const visibility = "visibility"; + static const circleRadius = "circle-radius"; + static const circleColor = "circle-color"; + static const circleBlur = "circle-blur"; + static const circleOpacity = "circle-opacity"; + static const circleTranslate = "circle-translate"; + static const circleTranslateAnchor = "circle-translate-anchor"; + static const circlePitchScale = "circle-pitch-scale"; + static const circlePitchAlignment = "circle-pitch-alignment"; + static const circleStrokeWidth = "circle-stroke-width"; + static const circleStrokeColor = "circle-stroke-color"; + static const circleStrokeOpacity = "circle-stroke-opacity"; +} + +class SymbolProperties{ + static const symbolPlacement = "symbol-placement"; + static const symbolSpacing = "symbol-spacing"; + static const symbolAvoidEdges = "symbol-avoid-edges"; + static const symbolSortKey = "symbol-sort-key"; + static const symbolZOrder = "symbol-z-order"; + static const iconAllowOverlap = "icon-allow-overlap"; + static const iconIgnorePlacement = "icon-ignore-placement"; + static const iconOptional = "icon-optional"; + static const iconRotationAlignment = "icon-rotation-alignment"; + static const iconSize = "icon-size"; + static const iconTextFit = "icon-text-fit"; + static const iconTextFitPadding = "icon-text-fit-padding"; + static const iconImage = "icon-image"; + static const iconRotate = "icon-rotate"; + static const iconPadding = "icon-padding"; + static const iconKeepUpright = "icon-keep-upright"; + static const iconOffset = "icon-offset"; + static const iconAnchor = "icon-anchor"; + static const iconPitchAlignment = "icon-pitch-alignment"; + static const textPitchAlignment = "text-pitch-alignment"; + static const textRotationAlignment = "text-rotation-alignment"; + static const textField = "text-field"; + static const textFont = "text-font"; + static const textSize = "text-size"; + static const textMaxWidth = "text-max-width"; + static const textLineHeight = "text-line-height"; + static const textLetterSpacing = "text-letter-spacing"; + static const textJustify = "text-justify"; + static const textRadialOffset = "text-radial-offset"; + static const textVariableAnchor = "text-variable-anchor"; + static const textAnchor = "text-anchor"; + static const textMaxAngle = "text-max-angle"; + static const textWritingMode = "text-writing-mode"; + static const textRotate = "text-rotate"; + static const textPadding = "text-padding"; + static const textKeepUpright = "text-keep-upright"; + static const textTransform = "text-transform"; + static const textOffset = "text-offset"; + static const textAllowOverlap = "text-allow-overlap"; + static const textIgnorePlacement = "text-ignore-placement"; + static const textOptional = "text-optional"; + static const visibility = "visibility"; + static const iconOpacity = "icon-opacity"; + static const iconColor = "icon-color"; + static const iconHaloColor = "icon-halo-color"; + static const iconHaloWidth = "icon-halo-width"; + static const iconHaloBlur = "icon-halo-blur"; + static const iconTranslate = "icon-translate"; + static const iconTranslateAnchor = "icon-translate-anchor"; + static const textOpacity = "text-opacity"; + static const textColor = "text-color"; + static const textHaloColor = "text-halo-color"; + static const textHaloWidth = "text-halo-width"; + static const textHaloBlur = "text-halo-blur"; + static const textTranslate = "text-translate"; + static const textTranslateAnchor = "text-translate-anchor"; +} + +class Expressions{ + static const let = "let"; + static const varExpression = "var"; + static const literal = "literal"; + static const array = "array"; + static const at = "at"; + static const inExpression = "in"; + static const caseExpression = "case"; + static const match = "match"; + static const coalesce = "coalesce"; + static const step = "step"; + static const interpolate = "interpolate"; + static const interpolateHcl = "interpolate-hcl"; + static const interpolateLab = "interpolate-lab"; + static const ln2 = "ln2"; + static const pi = "pi"; + static const e = "e"; + static const typeof = "typeof"; + static const string = "string"; + static const number = "number"; + static const boolean = "boolean"; + static const object = "object"; + static const collator = "collator"; + static const format = "format"; + static const image = "image"; + static const numberFormat = "number-format"; + static const toStringExpression = "to-string"; + static const toNumber = "to-number"; + static const toBoolean = "to-boolean"; + static const toRgba = "to-rgba"; + static const toColor = "to-color"; + static const rgb = "rgb"; + static const rgba = "rgba"; + static const get = "get"; + static const has = "has"; + static const length = "length"; + static const properties = "properties"; + static const featureState = "feature-state"; + static const geometryType = "geometry-type"; + static const id = "id"; + static const zoom = "zoom"; + static const heatmapDensity = "heatmap-density"; + static const lineProgress = "line-progress"; + static const accumulated = "accumulated"; + static const plus = "+"; + static const multiply = "*"; + static const minus = "-"; + static const divide = "/"; + static const precent = "%"; + static const xor = "^"; + static const sqrt = "sqrt"; + static const log10 = "log10"; + static const ln = "ln"; + static const log2 = "log2"; + static const sin = "sin"; + static const cos = "cos"; + static const tan = "tan"; + static const asin = "asin"; + static const acos = "acos"; + static const atan = "atan"; + static const min = "min"; + static const max = "max"; + static const round = "round"; + static const abs = "abs"; + static const ceil = "ceil"; + static const floor = "floor"; + static const equal = "=="; + static const notEqual = "!="; + static const larger = ">"; + static const smaller = "<"; + static const largerOrEqual = ">="; + static const smallerOrEqual = "<="; + static const all = "all"; + static const any = "any"; + static const not = "!"; + static const isSupportedScript = "is-supported-script"; + static const upcase = "upcase"; + static const downcase = "downcase"; + static const concat = "concat"; + static const resolvedLocale = "resolved-locale"; +} diff --git a/scripts/.dart_tool/package_config.json b/scripts/.dart_tool/package_config.json index 4a2ee0818..1b24c83f0 100644 --- a/scripts/.dart_tool/package_config.json +++ b/scripts/.dart_tool/package_config.json @@ -2,25 +2,25 @@ "configVersion": 2, "packages": [ { - "name": "mustache", - "rootUri": "file:///Users/ocell/.pub-cache/hosted/pub.dartlang.org/mustache-1.1.1", + "name": "mustache_template", + "rootUri": "file:///Users/ocell/.pub-cache/hosted/pub.dartlang.org/mustache_template-2.0.0", "packageUri": "lib/", - "languageVersion": "2.0" + "languageVersion": "2.12" }, { "name": "recase", - "rootUri": "file:///Users/ocell/.pub-cache/hosted/pub.dartlang.org/recase-3.0.0", + "rootUri": "file:///Users/ocell/.pub-cache/hosted/pub.dartlang.org/recase-4.0.0", "packageUri": "lib/", - "languageVersion": "2.6" + "languageVersion": "2.12" }, { "name": "mapbox_code_gen", "rootUri": "../", "packageUri": "lib/", - "languageVersion": "2.0" + "languageVersion": "2.12" } ], - "generated": "2021-10-15T19:19:48.011972Z", + "generated": "2021-10-15T22:46:38.145356Z", "generator": "pub", "generatorVersion": "2.14.3" } diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart new file mode 100644 index 000000000..68026b825 --- /dev/null +++ b/scripts/lib/generate.dart @@ -0,0 +1,104 @@ +import 'dart:io'; +import 'dart:convert'; + +import 'package:mustache_template/mustache_template.dart'; +import 'package:recase/recase.dart'; + +main() async { + var styleJson = + jsonDecode(await new File('./scripts/input/style.json').readAsString()); + + final renderContext = { + 'lineProperties': buildStyleProperties(styleJson, "layout_line") + + buildStyleProperties(styleJson, "paint_line"), + 'fillProperties': buildStyleProperties(styleJson, "layout_fill") + + buildStyleProperties(styleJson, "paint_fill"), + 'circleProperties': buildStyleProperties(styleJson, "layout_circle") + + buildStyleProperties(styleJson, "paint_circle"), + 'symbolProperties': buildStyleProperties(styleJson, "layout_symbol") + + buildStyleProperties(styleJson, "paint_symbol"), + 'expressions': buildExpressionProperties(styleJson) + }; + + await renderLayerPropertyConverter( + renderContext, + "java", + './android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java', + ); + await renderLayerPropertyConverter( + renderContext, + "swift", + "./ios/Classes/LayerPropertyConverter.swift", + ); + + await renderDart(renderContext); +} + +Future renderLayerPropertyConverter(Map renderContext, + String templateType, String outputPath) async { + var templateFile = await File( + './scripts/templates/LayerPropertyConverter.$templateType.template') + .readAsString(); + + var template = Template(templateFile); + var outputFile = File(outputPath); + + outputFile.writeAsString(template.renderString(renderContext)); +} + +Future renderDart( + Map renderContext, +) async { + var templateFile = + await File('./scripts/templates/layer_helper.dart.template') + .readAsString(); + + var template = Template(templateFile); + var outputFile = File("./lib/src/layer_helper.dart"); + + outputFile.writeAsString(template.renderString(renderContext)); +} + +List> buildStyleProperties( + Map styleJson, String key) { + final Map items = styleJson[key]; + + return items.keys + .map((f) => { + 'value': f, + 'valueAsCamelCase': new ReCase(f).camelCase + }) + .toList(); +} + +List> buildExpressionProperties( + Map styleJson) { + final Map items = styleJson["expression_name"]["values"]; + + final renamed = { + "var": "varExpression", + "in": "inExpression", + "case": "caseExpression", + "to-string": "toStringExpression", + "+": "plus", + "*": "multiply", + "-": "minus", + "%": "precent", + ">": "larger", + ">=": "largerOrEqual", + "<": "smaller", + "<=": "smallerOrEqual", + "!=": "notEqual", + "==": "equal", + "/": "divide", + "^": "xor", + "!": "not", + }; + + return items.keys + .map((f) => { + 'value': f, + 'valueAsCamelCase': new ReCase(renamed[f] ?? f).camelCase + }) + .toList(); +} diff --git a/scripts/lib/generate_style_converters.dart b/scripts/lib/generate_style_converters.dart deleted file mode 100644 index 4bda42c93..000000000 --- a/scripts/lib/generate_style_converters.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'dart:io'; -import 'dart:convert'; - -import 'package:mustache/mustache.dart'; -import 'package:recase/recase.dart'; - -main() async { - var styleJson = - jsonDecode(await new File('./scripts/input/style.json').readAsString()); - - await renderTemplate(styleJson, "LayerPropertyConverter.template.java", - './android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java'); - - await renderTemplate(styleJson, "LayerPropertyConverter.template.swift", - "./ios/Classes/LayerPropertyConverter.swift"); -} - -Future renderTemplate(Map styleJson, String templateName, - String outputPath) async { - var javaTemplate = - await File('./scripts/templates/$templateName').readAsString(); - var template = Template(javaTemplate); - - var outputFile = File(outputPath); - final renderContext = { - 'lineStyles': buildStyleProperties(styleJson, "layout_line", "paint_line"), - 'fillStyles': buildStyleProperties(styleJson, "layout_fill", "paint_fill"), - 'circleStyles': - buildStyleProperties(styleJson, "layout_circle", "paint_circle"), - 'symbolStyles': - buildStyleProperties(styleJson, "layout_symbol", "paint_symbol") - }; - outputFile.writeAsString(template.renderString(renderContext)); -} - -List> buildStyleProperties( - Map styleJson, String layoutKey, String paintKey) { - final Map layout = styleJson[layoutKey]; - final Map paint = styleJson[paintKey]; - - return layout.keys - .followedBy(paint.keys) - .map((f) => - {'property': f, 'function': new ReCase(f).camelCase}) - .toList(); -} diff --git a/scripts/pubspec.lock b/scripts/pubspec.lock index ddab59885..fed710049 100644 --- a/scripts/pubspec.lock +++ b/scripts/pubspec.lock @@ -1,19 +1,19 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - mustache: + mustache_template: dependency: "direct main" description: - name: mustache + name: mustache_template url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "2.0.0" recase: dependency: "direct main" description: name: recase url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "4.0.0" sdks: - dart: ">=2.6.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/scripts/pubspec.yaml b/scripts/pubspec.yaml index 49e28bd98..a49569e18 100644 --- a/scripts/pubspec.yaml +++ b/scripts/pubspec.yaml @@ -6,5 +6,5 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - mustache_template: 1.1.1 - recase: 4.0.0 + mustache_template: ^2.0.0 + recase: ^4.0.0 diff --git a/scripts/templates/LayerPropertyConverter.template.java b/scripts/templates/LayerPropertyConverter.java.template similarity index 78% rename from scripts/templates/LayerPropertyConverter.template.java rename to scripts/templates/LayerPropertyConverter.java.template index 75ec99f10..872528372 100644 --- a/scripts/templates/LayerPropertyConverter.template.java +++ b/scripts/templates/LayerPropertyConverter.java.template @@ -1,5 +1,5 @@ // This file is generated by -// ./scripts/lib/generate_style_converters.dart +// ./scripts/lib/generate.dart package com.mapbox.mapboxgl; @@ -22,11 +22,11 @@ static PropertyValue[] interpretLineLayerProperties(Object o) { for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { - {{#lineStyles}} - case "{{property}}": - properties.add(PropertyFactory.{{function}}(expression)); + {{#lineProperties}} + case "{{{value}}}": + properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); break; - {{/lineStyles}} + {{/lineProperties}} default: break; } @@ -42,11 +42,11 @@ static PropertyValue[] interpretSymbolLayerProperties(Object o) { for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { - {{#symbolStyles}} - case "{{property}}": - properties.add(PropertyFactory.{{function}}(expression)); + {{#symbolProperties}} + case "{{{value}}}": + properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); break; - {{/symbolStyles}} + {{/symbolProperties}} default: break; } @@ -62,11 +62,11 @@ static PropertyValue[] interpretCircleLayerProperties(Object o) { for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { - {{#circleStyles}} - case "{{property}}": - properties.add(PropertyFactory.{{function}}(expression)); + {{#circleProperties}} + case "{{{value}}}": + properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); break; - {{/circleStyles}} + {{/circleProperties}} default: break; } @@ -82,11 +82,11 @@ static PropertyValue[] interpretFillLayerProperties(Object o) { for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { - {{#fillStyles}} - case "{{property}}": - properties.add(PropertyFactory.{{function}}(expression)); + {{#fillProperties}} + case "{{{value}}}": + properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); break; - {{/fillStyles}} + {{/fillProperties}} default: break; } diff --git a/scripts/templates/LayerPropertyConverter.template.swift b/scripts/templates/LayerPropertyConverter.swift.template similarity index 73% rename from scripts/templates/LayerPropertyConverter.template.swift rename to scripts/templates/LayerPropertyConverter.swift.template index e5fd929ef..78559e335 100644 --- a/scripts/templates/LayerPropertyConverter.template.swift +++ b/scripts/templates/LayerPropertyConverter.swift.template @@ -1,5 +1,5 @@ // This file is generated by -// ./scripts/lib/generate_style_converters.dart +// ./scripts/lib/generate.dart import Mapbox import MapboxAnnotationExtension @@ -9,11 +9,11 @@ class LayerPropertyConverter { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { - {{#lineStyles}} - case "{{property}}": - lineLayer.{{function}} = expression; + {{#lineProperties}} + case "{{{value}}}": + lineLayer.{{valueAsCamelCase}} = expression; break; - {{/lineStyles}} + {{/lineProperties}} case "line-blur": lineLayer.lineBlur = expression default: @@ -26,11 +26,11 @@ class LayerPropertyConverter { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { - {{#circleStyles}} - case "{{property}}": - lineLayer.{{function}} = expression; + {{#circleProperties}} + case "{{{value}}}": + lineLayer.{{valueAsCamelCase}} = expression; break; - {{/circleStyles}} + {{/circleProperties}} default: break } @@ -41,11 +41,11 @@ class LayerPropertyConverter { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { - {{#symbolStyles}} - case "{{property}}": - lineLayer.{{function}} = expression; + {{#symbolProperties}} + case "{{{value}}}": + lineLayer.{{valueAsCamelCase}} = expression; break; - {{/symbolStyles}} + {{/symbolProperties}} default: break } @@ -56,11 +56,11 @@ class LayerPropertyConverter { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { - {{#fillStyles}} - case "{{property}}": - fillLayer.{{function}} = expression; + {{#fillProperties}} + case "{{{value}}}": + fillLayer.{{valueAsCamelCase}} = expression; break; - {{/fillStyles}} + {{/fillProperties}} default: break } diff --git a/scripts/templates/dart_template.txt b/scripts/templates/dart_template.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/scripts/templates/layer_helper.dart.template b/scripts/templates/layer_helper.dart.template new file mode 100644 index 000000000..b5fdade8f --- /dev/null +++ b/scripts/templates/layer_helper.dart.template @@ -0,0 +1,32 @@ +// This file is generated by +// ./scripts/lib/generate.dart + +class FillProperties{ + {{#fillProperties}} + static const {{valueAsCamelCase}} = "{{{value}}}"; + {{/fillProperties}} +} + +class LineProperties{ + {{#lineProperties}} + static const {{valueAsCamelCase}} = "{{{value}}}"; + {{/lineProperties}} +} + +class CricleProperties{ + {{#circleProperties}} + static const {{valueAsCamelCase}} = "{{{value}}}"; + {{/circleProperties}} +} + +class SymbolProperties{ + {{#symbolProperties}} + static const {{valueAsCamelCase}} = "{{{value}}}"; + {{/symbolProperties}} +} + +class Expressions{ + {{#expressions}} + static const {{valueAsCamelCase}} = "{{{value}}}"; + {{/expressions}} +} From 3c3352e89123a587c361b7ce9ded520f7779b5cf Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Wed, 20 Oct 2021 16:21:47 +0200 Subject: [PATCH 08/33] improved generation --- .../java/com/mapbox/mapboxgl/Convert.java | 235 ---------------- .../mapboxgl/LayerPropertyConverter.java | 133 +++++---- .../mapbox/mapboxgl/MapboxMapController.java | 40 ++- ios/Classes/LayerPropertyConverter.swift | 252 +++++++++--------- ios/Classes/MapboxMapController.swift | 30 ++- lib/src/controller.dart | 14 +- lib/src/layer_helper.dart | 109 ++++---- .../lib/src/mapbox_gl_platform_interface.dart | 6 +- .../lib/src/method_channel_mapbox_gl.dart | 11 +- scripts/.dart_tool/package_config.json | 2 +- scripts/lib/generate.dart | 20 +- .../LayerPropertyConverter.java.template | 71 +---- .../LayerPropertyConverter.swift.template | 53 +--- scripts/templates/layer_helper.dart.template | 28 +- 14 files changed, 363 insertions(+), 641 deletions(-) diff --git a/android/src/main/java/com/mapbox/mapboxgl/Convert.java b/android/src/main/java/com/mapbox/mapboxgl/Convert.java index 9a5eb09bc..3a52faf0e 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/Convert.java +++ b/android/src/main/java/com/mapbox/mapboxgl/Convert.java @@ -557,240 +557,5 @@ static void interpretFillOptions(Object o, FillOptionsSink sink) { if (draggable != null) { sink.setDraggable(toBoolean(draggable)); } - static PropertyValue[] interpretSymbolLayerProperties(Object o) { - final Map data = (Map) toMap(o); - final List properties = new LinkedList(); - - for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); - switch (entry.getKey()) { - case "icon-allow-overlap": - properties.add(PropertyFactory.iconAllowOverlap(expression)); - break; - case "icon-anchor": - properties.add(PropertyFactory.iconAnchor(expression)); - break; - case "icon-color": - properties.add(PropertyFactory.iconColor(expression)); - break; - case "icon-halo-blur": - properties.add(PropertyFactory.iconHaloBlur(expression)); - break; - case "icon-halo-color": - properties.add(PropertyFactory.iconHaloColor(expression)); - break; - case "icon-halo-width": - properties.add(PropertyFactory.iconHaloWidth(expression)); - break; - case "icon-ignore-placement": - properties.add(PropertyFactory.iconIgnorePlacement(expression)); - break; - case "icon-image": - properties.add(PropertyFactory.iconImage(expression)); - break; - case "icon-keep-upright": - properties.add(PropertyFactory.iconKeepUpright(expression)); - break; - case "icon-offset": - properties.add(PropertyFactory.iconOffset(expression)); - break; - case "icon-opacity": - properties.add(PropertyFactory.iconOpacity(expression)); - break; - case "icon-optional": - properties.add(PropertyFactory.iconOptional(expression)); - break; - case "icon-padding": - properties.add(PropertyFactory.iconPadding(expression)); - break; - case "icon-pitch-alignment": - properties.add(PropertyFactory.iconPitchAlignment(expression)); - break; - case "icon-rotate": - properties.add(PropertyFactory.iconRotate(expression)); - break; - case "icon-rotation-alignment": - properties.add(PropertyFactory.iconRotationAlignment(expression)); - break; - case "icon-size": - properties.add(PropertyFactory.iconSize(expression)); - break; - case "icon-text-fit": - properties.add(PropertyFactory.iconTextFit(expression)); - break; - case "icon-text-fit-padding": - properties.add(PropertyFactory.iconTextFitPadding(expression)); - break; - case "icon-translate": - properties.add(PropertyFactory.iconTranslate(expression)); - break; - case "icon-translate-anchor": - properties.add(PropertyFactory.iconTranslateAnchor(expression)); - break; - case "symbol-avoid-edges": - properties.add(PropertyFactory.symbolAvoidEdges(expression)); - break; - case "symbol-placement": - properties.add(PropertyFactory.symbolPlacement(expression)); - break; - case "symbol-sort-key": - properties.add(PropertyFactory.symbolSortKey(expression)); - break; - case "symbol-spacing": - properties.add(PropertyFactory.symbolSpacing(expression)); - break; - case "symbol-z-order": - properties.add(PropertyFactory.symbolZOrder(expression)); - break; - case "text-allow-overlap": - properties.add(PropertyFactory.textAllowOverlap(expression)); - break; - case "text-anchor": - properties.add(PropertyFactory.textAnchor(expression)); - break; - case "text-color": - properties.add(PropertyFactory.textColor(expression)); - break; - case "text-field": - properties.add(PropertyFactory.textField(expression)); - break; - case "text-font": - properties.add(PropertyFactory.textFont(expression)); - break; - case "text-halo-blur": - properties.add(PropertyFactory.textHaloBlur(expression)); - break; - case "text-halo-color": - properties.add(PropertyFactory.textHaloColor(expression)); - break; - case "text-halo-width": - properties.add(PropertyFactory.textHaloWidth(expression)); - break; - case "text-ignore-placement": - properties.add(PropertyFactory.textIgnorePlacement(expression)); - break; - case "text-justify": - properties.add(PropertyFactory.textJustify(expression)); - break; - case "text-keep-upright": - properties.add(PropertyFactory.textKeepUpright(expression)); - break; - case "text-letter-spacing": - properties.add(PropertyFactory.textLetterSpacing(expression)); - break; - case "text-line-height": - properties.add(PropertyFactory.textLineHeight(expression)); - break; - case "text-max-angle": - properties.add(PropertyFactory.textMaxAngle(expression)); - break; - case "text-max-width": - properties.add(PropertyFactory.textMaxWidth(expression)); - break; - case "text-offset": - properties.add(PropertyFactory.textOffset(expression)); - break; - case "text-opacity": - properties.add(PropertyFactory.textOpacity(expression)); - break; - case "text-optional": - properties.add(PropertyFactory.textOptional(expression)); - break; - case "text-padding": - properties.add(PropertyFactory.textPadding(expression)); - break; - case "text-pitch-alignment": - properties.add(PropertyFactory.textPitchAlignment(expression)); - break; - case "text-radial-offset": - properties.add(PropertyFactory.textRadialOffset(expression)); - break; - case "text-rotate": - properties.add(PropertyFactory.textRotate(expression)); - break; - case "text-rotation-alignment": - properties.add(PropertyFactory.textRotationAlignment(expression)); - break; - case "text-size": - properties.add(PropertyFactory.textSize(expression)); - break; - case "text-transform": - properties.add(PropertyFactory.textTransform(expression)); - break; - case "text-translate": - properties.add(PropertyFactory.textTranslate(expression)); - break; - case "text-translate-anchor": - properties.add(PropertyFactory.textTranslateAnchor(expression)); - break; - case "text-variable-anchor": - properties.add(PropertyFactory.textVariableAnchor(expression)); - break; - case "text-writing-mode": - properties.add(PropertyFactory.textWritingMode(expression)); - break; - default: - break; - } - } - - return properties.toArray(new PropertyValue[properties.size()]); - } - - static PropertyValue[] interpretLineLayerProperties(Object o) { - final Map data = (Map) toMap(o); - final List properties = new LinkedList(); - - for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); - switch(entry.getKey()) { - case "line-blur": - properties.add(PropertyFactory.lineBlur(expression)); - break; - case "line-cap": - properties.add(PropertyFactory.lineCap(expression)); - break; - case "line-color": - properties.add(PropertyFactory.lineColor(expression)); - break; - case "line-dasharray": - properties.add(PropertyFactory.lineDasharray(expression)); - break; - case "line-gap-width": - properties.add(PropertyFactory.lineGapWidth(expression)); - break; - case "line-gradient": - properties.add(PropertyFactory.lineGradient(expression)); - break; - case "line-join": - properties.add(PropertyFactory.lineJoin(expression)); - break; - case "line-miter-limit": - properties.add(PropertyFactory.lineMiterLimit(expression)); - break; - case "line-offset": - properties.add(PropertyFactory.lineOffset(expression)); - break; - case "line-pattern": - properties.add(PropertyFactory.linePattern(expression)); - break; - case "line-round-limit": - properties.add(PropertyFactory.lineRoundLimit(expression)); - break; - case "line-translate": - properties.add(PropertyFactory.lineTranslate(expression)); - break; - case "line-translate-anchor": - properties.add(PropertyFactory.lineTranslateAnchor(expression)); - break; - case "line-width": - properties.add(PropertyFactory.lineWidth(expression)); - break; - default: - break; - } - } - - return properties.toArray(new PropertyValue[properties.size()]); } } \ No newline at end of file diff --git a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java index 7b58664d1..53656213c 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java +++ b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java @@ -14,73 +14,6 @@ import static com.mapbox.mapboxgl.Convert.toMap; class LayerPropertyConverter { - - static PropertyValue[] interpretLineLayerProperties(Object o) { - final Map data = (Map) toMap(o); - final List properties = new LinkedList(); - - for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); - switch (entry.getKey()) { - case "line-cap": - properties.add(PropertyFactory.lineCap(expression)); - break; - case "line-join": - properties.add(PropertyFactory.lineJoin(expression)); - break; - case "line-miter-limit": - properties.add(PropertyFactory.lineMiterLimit(expression)); - break; - case "line-round-limit": - properties.add(PropertyFactory.lineRoundLimit(expression)); - break; - case "line-sort-key": - properties.add(PropertyFactory.lineSortKey(expression)); - break; - case "visibility": - properties.add(PropertyFactory.visibility(expression)); - break; - case "line-opacity": - properties.add(PropertyFactory.lineOpacity(expression)); - break; - case "line-color": - properties.add(PropertyFactory.lineColor(expression)); - break; - case "line-translate": - properties.add(PropertyFactory.lineTranslate(expression)); - break; - case "line-translate-anchor": - properties.add(PropertyFactory.lineTranslateAnchor(expression)); - break; - case "line-width": - properties.add(PropertyFactory.lineWidth(expression)); - break; - case "line-gap-width": - properties.add(PropertyFactory.lineGapWidth(expression)); - break; - case "line-offset": - properties.add(PropertyFactory.lineOffset(expression)); - break; - case "line-blur": - properties.add(PropertyFactory.lineBlur(expression)); - break; - case "line-dasharray": - properties.add(PropertyFactory.lineDasharray(expression)); - break; - case "line-pattern": - properties.add(PropertyFactory.linePattern(expression)); - break; - case "line-gradient": - properties.add(PropertyFactory.lineGradient(expression)); - break; - default: - break; - } - } - - return properties.toArray(new PropertyValue[properties.size()]); - } - static PropertyValue[] interpretSymbolLayerProperties(Object o) { final Map data = (Map) toMap(o); final List properties = new LinkedList(); @@ -318,6 +251,72 @@ static PropertyValue[] interpretCircleLayerProperties(Object o) { return properties.toArray(new PropertyValue[properties.size()]); } + static PropertyValue[] interpretLineLayerProperties(Object o) { + final Map data = (Map) toMap(o); + final List properties = new LinkedList(); + + for (Map.Entry entry : data.entrySet()) { + Expression expression = Expression.Converter.convert(entry.getValue()); + switch (entry.getKey()) { + case "line-cap": + properties.add(PropertyFactory.lineCap(expression)); + break; + case "line-join": + properties.add(PropertyFactory.lineJoin(expression)); + break; + case "line-miter-limit": + properties.add(PropertyFactory.lineMiterLimit(expression)); + break; + case "line-round-limit": + properties.add(PropertyFactory.lineRoundLimit(expression)); + break; + case "line-sort-key": + properties.add(PropertyFactory.lineSortKey(expression)); + break; + case "visibility": + properties.add(PropertyFactory.visibility(expression)); + break; + case "line-opacity": + properties.add(PropertyFactory.lineOpacity(expression)); + break; + case "line-color": + properties.add(PropertyFactory.lineColor(expression)); + break; + case "line-translate": + properties.add(PropertyFactory.lineTranslate(expression)); + break; + case "line-translate-anchor": + properties.add(PropertyFactory.lineTranslateAnchor(expression)); + break; + case "line-width": + properties.add(PropertyFactory.lineWidth(expression)); + break; + case "line-gap-width": + properties.add(PropertyFactory.lineGapWidth(expression)); + break; + case "line-offset": + properties.add(PropertyFactory.lineOffset(expression)); + break; + case "line-blur": + properties.add(PropertyFactory.lineBlur(expression)); + break; + case "line-dasharray": + properties.add(PropertyFactory.lineDasharray(expression)); + break; + case "line-pattern": + properties.add(PropertyFactory.linePattern(expression)); + break; + case "line-gradient": + properties.add(PropertyFactory.lineGradient(expression)); + break; + default: + break; + } + } + + return properties.toArray(new PropertyValue[properties.size()]); + } + static PropertyValue[] interpretFillLayerProperties(Object o) { final Map data = (Map) toMap(o); final List properties = new LinkedList(); diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index c68cad4cc..384943909 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -416,6 +416,28 @@ private void addLineLayer(String layerName, style.addLayer(lineLayer); } + private void addFillLayer(String layerName, + String sourceName, + PropertyValue[] properties, + Expression filter) { + LineLayer fillLayer = new FillLayer(layerName, sourceName); + + fillLayer.setProperties(properties); + + style.addLayer(fillLayer); + } + + private void addCircleLayer(String layerName, + String sourceName, + PropertyValue[] properties, + Expression filter) { + LineLayer circleLayer = new CircleLayer(layerName, sourceName); + + circleLayer.setProperties(properties); + + style.addLayer(circleLayer); + } + private void enableSymbolManager(@NonNull Style style) { if (symbolManager == null) { symbolManager = new SymbolManager(mapView, mapboxMap, style); @@ -955,17 +977,31 @@ public void onError(@NonNull String message) { case "symbolLayer#add": { final String sourceId = call.argument("sourceId"); final String layerId = call.argument("layerId"); - final PropertyValue[] properties = Convert.interpretSymbolLayerProperties(call.argument("properties")); + final PropertyValue[] properties = LayerPropertyConverter.interpretSymbolLayerProperties(call.argument("properties")); addSymbolLayer(layerId, sourceId, properties, null); break; } case "lineLayer#add": { final String sourceId = call.argument("sourceId"); final String layerId = call.argument("layerId"); - final PropertyValue[] properties = Convert.interpretLineLayerProperties(call.argument("properties")); + final PropertyValue[] properties = LayerPropertyConverter.interpretLineLayerProperties(call.argument("properties")); addLineLayer(layerId, sourceId, properties, null); break; } + case "fillLayer#add": { + final String sourceId = call.argument("sourceId"); + final String layerId = call.argument("layerId"); + final PropertyValue[] properties = LayerPropertyConverter.interpretFillLayerProperties(call.argument("properties")); + addFillLayer(layerId, sourceId, properties, null); + break; + } + case "circleLayer#add": { + final String sourceId = call.argument("sourceId"); + final String layerId = call.argument("layerId"); + final PropertyValue[] properties = LayerPropertyConverter.interpretCircleLayerProperties(call.argument("properties")); + addCircleLayer(layerId, sourceId, properties, null); + break; + } case "locationComponent#getLastLocation": { Log.e(TAG, "location component: getLastLocation"); if (this.myLocationEnabled && locationComponent != null && locationEngine != null) { diff --git a/ios/Classes/LayerPropertyConverter.swift b/ios/Classes/LayerPropertyConverter.swift index 45cf3efc3..b06547ee4 100644 --- a/ios/Classes/LayerPropertyConverter.swift +++ b/ios/Classes/LayerPropertyConverter.swift @@ -5,118 +5,6 @@ import Mapbox import MapboxAnnotationExtension class LayerPropertyConverter { - class func addLineProperties(lineLayer: MGLLineStyleLayer, properties: [String: String]) { - for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) - switch propertyName { - case "line-cap": - lineLayer.lineCap = expression; - break; - case "line-join": - lineLayer.lineJoin = expression; - break; - case "line-miter-limit": - lineLayer.lineMiterLimit = expression; - break; - case "line-round-limit": - lineLayer.lineRoundLimit = expression; - break; - case "line-sort-key": - lineLayer.lineSortKey = expression; - break; - case "visibility": - lineLayer.visibility = expression; - break; - case "line-opacity": - lineLayer.lineOpacity = expression; - break; - case "line-color": - lineLayer.lineColor = expression; - break; - case "line-translate": - lineLayer.lineTranslate = expression; - break; - case "line-translate-anchor": - lineLayer.lineTranslateAnchor = expression; - break; - case "line-width": - lineLayer.lineWidth = expression; - break; - case "line-gap-width": - lineLayer.lineGapWidth = expression; - break; - case "line-offset": - lineLayer.lineOffset = expression; - break; - case "line-blur": - lineLayer.lineBlur = expression; - break; - case "line-dasharray": - lineLayer.lineDasharray = expression; - break; - case "line-pattern": - lineLayer.linePattern = expression; - break; - case "line-gradient": - lineLayer.lineGradient = expression; - break; - case "line-blur": - lineLayer.lineBlur = expression - default: - break - } - } - } - - class func addCircleProperties(circleLayer: MGLCircleStyleLayer, properties: [String: String]) { - for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) - switch propertyName { - case "circle-sort-key": - lineLayer.circleSortKey = expression; - break; - case "visibility": - lineLayer.visibility = expression; - break; - case "circle-radius": - lineLayer.circleRadius = expression; - break; - case "circle-color": - lineLayer.circleColor = expression; - break; - case "circle-blur": - lineLayer.circleBlur = expression; - break; - case "circle-opacity": - lineLayer.circleOpacity = expression; - break; - case "circle-translate": - lineLayer.circleTranslate = expression; - break; - case "circle-translate-anchor": - lineLayer.circleTranslateAnchor = expression; - break; - case "circle-pitch-scale": - lineLayer.circlePitchScale = expression; - break; - case "circle-pitch-alignment": - lineLayer.circlePitchAlignment = expression; - break; - case "circle-stroke-width": - lineLayer.circleStrokeWidth = expression; - break; - case "circle-stroke-color": - lineLayer.circleStrokeColor = expression; - break; - case "circle-stroke-opacity": - lineLayer.circleStrokeOpacity = expression; - break; - default: - break - } - } - } - class func addSymbolProperties(symbolLayer: MGLSymbolStyleLayer, properties: [String: String]) { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) @@ -289,49 +177,167 @@ class LayerPropertyConverter { case "text-translate-anchor": lineLayer.textTranslateAnchor = expression; break; + case "line-blur": + lineLayer.lineBlur = expression + default: + break + } + } + } + + class func addCircleProperties(circleLayer: MGLCircleStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + case "circle-sort-key": + lineLayer.circleSortKey = expression; + break; + case "visibility": + lineLayer.visibility = expression; + break; + case "circle-radius": + lineLayer.circleRadius = expression; + break; + case "circle-color": + lineLayer.circleColor = expression; + break; + case "circle-blur": + lineLayer.circleBlur = expression; + break; + case "circle-opacity": + lineLayer.circleOpacity = expression; + break; + case "circle-translate": + lineLayer.circleTranslate = expression; + break; + case "circle-translate-anchor": + lineLayer.circleTranslateAnchor = expression; + break; + case "circle-pitch-scale": + lineLayer.circlePitchScale = expression; + break; + case "circle-pitch-alignment": + lineLayer.circlePitchAlignment = expression; + break; + case "circle-stroke-width": + lineLayer.circleStrokeWidth = expression; + break; + case "circle-stroke-color": + lineLayer.circleStrokeColor = expression; + break; + case "circle-stroke-opacity": + lineLayer.circleStrokeOpacity = expression; + break; + case "line-blur": + lineLayer.lineBlur = expression + default: + break + } + } + } + + class func addLineProperties(lineLayer: MGLLineStyleLayer, properties: [String: String]) { + for (propertyName, propertyValue) in properties { + let expression = interpretExpression(expression: propertyValue) + switch propertyName { + case "line-cap": + lineLayer.lineCap = expression; + break; + case "line-join": + lineLayer.lineJoin = expression; + break; + case "line-miter-limit": + lineLayer.lineMiterLimit = expression; + break; + case "line-round-limit": + lineLayer.lineRoundLimit = expression; + break; + case "line-sort-key": + lineLayer.lineSortKey = expression; + break; + case "visibility": + lineLayer.visibility = expression; + break; + case "line-opacity": + lineLayer.lineOpacity = expression; + break; + case "line-color": + lineLayer.lineColor = expression; + break; + case "line-translate": + lineLayer.lineTranslate = expression; + break; + case "line-translate-anchor": + lineLayer.lineTranslateAnchor = expression; + break; + case "line-width": + lineLayer.lineWidth = expression; + break; + case "line-gap-width": + lineLayer.lineGapWidth = expression; + break; + case "line-offset": + lineLayer.lineOffset = expression; + break; + case "line-blur": + lineLayer.lineBlur = expression; + break; + case "line-dasharray": + lineLayer.lineDasharray = expression; + break; + case "line-pattern": + lineLayer.linePattern = expression; + break; + case "line-gradient": + lineLayer.lineGradient = expression; + break; + case "line-blur": + lineLayer.lineBlur = expression default: break } } } - class func addFillProperties(fillLayer: MGLSFillStyleLayer, properties: [String: String]) { + class func addFillProperties(fillLayer: MGLFillStyleLayer, properties: [String: String]) { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { case "fill-sort-key": - fillLayer.fillSortKey = expression; + lineLayer.fillSortKey = expression; break; case "visibility": - fillLayer.visibility = expression; + lineLayer.visibility = expression; break; case "fill-antialias": - fillLayer.fillAntialias = expression; + lineLayer.fillAntialias = expression; break; case "fill-opacity": - fillLayer.fillOpacity = expression; + lineLayer.fillOpacity = expression; break; case "fill-color": - fillLayer.fillColor = expression; + lineLayer.fillColor = expression; break; case "fill-outline-color": - fillLayer.fillOutlineColor = expression; + lineLayer.fillOutlineColor = expression; break; case "fill-translate": - fillLayer.fillTranslate = expression; + lineLayer.fillTranslate = expression; break; case "fill-translate-anchor": - fillLayer.fillTranslateAnchor = expression; + lineLayer.fillTranslateAnchor = expression; break; case "fill-pattern": - fillLayer.fillPattern = expression; + lineLayer.fillPattern = expression; break; + case "line-blur": + lineLayer.lineBlur = expression default: break } } } - + private class func interpretExpression(expression: String) -> NSExpression? { do { let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: []) diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index be39145a9..c41b76158 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -997,7 +997,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { let layer = MGLSymbolStyleLayer(identifier: layerId, source: source) - Convert.addSymbolProperties(symbolLayer: layer, properties: properties) + LayerPropertyConverter.addSymbolProperties(symbolLayer: layer, properties: properties) style.addLayer(layer) } } @@ -1007,7 +1007,27 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { let layer = MGLLineStyleLayer(identifier: layerId, source: source) - Convert.addLineProperties(lineLayer: layer, properties: properties) + LayerPropertyConverter.addLineProperties(lineLayer: layer, properties: properties) + style.addLayer(layer) + } + } + } + + func addLineLayer(sourceId: String, layerId: String, properties: [String: String]) { + if let style = mapView.style { + if let source = style.source(withIdentifier: sourceId) { + let layer = MGLFillStyleLayer(identifier: layerId, source: source) + LayerPropertyConverter.addFillProperties(fillLayer: layer, properties: properties) + style.addLayer(layer) + } + } + } + + func addCircleLayer(sourceId: String, layerId: String, properties: [String: String]) { + if let style = mapView.style { + if let source = style.source(withIdentifier: sourceId) { + let layer = MGLCircleStyleLayer(identifier: layerId, source: source) + LayerPropertyConverter.addCircleProperties(cricleLayer: layer, properties: properties) style.addLayer(layer) } } @@ -1052,12 +1072,6 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } } - func addLineLayer(sourceId: String, layerId: String, properties: [String: String]) { - let source = mapView.style?.source(withIdentifier: sourceId) - let layer = MGLLineStyleLayer(identifier: layerId, source: source!) - Convert.addLineProperties(lineLayer: layer, properties: properties) - mapView.style?.addLayer(layer) - } /* * MapboxMapOptionsSink diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 04a792ca9..ab48a66a3 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -259,16 +259,20 @@ class MapboxMapController extends ChangeNotifier { return _mapboxGlPlatform.moveCamera(cameraUpdate); } - Future addSource(String sourceId, String geojson) async { + Future addSource(String sourceId, Map geojson) async { await MapboxGlPlatform.getInstance(_id).addSource(sourceId, geojson); } - Future addSymbolLayer(String sourceId, String layerId, Map properties) async { - await MapboxGlPlatform.getInstance(_id).addSymbolLayer(sourceId, layerId, properties); + Future addSymbolLayer( + String sourceId, String layerId, Map properties) async { + await MapboxGlPlatform.getInstance(_id) + .addSymbolLayer(sourceId, layerId, properties); } - Future addLineLayer(String sourceId, String layerId, Map properties) async { - await MapboxGlPlatform.getInstance(_id).addLineLayer(sourceId, layerId, properties); + Future addLineLayer( + String sourceId, String layerId, Map properties) async { + await MapboxGlPlatform.getInstance(_id) + .addLineLayer(sourceId, layerId, properties); } /// Updates user location tracking mode. diff --git a/lib/src/layer_helper.dart b/lib/src/layer_helper.dart index ed80f2db6..5b5678128 100644 --- a/lib/src/layer_helper.dart +++ b/lib/src/layer_helper.dart @@ -1,53 +1,6 @@ // This file is generated by // ./scripts/lib/generate.dart -class FillProperties{ - static const fillSortKey = "fill-sort-key"; - static const visibility = "visibility"; - static const fillAntialias = "fill-antialias"; - static const fillOpacity = "fill-opacity"; - static const fillColor = "fill-color"; - static const fillOutlineColor = "fill-outline-color"; - static const fillTranslate = "fill-translate"; - static const fillTranslateAnchor = "fill-translate-anchor"; - static const fillPattern = "fill-pattern"; -} - -class LineProperties{ - static const lineCap = "line-cap"; - static const lineJoin = "line-join"; - static const lineMiterLimit = "line-miter-limit"; - static const lineRoundLimit = "line-round-limit"; - static const lineSortKey = "line-sort-key"; - static const visibility = "visibility"; - static const lineOpacity = "line-opacity"; - static const lineColor = "line-color"; - static const lineTranslate = "line-translate"; - static const lineTranslateAnchor = "line-translate-anchor"; - static const lineWidth = "line-width"; - static const lineGapWidth = "line-gap-width"; - static const lineOffset = "line-offset"; - static const lineBlur = "line-blur"; - static const lineDasharray = "line-dasharray"; - static const linePattern = "line-pattern"; - static const lineGradient = "line-gradient"; -} - -class CricleProperties{ - static const circleSortKey = "circle-sort-key"; - static const visibility = "visibility"; - static const circleRadius = "circle-radius"; - static const circleColor = "circle-color"; - static const circleBlur = "circle-blur"; - static const circleOpacity = "circle-opacity"; - static const circleTranslate = "circle-translate"; - static const circleTranslateAnchor = "circle-translate-anchor"; - static const circlePitchScale = "circle-pitch-scale"; - static const circlePitchAlignment = "circle-pitch-alignment"; - static const circleStrokeWidth = "circle-stroke-width"; - static const circleStrokeColor = "circle-stroke-color"; - static const circleStrokeOpacity = "circle-stroke-opacity"; -} class SymbolProperties{ static const symbolPlacement = "symbol-placement"; @@ -108,6 +61,58 @@ class SymbolProperties{ static const textTranslateAnchor = "text-translate-anchor"; } + +class CircleProperties{ + static const circleSortKey = "circle-sort-key"; + static const visibility = "visibility"; + static const circleRadius = "circle-radius"; + static const circleColor = "circle-color"; + static const circleBlur = "circle-blur"; + static const circleOpacity = "circle-opacity"; + static const circleTranslate = "circle-translate"; + static const circleTranslateAnchor = "circle-translate-anchor"; + static const circlePitchScale = "circle-pitch-scale"; + static const circlePitchAlignment = "circle-pitch-alignment"; + static const circleStrokeWidth = "circle-stroke-width"; + static const circleStrokeColor = "circle-stroke-color"; + static const circleStrokeOpacity = "circle-stroke-opacity"; +} + + +class LineProperties{ + static const lineCap = "line-cap"; + static const lineJoin = "line-join"; + static const lineMiterLimit = "line-miter-limit"; + static const lineRoundLimit = "line-round-limit"; + static const lineSortKey = "line-sort-key"; + static const visibility = "visibility"; + static const lineOpacity = "line-opacity"; + static const lineColor = "line-color"; + static const lineTranslate = "line-translate"; + static const lineTranslateAnchor = "line-translate-anchor"; + static const lineWidth = "line-width"; + static const lineGapWidth = "line-gap-width"; + static const lineOffset = "line-offset"; + static const lineBlur = "line-blur"; + static const lineDasharray = "line-dasharray"; + static const linePattern = "line-pattern"; + static const lineGradient = "line-gradient"; +} + + +class FillProperties{ + static const fillSortKey = "fill-sort-key"; + static const visibility = "visibility"; + static const fillAntialias = "fill-antialias"; + static const fillOpacity = "fill-opacity"; + static const fillColor = "fill-color"; + static const fillOutlineColor = "fill-outline-color"; + static const fillTranslate = "fill-translate"; + static const fillTranslateAnchor = "fill-translate-anchor"; + static const fillPattern = "fill-pattern"; +} + + class Expressions{ static const let = "let"; static const varExpression = "var"; @@ -155,7 +160,7 @@ class Expressions{ static const plus = "+"; static const multiply = "*"; static const minus = "-"; - static const divide = "/"; + static const divide = "/"; static const precent = "%"; static const xor = "^"; static const sqrt = "sqrt"; @@ -176,10 +181,10 @@ class Expressions{ static const floor = "floor"; static const equal = "=="; static const notEqual = "!="; - static const larger = ">"; - static const smaller = "<"; - static const largerOrEqual = ">="; - static const smallerOrEqual = "<="; + static const larger = ">"; + static const smaller = "<"; + static const largerOrEqual = ">="; + static const smallerOrEqual = "<="; static const all = "all"; static const any = "any"; static const not = "!"; diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index 54c7bcc40..94dc4a361 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -278,17 +278,17 @@ abstract class MapboxGlPlatform { throw UnimplementedError( 'getMetersPerPixelAtLatitude() has not been implemented.'); } - Future addSource(String sourceId, String geojson) async { + Future addSource(String sourceId, Map geojson) async { throw UnimplementedError( 'setSymbolTextIgnorePlacement() has not been implemented.'); } - Future addSymbolLayer(String sourceId, String layerId, Map properties) async { + Future addSymbolLayer(String sourceId, String layerId, Map properties) async { throw UnimplementedError( 'setSymbolTextIgnorePlacement() has not been implemented.'); } - Future addLineLayer(String sourceId, String layerId, Map properties) async { + Future addLineLayer(String sourceId, String layerId, Map properties) async { throw UnimplementedError( 'setSymbolTextIgnorePlacement() has not been implemented.'); } diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index 4aa583510..c1d57a4f9 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -719,7 +719,8 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { return new Future.error(e); } } - Future addSource(String sourceId, String geojson) async { + + Future addSource(String sourceId, Map geojson) async { await _channel.invokeMethod('source#add', { 'sourceId': sourceId, 'geojson': geojson, @@ -727,20 +728,24 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { } @override - Future addSymbolLayer(String sourceId, String layerId, Map properties) async { + Future addSymbolLayer( + String sourceId, String layerId, Map properties) async { await _channel.invokeMethod('symbolLayer#add', { 'sourceId': sourceId, 'layerId': layerId, 'properties': properties + .map((key, value) => MapEntry(key, jsonEncode(value))) }); } @override - Future addLineLayer(String sourceId, String layerId, Map properties) async { + Future addLineLayer( + String sourceId, String layerId, Map properties) async { await _channel.invokeMethod('lineLayer#add', { 'sourceId': sourceId, 'layerId': layerId, 'properties': properties + .map((key, value) => MapEntry(key, jsonEncode(value))) }); } } diff --git a/scripts/.dart_tool/package_config.json b/scripts/.dart_tool/package_config.json index 1b24c83f0..653ae73da 100644 --- a/scripts/.dart_tool/package_config.json +++ b/scripts/.dart_tool/package_config.json @@ -20,7 +20,7 @@ "languageVersion": "2.12" } ], - "generated": "2021-10-15T22:46:38.145356Z", + "generated": "2021-10-15T22:47:11.982253Z", "generator": "pub", "generatorVersion": "2.14.3" } diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index 68026b825..3c5be4561 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -9,28 +9,32 @@ main() async { jsonDecode(await new File('./scripts/input/style.json').readAsString()); final renderContext = { - 'lineProperties': buildStyleProperties(styleJson, "layout_line") + - buildStyleProperties(styleJson, "paint_line"), - 'fillProperties': buildStyleProperties(styleJson, "layout_fill") + - buildStyleProperties(styleJson, "paint_fill"), - 'circleProperties': buildStyleProperties(styleJson, "layout_circle") + - buildStyleProperties(styleJson, "paint_circle"), - 'symbolProperties': buildStyleProperties(styleJson, "layout_symbol") + - buildStyleProperties(styleJson, "paint_symbol"), + "layerTypes": [ + for (var type in ["symbol", "circle", "line", "fill"]) + { + "type": type, + "typePascal": ReCase(type).pascalCase, + "properties": buildStyleProperties(styleJson, "layout_$type") + + buildStyleProperties(styleJson, "paint_$type") + }, + ], 'expressions': buildExpressionProperties(styleJson) }; + print("generating java"); await renderLayerPropertyConverter( renderContext, "java", './android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java', ); + print("generating swift"); await renderLayerPropertyConverter( renderContext, "swift", "./ios/Classes/LayerPropertyConverter.swift", ); + print("generating dart"); await renderDart(renderContext); } diff --git a/scripts/templates/LayerPropertyConverter.java.template b/scripts/templates/LayerPropertyConverter.java.template index 872528372..9f623e95b 100644 --- a/scripts/templates/LayerPropertyConverter.java.template +++ b/scripts/templates/LayerPropertyConverter.java.template @@ -14,79 +14,19 @@ import java.util.Map; import static com.mapbox.mapboxgl.Convert.toMap; class LayerPropertyConverter { - - static PropertyValue[] interpretLineLayerProperties(Object o) { - final Map data = (Map) toMap(o); - final List properties = new LinkedList(); - - for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); - switch (entry.getKey()) { - {{#lineProperties}} - case "{{{value}}}": - properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); - break; - {{/lineProperties}} - default: - break; - } - } - - return properties.toArray(new PropertyValue[properties.size()]); - } - - static PropertyValue[] interpretSymbolLayerProperties(Object o) { - final Map data = (Map) toMap(o); - final List properties = new LinkedList(); - - for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); - switch (entry.getKey()) { - {{#symbolProperties}} - case "{{{value}}}": - properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); - break; - {{/symbolProperties}} - default: - break; - } - } - - return properties.toArray(new PropertyValue[properties.size()]); - } - - static PropertyValue[] interpretCircleLayerProperties(Object o) { - final Map data = (Map) toMap(o); - final List properties = new LinkedList(); - - for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); - switch (entry.getKey()) { - {{#circleProperties}} - case "{{{value}}}": - properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); - break; - {{/circleProperties}} - default: - break; - } - } - - return properties.toArray(new PropertyValue[properties.size()]); - } - - static PropertyValue[] interpretFillLayerProperties(Object o) { +{{#layerTypes}} + static PropertyValue[] interpret{{typePascal}}LayerProperties(Object o) { final Map data = (Map) toMap(o); final List properties = new LinkedList(); for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { - {{#fillProperties}} - case "{{{value}}}": + {{#properties}} + case "{{value}}": properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); break; - {{/fillProperties}} + {{/properties}} default: break; } @@ -95,4 +35,5 @@ class LayerPropertyConverter { return properties.toArray(new PropertyValue[properties.size()]); } +{{/layerTypes}} } \ No newline at end of file diff --git a/scripts/templates/LayerPropertyConverter.swift.template b/scripts/templates/LayerPropertyConverter.swift.template index 78559e335..87201943c 100644 --- a/scripts/templates/LayerPropertyConverter.swift.template +++ b/scripts/templates/LayerPropertyConverter.swift.template @@ -5,15 +5,16 @@ import Mapbox import MapboxAnnotationExtension class LayerPropertyConverter { - class func addLineProperties(lineLayer: MGLLineStyleLayer, properties: [String: String]) { +{{#layerTypes}} + class func add{{typePascal}}Properties({{type}}Layer: MGL{{typePascal}}StyleLayer, properties: [String: String]) { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { - {{#lineProperties}} + {{#properties}} case "{{{value}}}": lineLayer.{{valueAsCamelCase}} = expression; break; - {{/lineProperties}} + {{/properties}} case "line-blur": lineLayer.lineBlur = expression default: @@ -22,51 +23,7 @@ class LayerPropertyConverter { } } - class func addCircleProperties(circleLayer: MGLCircleStyleLayer, properties: [String: String]) { - for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) - switch propertyName { - {{#circleProperties}} - case "{{{value}}}": - lineLayer.{{valueAsCamelCase}} = expression; - break; - {{/circleProperties}} - default: - break - } - } - } - - class func addSymbolProperties(symbolLayer: MGLSymbolStyleLayer, properties: [String: String]) { - for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) - switch propertyName { - {{#symbolProperties}} - case "{{{value}}}": - lineLayer.{{valueAsCamelCase}} = expression; - break; - {{/symbolProperties}} - default: - break - } - } - } - - class func addFillProperties(fillLayer: MGLSFillStyleLayer, properties: [String: String]) { - for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) - switch propertyName { - {{#fillProperties}} - case "{{{value}}}": - fillLayer.{{valueAsCamelCase}} = expression; - break; - {{/fillProperties}} - default: - break - } - } - } - +{{/layerTypes}} private class func interpretExpression(expression: String) -> NSExpression? { do { let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: []) diff --git a/scripts/templates/layer_helper.dart.template b/scripts/templates/layer_helper.dart.template index b5fdade8f..4e23a0579 100644 --- a/scripts/templates/layer_helper.dart.template +++ b/scripts/templates/layer_helper.dart.template @@ -1,32 +1,18 @@ // This file is generated by // ./scripts/lib/generate.dart +{{#layerTypes}} -class FillProperties{ - {{#fillProperties}} - static const {{valueAsCamelCase}} = "{{{value}}}"; - {{/fillProperties}} -} - -class LineProperties{ - {{#lineProperties}} - static const {{valueAsCamelCase}} = "{{{value}}}"; - {{/lineProperties}} -} -class CricleProperties{ - {{#circleProperties}} - static const {{valueAsCamelCase}} = "{{{value}}}"; - {{/circleProperties}} +class {{typePascal}}Properties{ + {{#properties}} + static const {{valueAsCamelCase}} = "{{value}}"; + {{/properties}} } +{{/layerTypes}} -class SymbolProperties{ - {{#symbolProperties}} - static const {{valueAsCamelCase}} = "{{{value}}}"; - {{/symbolProperties}} -} class Expressions{ {{#expressions}} - static const {{valueAsCamelCase}} = "{{{value}}}"; + static const {{valueAsCamelCase}} = "{{value}}"; {{/expressions}} } From 1346cd0176cbecefd6a612d5c53455e2e58d213a Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Wed, 20 Oct 2021 18:11:27 +0200 Subject: [PATCH 09/33] added doc string generation --- example/lib/layer.dart | 89 +++--- lib/mapbox_gl.dart | 1 + lib/src/controller.dart | 21 +- lib/src/layer_helper.dart | 292 +++++++++++++++++- .../lib/src/mapbox_gl_platform_interface.dart | 27 +- .../lib/src/method_channel_mapbox_gl.dart | 36 ++- scripts/lib/generate.dart | 39 ++- scripts/templates/layer_helper.dart.template | 10 +- 8 files changed, 446 insertions(+), 69 deletions(-) diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 101a76564..c2083dd23 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -4,7 +4,6 @@ import 'package:mapbox_gl_example/main.dart'; import 'package:mapbox_gl_example/page.dart'; class LayerPage extends ExamplePage { - LayerPage() : super(const Icon(Icons.share), 'Layer'); @override @@ -12,63 +11,53 @@ class LayerPage extends ExamplePage { } class LayerBody extends StatefulWidget { - @override State createState() => LayerState(); } class LayerState extends State { static final LatLng center = const LatLng(-33.86711, 151.1947171); - static final String geojson = ''' -{ - "type": "FeatureCollection", - "features": [ - { - "type": "Feature", - "properties": {}, - "geometry": { - "type": "LineString", - "coordinates": [ - [ - 151.19213104248047, - -33.87112820031405 - ], - [ - 151.4770858764648, - -33.853737857223145 + static final Map geojsonLines = { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [151.19213104248047, -33.87112820031405], + [151.4770858764648, -33.853737857223145] ] - ] + } } - } - ] -} - '''; + ] + }; - MapboxMapController controller; + late MapboxMapController controller; @override Widget build(BuildContext context) { return Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Center( - child: SizedBox( - width: 300.0, - height: 500.0, - child: MapboxMap( - accessToken: MapsDemo.ACCESS_TOKEN, - onMapCreated: _onMapCreated, - onStyleLoadedCallback: _onStyleLoadedCallback, - initialCameraPosition: CameraPosition( - target: center, - zoom: 11.0, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Center( + child: SizedBox( + width: 300.0, + height: 500.0, + child: MapboxMap( + accessToken: MapsDemo.ACCESS_TOKEN, + onMapCreated: _onMapCreated, + onStyleLoadedCallback: _onStyleLoadedCallback, + initialCameraPosition: CameraPosition( + target: center, + zoom: 11.0, + ), ), ), ), - ), - ] - ); + ]); } void _onMapCreated(MapboxMapController controller) { @@ -76,9 +65,17 @@ class LayerState extends State { } void _onStyleLoadedCallback() { - controller.addSource("source_1", geojson); - controller.addLineLayer("source_1", "layer_1", { - 'line-width': "[\"interpolate\", [\"linear\"], [\"zoom\"], 15.0, 1.0, 23.0, 10.0]" + controller.addGeoJsonSource("lines", geojsonLines); + controller.addLineLayer("lines", "layer_1", { + LineProperties.lineWidth: [ + Expressions.interpolate, + ["linear"], + [Expressions.zoom], + 15.0, + 1.0, + 23.0, + 10.0 + ] }); } -} \ No newline at end of file +} diff --git a/lib/mapbox_gl.dart b/lib/mapbox_gl.dart index 121d6817b..d29c89615 100644 --- a/lib/mapbox_gl.dart +++ b/lib/mapbox_gl.dart @@ -45,3 +45,4 @@ part 'src/mapbox_map.dart'; part 'src/global.dart'; part 'src/offline_region.dart'; part 'src/download_region_status.dart'; +part 'src/layer_helper.dart'; diff --git a/lib/src/controller.dart b/lib/src/controller.dart index ab48a66a3..0dc2cc88b 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -259,8 +259,13 @@ class MapboxMapController extends ChangeNotifier { return _mapboxGlPlatform.moveCamera(cameraUpdate); } - Future addSource(String sourceId, Map geojson) async { - await MapboxGlPlatform.getInstance(_id).addSource(sourceId, geojson); + Future addSource(String sourceId, String source) async { + await MapboxGlPlatform.getInstance(_id).addSource(sourceId, source); + } + + Future addGeoJsonSource( + String sourceId, Map source) async { + await MapboxGlPlatform.getInstance(_id).addGeoJsonSource(sourceId, source); } Future addSymbolLayer( @@ -275,6 +280,18 @@ class MapboxMapController extends ChangeNotifier { .addLineLayer(sourceId, layerId, properties); } + Future addFillLayer( + String sourceId, String layerId, Map properties) async { + await MapboxGlPlatform.getInstance(_id) + .addFillLayer(sourceId, layerId, properties); + } + + Future addCircleLayer( + String sourceId, String layerId, Map properties) async { + await MapboxGlPlatform.getInstance(_id) + .addCircleLayer(sourceId, layerId, properties); + } + /// Updates user location tracking mode. /// /// The returned [Future] completes after the change has been made on the diff --git a/lib/src/layer_helper.dart b/lib/src/layer_helper.dart index 5b5678128..3c30ed36a 100644 --- a/lib/src/layer_helper.dart +++ b/lib/src/layer_helper.dart @@ -1,115 +1,397 @@ // This file is generated by // ./scripts/lib/generate.dart +part of mapbox_gl; + class SymbolProperties{ + /// Label placement relative to its geometry. static const symbolPlacement = "symbol-placement"; + + /// Distance between two symbol anchors. static const symbolSpacing = "symbol-spacing"; + + /// 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. When using a client that + /// supports global collision detection, like Mapbox GL JS version 0.42.0 + /// or greater, enabling this property is not needed to prevent clipped + /// labels at tile boundaries. static const symbolAvoidEdges = "symbol-avoid-edges"; + + /// Sorts features in ascending order based on this value. Features with + /// lower sort keys are drawn and placed first. When `icon-allow-overlap` + /// or `text-allow-overlap` is `false`, features with a lower sort key + /// will have priority during placement. When `icon-allow-overlap` or + /// `text-allow-overlap` is set to `true`, features with a higher sort key + /// will overlap over features with a lower sort key. static const symbolSortKey = "symbol-sort-key"; + + /// Controls the order in which overlapping symbols in the same layer are + /// rendered static const symbolZOrder = "symbol-z-order"; + + /// If true, the icon will be visible even if it collides with other + /// previously drawn symbols. static const iconAllowOverlap = "icon-allow-overlap"; + + /// If true, other symbols can be visible even if they collide with the + /// icon. static const iconIgnorePlacement = "icon-ignore-placement"; + + /// If true, text will display without their corresponding icons when the + /// icon collides with other symbols and the text does not. static const iconOptional = "icon-optional"; + + /// In combination with `symbol-placement`, determines the rotation + /// behavior of icons. static const iconRotationAlignment = "icon-rotation-alignment"; + + /// Scales the original size of the icon by the provided factor. The new + /// pixel size of the image will be the original pixel size multiplied by + /// `icon-size`. 1 is the original size; 3 triples the size of the image. static const iconSize = "icon-size"; + + /// Scales the icon to fit around the associated text. static const iconTextFit = "icon-text-fit"; + + /// Size of the additional area added to dimensions determined by + /// `icon-text-fit`, in clockwise order: top, right, bottom, left. static const iconTextFitPadding = "icon-text-fit-padding"; + + /// Name of image in sprite to use for drawing an image background. static const iconImage = "icon-image"; + + /// Rotates the icon clockwise. static const iconRotate = "icon-rotate"; + + /// Size of the additional area around the icon bounding box used for + /// detecting symbol collisions. static const iconPadding = "icon-padding"; + + /// If true, the icon may be flipped to prevent it from being rendered + /// upside-down. static const iconKeepUpright = "icon-keep-upright"; + + /// Offset distance of icon from its anchor. Positive values indicate + /// right and down, while negative values indicate left and up. Each + /// component is multiplied by the value of `icon-size` to obtain the + /// final offset in pixels. When combined with `icon-rotate` the offset + /// will be as if the rotated direction was up. static const iconOffset = "icon-offset"; + + /// Part of the icon placed closest to the anchor. static const iconAnchor = "icon-anchor"; + + /// Orientation of icon when map is pitched. static const iconPitchAlignment = "icon-pitch-alignment"; + + /// Orientation of text when map is pitched. static const textPitchAlignment = "text-pitch-alignment"; + + /// In combination with `symbol-placement`, determines the rotation + /// behavior of the individual glyphs forming the text. static const textRotationAlignment = "text-rotation-alignment"; + + /// Value to use for a text label. If a plain `string` is provided, it + /// will be treated as a `formatted` with default/inherited formatting + /// options. static const textField = "text-field"; + + /// Font stack to use for displaying text. static const textFont = "text-font"; + + /// Font size. static const textSize = "text-size"; + + /// The maximum line width for text wrapping. static const textMaxWidth = "text-max-width"; + + /// Text leading value for multi-line text. static const textLineHeight = "text-line-height"; + + /// Text tracking amount. static const textLetterSpacing = "text-letter-spacing"; + + /// Text justification options. static const textJustify = "text-justify"; + + /// Radial offset of text, in the direction of the symbol's anchor. Useful + /// in combination with `text-variable-anchor`, which defaults to using + /// the two-dimensional `text-offset` if present. static const textRadialOffset = "text-radial-offset"; + + /// To increase the chance of placing high-priority labels on the map, you + /// can provide an array of `text-anchor` locations: the renderer will + /// attempt to place the label at each location, in order, before moving + /// onto the next label. Use `text-justify: auto` to choose justification + /// based on anchor position. To apply an offset, use the + /// `text-radial-offset` or the two-dimensional `text-offset`. static const textVariableAnchor = "text-variable-anchor"; + + /// Part of the text placed closest to the anchor. static const textAnchor = "text-anchor"; + + /// Maximum angle change between adjacent characters. static const textMaxAngle = "text-max-angle"; + + /// The property allows control over a symbol's orientation. Note that the + /// property values act as a hint, so that a symbol whose language doesn’t + /// support the provided orientation will be laid out in its natural + /// orientation. Example: English point symbol will be rendered + /// horizontally even if array value contains single 'vertical' enum + /// value. The order of elements in an array define priority order for the + /// placement of an orientation variant. static const textWritingMode = "text-writing-mode"; + + /// Rotates the text clockwise. static const textRotate = "text-rotate"; + + /// Size of the additional area around the text bounding box used for + /// detecting symbol collisions. static const textPadding = "text-padding"; + + /// If true, the text may be flipped vertically to prevent it from being + /// rendered upside-down. static const textKeepUpright = "text-keep-upright"; + + /// Specifies how to capitalize text, similar to the CSS `text-transform` + /// property. static const textTransform = "text-transform"; + + /// Offset distance of text from its anchor. Positive values indicate + /// right and down, while negative values indicate left and up. If used + /// with text-variable-anchor, input values will be taken as absolute + /// values. Offsets along the x- and y-axis will be applied automatically + /// based on the anchor position. static const textOffset = "text-offset"; + + /// If true, the text will be visible even if it collides with other + /// previously drawn symbols. static const textAllowOverlap = "text-allow-overlap"; + + /// If true, other symbols can be visible even if they collide with the + /// text. static const textIgnorePlacement = "text-ignore-placement"; + + /// If true, icons will display without their corresponding text when the + /// text collides with other symbols and the icon does not. static const textOptional = "text-optional"; + + /// Whether this layer is displayed. static const visibility = "visibility"; + + /// The opacity at which the icon will be drawn. static const iconOpacity = "icon-opacity"; + + /// The color of the icon. This can only be used with sdf icons. static const iconColor = "icon-color"; + + /// The color of the icon's halo. Icon halos can only be used with SDF + /// icons. static const iconHaloColor = "icon-halo-color"; + + /// Distance of halo to the icon outline. static const iconHaloWidth = "icon-halo-width"; + + /// Fade out the halo towards the outside. static const iconHaloBlur = "icon-halo-blur"; + + /// 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. static const iconTranslate = "icon-translate"; + + /// Controls the frame of reference for `icon-translate`. static const iconTranslateAnchor = "icon-translate-anchor"; + + /// The opacity at which the text will be drawn. static const textOpacity = "text-opacity"; + + /// The color with which the text will be drawn. static const textColor = "text-color"; + + /// The color of the text's halo, which helps it stand out from + /// backgrounds. static const textHaloColor = "text-halo-color"; + + /// Distance of halo to the font outline. Max text halo width is 1/4 of + /// the font-size. static const textHaloWidth = "text-halo-width"; + + /// The halo's fadeout distance towards the outside. static const textHaloBlur = "text-halo-blur"; + + /// 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. static const textTranslate = "text-translate"; + + /// Controls the frame of reference for `text-translate`. static const textTranslateAnchor = "text-translate-anchor"; + } class CircleProperties{ + /// Sorts features in ascending order based on this value. Features with a + /// higher sort key will appear above features with a lower sort key. static const circleSortKey = "circle-sort-key"; + + /// Whether this layer is displayed. static const visibility = "visibility"; + + /// Circle radius. static const circleRadius = "circle-radius"; + + /// The fill color of the circle. static const circleColor = "circle-color"; + + /// Amount to blur the circle. 1 blurs the circle such that only the + /// centerpoint is full opacity. static const circleBlur = "circle-blur"; + + /// The opacity at which the circle will be drawn. static const circleOpacity = "circle-opacity"; + + /// The geometry's offset. Values are [x, y] where negatives indicate left + /// and up, respectively. static const circleTranslate = "circle-translate"; + + /// Controls the frame of reference for `circle-translate`. static const circleTranslateAnchor = "circle-translate-anchor"; + + /// Controls the scaling behavior of the circle when the map is pitched. static const circlePitchScale = "circle-pitch-scale"; + + /// Orientation of circle when map is pitched. static const circlePitchAlignment = "circle-pitch-alignment"; + + /// The width of the circle's stroke. Strokes are placed outside of the + /// `circle-radius`. static const circleStrokeWidth = "circle-stroke-width"; + + /// The stroke color of the circle. static const circleStrokeColor = "circle-stroke-color"; + + /// The opacity of the circle's stroke. static const circleStrokeOpacity = "circle-stroke-opacity"; + } class LineProperties{ + /// The display of line endings. static const lineCap = "line-cap"; + + /// The display of lines when joining. static const lineJoin = "line-join"; + + /// Used to automatically convert miter joins to bevel joins for sharp + /// angles. static const lineMiterLimit = "line-miter-limit"; + + /// Used to automatically convert round joins to miter joins for shallow + /// angles. static const lineRoundLimit = "line-round-limit"; + + /// Sorts features in ascending order based on this value. Features with a + /// higher sort key will appear above features with a lower sort key. static const lineSortKey = "line-sort-key"; + + /// Whether this layer is displayed. static const visibility = "visibility"; + + /// The opacity at which the line will be drawn. static const lineOpacity = "line-opacity"; + + /// The color with which the line will be drawn. static const lineColor = "line-color"; + + /// The geometry's offset. Values are [x, y] where negatives indicate left + /// and up, respectively. static const lineTranslate = "line-translate"; + + /// Controls the frame of reference for `line-translate`. static const lineTranslateAnchor = "line-translate-anchor"; + + /// Stroke thickness. static const lineWidth = "line-width"; + + /// Draws a line casing outside of a line's actual path. Value indicates + /// the width of the inner gap. static const lineGapWidth = "line-gap-width"; + + /// The line's offset. For linear features, a positive value offsets the + /// line to the right, relative to the direction of the line, and a + /// negative value to the left. For polygon features, a positive value + /// results in an inset, and a negative value results in an outset. static const lineOffset = "line-offset"; + + /// Blur applied to the line, in pixels. static const lineBlur = "line-blur"; + + /// 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. Note that GeoJSON sources with `lineMetrics: true` + /// specified won't render dashed lines to the expected scale. Also note + /// that zoom-dependent expressions will be evaluated only at integer zoom + /// levels. static const lineDasharray = "line-dasharray"; + + /// 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). + /// Note that zoom-dependent expressions will be evaluated only at integer + /// zoom levels. static const linePattern = "line-pattern"; + + /// Defines a gradient with which to color a line feature. Can only be + /// used with GeoJSON sources that specify `"lineMetrics": true`. static const lineGradient = "line-gradient"; + } class FillProperties{ + /// Sorts features in ascending order based on this value. Features with a + /// higher sort key will appear above features with a lower sort key. static const fillSortKey = "fill-sort-key"; + + /// Whether this layer is displayed. static const visibility = "visibility"; + + /// Whether or not the fill should be antialiased. static const fillAntialias = "fill-antialias"; + + /// 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. static const fillOpacity = "fill-opacity"; + + /// 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. static const fillColor = "fill-color"; + + /// The outline color of the fill. Matches the value of `fill-color` if + /// unspecified. static const fillOutlineColor = "fill-outline-color"; + + /// The geometry's offset. Values are [x, y] where negatives indicate left + /// and up, respectively. static const fillTranslate = "fill-translate"; + + /// Controls the frame of reference for `fill-translate`. static const fillTranslateAnchor = "fill-translate-anchor"; + + /// 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). Note that zoom-dependent expressions will be evaluated only + /// at integer zoom levels. static const fillPattern = "fill-pattern"; + } @@ -160,7 +442,7 @@ class Expressions{ static const plus = "+"; static const multiply = "*"; static const minus = "-"; - static const divide = "/"; + static const divide = "/"; static const precent = "%"; static const xor = "^"; static const sqrt = "sqrt"; @@ -181,10 +463,10 @@ class Expressions{ static const floor = "floor"; static const equal = "=="; static const notEqual = "!="; - static const larger = ">"; - static const smaller = "<"; - static const largerOrEqual = ">="; - static const smallerOrEqual = "<="; + static const larger = ">"; + static const smaller = "<"; + static const largerOrEqual = ">="; + static const smallerOrEqual = "<="; static const all = "all"; static const any = "any"; static const not = "!"; diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index 94dc4a361..220ab0a49 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -278,18 +278,35 @@ abstract class MapboxGlPlatform { throw UnimplementedError( 'getMetersPerPixelAtLatitude() has not been implemented.'); } - Future addSource(String sourceId, Map geojson) async { + + Future addSource(String sourceId, String source) async { throw UnimplementedError( 'setSymbolTextIgnorePlacement() has not been implemented.'); } - Future addSymbolLayer(String sourceId, String layerId, Map properties) async { + Future addGeoJsonSource( + String sourceId, Map source) async { throw UnimplementedError( 'setSymbolTextIgnorePlacement() has not been implemented.'); } - Future addLineLayer(String sourceId, String layerId, Map properties) async { - throw UnimplementedError( - 'setSymbolTextIgnorePlacement() has not been implemented.'); + Future addSymbolLayer( + String sourceId, String layerId, Map properties) async { + throw UnimplementedError('addSymbolLayer() has not been implemented.'); + } + + Future addLineLayer( + String sourceId, String layerId, Map properties) async { + throw UnimplementedError('addLineLayer() has not been implemented.'); + } + + Future addCircleLayer( + String sourceId, String layerId, Map properties) async { + throw UnimplementedError('addCircleLayer() has not been implemented.'); + } + + Future addFillLayer( + String sourceId, String layerId, Map properties) async { + throw UnimplementedError('addFillLayer() has not been implemented.'); } } diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index c1d57a4f9..7357e4e51 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -720,10 +720,20 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { } } - Future addSource(String sourceId, Map geojson) async { + @override + Future addSource(String sourceId, String source) async { + await _channel.invokeMethod('source#add', { + 'sourceId': sourceId, + 'geojson': source, + }); + } + + @override + Future addGeoJsonSource( + String sourceId, Map source) async { await _channel.invokeMethod('source#add', { 'sourceId': sourceId, - 'geojson': geojson, + 'geojson': jsonEncode(source), }); } @@ -748,4 +758,26 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { .map((key, value) => MapEntry(key, jsonEncode(value))) }); } + + @override + Future addCircleLayer( + String sourceId, String layerId, Map properties) async { + await _channel.invokeMethod('circleLayer#add', { + 'sourceId': sourceId, + 'layerId': layerId, + 'properties': properties + .map((key, value) => MapEntry(key, jsonEncode(value))) + }); + } + + @override + Future addFillLayer( + String sourceId, String layerId, Map properties) async { + await _channel.invokeMethod('fillLayer#add', { + 'sourceId': sourceId, + 'layerId': layerId, + 'properties': properties + .map((key, value) => MapEntry(key, jsonEncode(value))) + }); + } } diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index 3c5be4561..1e59b4826 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -1,12 +1,14 @@ import 'dart:io'; import 'dart:convert'; +import 'dart:math'; import 'package:mustache_template/mustache_template.dart'; import 'package:recase/recase.dart'; main() async { - var styleJson = - jsonDecode(await new File('./scripts/input/style.json').readAsString()); + var styleJson = jsonDecode(await new File( + '/Users/ocell/code/flutter-mapbox-gl/scripts/input/style.json') + .readAsString()); final renderContext = { "layerTypes": [ @@ -63,18 +65,41 @@ Future renderDart( outputFile.writeAsString(template.renderString(renderContext)); } -List> buildStyleProperties( +List> buildStyleProperties( Map styleJson, String key) { final Map items = styleJson[key]; - return items.keys - .map((f) => { - 'value': f, - 'valueAsCamelCase': new ReCase(f).camelCase + return items.entries + .map((e) => { + 'value': e.key, + 'doc': e.value["doc"], + 'docSplit': chunkSubstr(e.value["doc"], 70) + .map((s) => {"part": s}) + .toList(), + 'valueAsCamelCase': new ReCase(e.key).camelCase }) .toList(); } +List chunkSubstr(String input, int size) { + final words = input.split(" "); + final chunks = []; + + String chunk = ""; + for (var word in words) { + final nextChunk = chunk.length > 0 ? chunk + " " + word : word; + if (nextChunk.length > size) { + chunks.add(chunk); + chunk = word; + } else { + chunk = nextChunk; + } + } + chunks.add(chunk); + + return chunks; +} + List> buildExpressionProperties( Map styleJson) { final Map items = styleJson["expression_name"]["values"]; diff --git a/scripts/templates/layer_helper.dart.template b/scripts/templates/layer_helper.dart.template index 4e23a0579..a7b262aab 100644 --- a/scripts/templates/layer_helper.dart.template +++ b/scripts/templates/layer_helper.dart.template @@ -1,11 +1,17 @@ // This file is generated by // ./scripts/lib/generate.dart + +part of mapbox_gl; {{#layerTypes}} class {{typePascal}}Properties{ {{#properties}} - static const {{valueAsCamelCase}} = "{{value}}"; + {{#docSplit}} + /// {{{part}}} + {{/docSplit}} + static const {{valueAsCamelCase}} = "{{{value}}}"; + {{/properties}} } {{/layerTypes}} @@ -13,6 +19,6 @@ class {{typePascal}}Properties{ class Expressions{ {{#expressions}} - static const {{valueAsCamelCase}} = "{{value}}"; + static const {{valueAsCamelCase}} = "{{{value}}}"; {{/expressions}} } From 3bbccaa44cda000e571bd82f1fd30bfdb6a39ad8 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Thu, 21 Oct 2021 13:11:11 +0200 Subject: [PATCH 10/33] added web bindings --- .../mapboxgl/LayerPropertyConverter.java | 144 ++-- ios/Classes/LayerPropertyConverter.swift | 156 ++-- lib/src/layer_helper.dart | 815 +++++++++++++----- mapbox_gl_web/lib/mapbox_gl_web.dart | 1 + mapbox_gl_web/lib/src/layer_tools.dart | 58 ++ .../lib/src/mapbox_map_controller.dart | 45 + scripts/lib/generate.dart | 52 +- .../LayerPropertyConverter.java.template | 9 +- .../LayerPropertyConverter.swift.template | 12 +- scripts/templates/layer_helper.dart.template | 20 +- scripts/templates/layer_tools.dart.template | 12 + 11 files changed, 919 insertions(+), 405 deletions(-) create mode 100644 mapbox_gl_web/lib/src/layer_tools.dart create mode 100644 scripts/templates/layer_tools.dart.template diff --git a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java index 53656213c..abf409362 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java +++ b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java @@ -21,6 +21,48 @@ static PropertyValue[] interpretSymbolLayerProperties(Object o) { for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { + case "icon-opacity": + properties.add(PropertyFactory.iconOpacity(expression)); + break; + case "icon-color": + properties.add(PropertyFactory.iconColor(expression)); + break; + case "icon-halo-color": + properties.add(PropertyFactory.iconHaloColor(expression)); + break; + case "icon-halo-width": + properties.add(PropertyFactory.iconHaloWidth(expression)); + break; + case "icon-halo-blur": + properties.add(PropertyFactory.iconHaloBlur(expression)); + break; + case "icon-translate": + properties.add(PropertyFactory.iconTranslate(expression)); + break; + case "icon-translate-anchor": + properties.add(PropertyFactory.iconTranslateAnchor(expression)); + break; + case "text-opacity": + properties.add(PropertyFactory.textOpacity(expression)); + break; + case "text-color": + properties.add(PropertyFactory.textColor(expression)); + break; + case "text-halo-color": + properties.add(PropertyFactory.textHaloColor(expression)); + break; + case "text-halo-width": + properties.add(PropertyFactory.textHaloWidth(expression)); + break; + case "text-halo-blur": + properties.add(PropertyFactory.textHaloBlur(expression)); + break; + case "text-translate": + properties.add(PropertyFactory.textTranslate(expression)); + break; + case "text-translate-anchor": + properties.add(PropertyFactory.textTranslateAnchor(expression)); + break; case "symbol-placement": properties.add(PropertyFactory.symbolPlacement(expression)); break; @@ -147,48 +189,6 @@ static PropertyValue[] interpretSymbolLayerProperties(Object o) { case "visibility": properties.add(PropertyFactory.visibility(expression)); break; - case "icon-opacity": - properties.add(PropertyFactory.iconOpacity(expression)); - break; - case "icon-color": - properties.add(PropertyFactory.iconColor(expression)); - break; - case "icon-halo-color": - properties.add(PropertyFactory.iconHaloColor(expression)); - break; - case "icon-halo-width": - properties.add(PropertyFactory.iconHaloWidth(expression)); - break; - case "icon-halo-blur": - properties.add(PropertyFactory.iconHaloBlur(expression)); - break; - case "icon-translate": - properties.add(PropertyFactory.iconTranslate(expression)); - break; - case "icon-translate-anchor": - properties.add(PropertyFactory.iconTranslateAnchor(expression)); - break; - case "text-opacity": - properties.add(PropertyFactory.textOpacity(expression)); - break; - case "text-color": - properties.add(PropertyFactory.textColor(expression)); - break; - case "text-halo-color": - properties.add(PropertyFactory.textHaloColor(expression)); - break; - case "text-halo-width": - properties.add(PropertyFactory.textHaloWidth(expression)); - break; - case "text-halo-blur": - properties.add(PropertyFactory.textHaloBlur(expression)); - break; - case "text-translate": - properties.add(PropertyFactory.textTranslate(expression)); - break; - case "text-translate-anchor": - properties.add(PropertyFactory.textTranslateAnchor(expression)); - break; default: break; } @@ -204,12 +204,6 @@ static PropertyValue[] interpretCircleLayerProperties(Object o) { for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { - case "circle-sort-key": - properties.add(PropertyFactory.circleSortKey(expression)); - break; - case "visibility": - properties.add(PropertyFactory.visibility(expression)); - break; case "circle-radius": properties.add(PropertyFactory.circleRadius(expression)); break; @@ -243,6 +237,12 @@ static PropertyValue[] interpretCircleLayerProperties(Object o) { case "circle-stroke-opacity": properties.add(PropertyFactory.circleStrokeOpacity(expression)); break; + case "circle-sort-key": + properties.add(PropertyFactory.circleSortKey(expression)); + break; + case "visibility": + properties.add(PropertyFactory.visibility(expression)); + break; default: break; } @@ -258,24 +258,6 @@ static PropertyValue[] interpretLineLayerProperties(Object o) { for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { - case "line-cap": - properties.add(PropertyFactory.lineCap(expression)); - break; - case "line-join": - properties.add(PropertyFactory.lineJoin(expression)); - break; - case "line-miter-limit": - properties.add(PropertyFactory.lineMiterLimit(expression)); - break; - case "line-round-limit": - properties.add(PropertyFactory.lineRoundLimit(expression)); - break; - case "line-sort-key": - properties.add(PropertyFactory.lineSortKey(expression)); - break; - case "visibility": - properties.add(PropertyFactory.visibility(expression)); - break; case "line-opacity": properties.add(PropertyFactory.lineOpacity(expression)); break; @@ -309,6 +291,24 @@ static PropertyValue[] interpretLineLayerProperties(Object o) { case "line-gradient": properties.add(PropertyFactory.lineGradient(expression)); break; + case "line-cap": + properties.add(PropertyFactory.lineCap(expression)); + break; + case "line-join": + properties.add(PropertyFactory.lineJoin(expression)); + break; + case "line-miter-limit": + properties.add(PropertyFactory.lineMiterLimit(expression)); + break; + case "line-round-limit": + properties.add(PropertyFactory.lineRoundLimit(expression)); + break; + case "line-sort-key": + properties.add(PropertyFactory.lineSortKey(expression)); + break; + case "visibility": + properties.add(PropertyFactory.visibility(expression)); + break; default: break; } @@ -324,12 +324,6 @@ static PropertyValue[] interpretFillLayerProperties(Object o) { for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { - case "fill-sort-key": - properties.add(PropertyFactory.fillSortKey(expression)); - break; - case "visibility": - properties.add(PropertyFactory.visibility(expression)); - break; case "fill-antialias": properties.add(PropertyFactory.fillAntialias(expression)); break; @@ -351,6 +345,12 @@ static PropertyValue[] interpretFillLayerProperties(Object o) { case "fill-pattern": properties.add(PropertyFactory.fillPattern(expression)); break; + case "fill-sort-key": + properties.add(PropertyFactory.fillSortKey(expression)); + break; + case "visibility": + properties.add(PropertyFactory.visibility(expression)); + break; default: break; } diff --git a/ios/Classes/LayerPropertyConverter.swift b/ios/Classes/LayerPropertyConverter.swift index b06547ee4..17a5ceae4 100644 --- a/ios/Classes/LayerPropertyConverter.swift +++ b/ios/Classes/LayerPropertyConverter.swift @@ -9,6 +9,48 @@ class LayerPropertyConverter { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { + case "icon-opacity": + lineLayer.iconOpacity = expression; + break; + case "icon-color": + lineLayer.iconColor = expression; + break; + case "icon-halo-color": + lineLayer.iconHaloColor = expression; + break; + case "icon-halo-width": + lineLayer.iconHaloWidth = expression; + break; + case "icon-halo-blur": + lineLayer.iconHaloBlur = expression; + break; + case "icon-translate": + lineLayer.iconTranslate = expression; + break; + case "icon-translate-anchor": + lineLayer.iconTranslateAnchor = expression; + break; + case "text-opacity": + lineLayer.textOpacity = expression; + break; + case "text-color": + lineLayer.textColor = expression; + break; + case "text-halo-color": + lineLayer.textHaloColor = expression; + break; + case "text-halo-width": + lineLayer.textHaloWidth = expression; + break; + case "text-halo-blur": + lineLayer.textHaloBlur = expression; + break; + case "text-translate": + lineLayer.textTranslate = expression; + break; + case "text-translate-anchor": + lineLayer.textTranslateAnchor = expression; + break; case "symbol-placement": lineLayer.symbolPlacement = expression; break; @@ -135,50 +177,7 @@ class LayerPropertyConverter { case "visibility": lineLayer.visibility = expression; break; - case "icon-opacity": - lineLayer.iconOpacity = expression; - break; - case "icon-color": - lineLayer.iconColor = expression; - break; - case "icon-halo-color": - lineLayer.iconHaloColor = expression; - break; - case "icon-halo-width": - lineLayer.iconHaloWidth = expression; - break; - case "icon-halo-blur": - lineLayer.iconHaloBlur = expression; - break; - case "icon-translate": - lineLayer.iconTranslate = expression; - break; - case "icon-translate-anchor": - lineLayer.iconTranslateAnchor = expression; - break; - case "text-opacity": - lineLayer.textOpacity = expression; - break; - case "text-color": - lineLayer.textColor = expression; - break; - case "text-halo-color": - lineLayer.textHaloColor = expression; - break; - case "text-halo-width": - lineLayer.textHaloWidth = expression; - break; - case "text-halo-blur": - lineLayer.textHaloBlur = expression; - break; - case "text-translate": - lineLayer.textTranslate = expression; - break; - case "text-translate-anchor": - lineLayer.textTranslateAnchor = expression; - break; - case "line-blur": - lineLayer.lineBlur = expression + default: break } @@ -189,12 +188,6 @@ class LayerPropertyConverter { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { - case "circle-sort-key": - lineLayer.circleSortKey = expression; - break; - case "visibility": - lineLayer.visibility = expression; - break; case "circle-radius": lineLayer.circleRadius = expression; break; @@ -228,8 +221,13 @@ class LayerPropertyConverter { case "circle-stroke-opacity": lineLayer.circleStrokeOpacity = expression; break; - case "line-blur": - lineLayer.lineBlur = expression + case "circle-sort-key": + lineLayer.circleSortKey = expression; + break; + case "visibility": + lineLayer.visibility = expression; + break; + default: break } @@ -240,24 +238,6 @@ class LayerPropertyConverter { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { - case "line-cap": - lineLayer.lineCap = expression; - break; - case "line-join": - lineLayer.lineJoin = expression; - break; - case "line-miter-limit": - lineLayer.lineMiterLimit = expression; - break; - case "line-round-limit": - lineLayer.lineRoundLimit = expression; - break; - case "line-sort-key": - lineLayer.lineSortKey = expression; - break; - case "visibility": - lineLayer.visibility = expression; - break; case "line-opacity": lineLayer.lineOpacity = expression; break; @@ -291,8 +271,25 @@ class LayerPropertyConverter { case "line-gradient": lineLayer.lineGradient = expression; break; - case "line-blur": - lineLayer.lineBlur = expression + case "line-cap": + lineLayer.lineCap = expression; + break; + case "line-join": + lineLayer.lineJoin = expression; + break; + case "line-miter-limit": + lineLayer.lineMiterLimit = expression; + break; + case "line-round-limit": + lineLayer.lineRoundLimit = expression; + break; + case "line-sort-key": + lineLayer.lineSortKey = expression; + break; + case "visibility": + lineLayer.visibility = expression; + break; + default: break } @@ -303,12 +300,6 @@ class LayerPropertyConverter { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { - case "fill-sort-key": - lineLayer.fillSortKey = expression; - break; - case "visibility": - lineLayer.visibility = expression; - break; case "fill-antialias": lineLayer.fillAntialias = expression; break; @@ -330,8 +321,13 @@ class LayerPropertyConverter { case "fill-pattern": lineLayer.fillPattern = expression; break; - case "line-blur": - lineLayer.lineBlur = expression + case "fill-sort-key": + lineLayer.fillSortKey = expression; + break; + case "visibility": + lineLayer.visibility = expression; + break; + default: break } diff --git a/lib/src/layer_helper.dart b/lib/src/layer_helper.dart index 3c30ed36a..7621d16f0 100644 --- a/lib/src/layer_helper.dart +++ b/lib/src/layer_helper.dart @@ -5,474 +5,827 @@ part of mapbox_gl; class SymbolProperties{ - /// Label placement relative to its geometry. + // Paint Properties + /// The opacity at which the icon will be drawn. + static const iconOpacity = "icon-opacity"; + + /// The color of the icon. This can only be used with sdf icons. + static const iconColor = "icon-color"; + + /// The color of the icon's halo. Icon halos can only be used with SDF + /// icons. + static const iconHaloColor = "icon-halo-color"; + + /// Distance of halo to the icon outline. + static const iconHaloWidth = "icon-halo-width"; + + /// Fade out the halo towards the outside. + static const iconHaloBlur = "icon-halo-blur"; + + /// 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. + static const iconTranslate = "icon-translate"; + + /// Controls the frame of reference for `icon-translate`. + static const iconTranslateAnchor = "icon-translate-anchor"; + + /// The opacity at which the text will be drawn. + static const textOpacity = "text-opacity"; + + /// The color with which the text will be drawn. + static const textColor = "text-color"; + + /// The color of the text's halo, which helps it stand out from + /// backgrounds. + static const textHaloColor = "text-halo-color"; + + /// Distance of halo to the font outline. Max text halo width is 1/4 of + /// the font-size. + static const textHaloWidth = "text-halo-width"; + + /// The halo's fadeout distance towards the outside. + static const textHaloBlur = "text-halo-blur"; + + /// 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. + static const textTranslate = "text-translate"; + + /// Controls the frame of reference for `text-translate`. + static const textTranslateAnchor = "text-translate-anchor"; + + + // Layout Properties + /// Label placement relative to its geometry. static const symbolPlacement = "symbol-placement"; - /// Distance between two symbol anchors. + /// Distance between two symbol anchors. static const symbolSpacing = "symbol-spacing"; - /// 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. When using a client that - /// supports global collision detection, like Mapbox GL JS version 0.42.0 - /// or greater, enabling this property is not needed to prevent clipped - /// labels at tile boundaries. + /// 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. When using a client that + /// supports global collision detection, like Mapbox GL JS version 0.42.0 + /// or greater, enabling this property is not needed to prevent clipped + /// labels at tile boundaries. static const symbolAvoidEdges = "symbol-avoid-edges"; - /// Sorts features in ascending order based on this value. Features with - /// lower sort keys are drawn and placed first. When `icon-allow-overlap` - /// or `text-allow-overlap` is `false`, features with a lower sort key - /// will have priority during placement. When `icon-allow-overlap` or - /// `text-allow-overlap` is set to `true`, features with a higher sort key - /// will overlap over features with a lower sort key. + /// Sorts features in ascending order based on this value. Features with + /// lower sort keys are drawn and placed first. When + /// `icon-allow-overlap` or `text-allow-overlap` is `false`, features + /// with a lower sort key will have priority during placement. When + /// `icon-allow-overlap` or `text-allow-overlap` is set to `true`, + /// features with a higher sort key will overlap over features with a + /// lower sort key. static const symbolSortKey = "symbol-sort-key"; - /// Controls the order in which overlapping symbols in the same layer are - /// rendered + /// Controls the order in which overlapping symbols in the same layer are + /// rendered static const symbolZOrder = "symbol-z-order"; - /// If true, the icon will be visible even if it collides with other - /// previously drawn symbols. + /// If true, the icon will be visible even if it collides with other + /// previously drawn symbols. static const iconAllowOverlap = "icon-allow-overlap"; - /// If true, other symbols can be visible even if they collide with the - /// icon. + /// If true, other symbols can be visible even if they collide with the + /// icon. static const iconIgnorePlacement = "icon-ignore-placement"; - /// If true, text will display without their corresponding icons when the - /// icon collides with other symbols and the text does not. + /// If true, text will display without their corresponding icons when the + /// icon collides with other symbols and the text does not. static const iconOptional = "icon-optional"; - /// In combination with `symbol-placement`, determines the rotation - /// behavior of icons. + /// In combination with `symbol-placement`, determines the rotation + /// behavior of icons. static const iconRotationAlignment = "icon-rotation-alignment"; - /// Scales the original size of the icon by the provided factor. The new - /// pixel size of the image will be the original pixel size multiplied by - /// `icon-size`. 1 is the original size; 3 triples the size of the image. + /// Scales the original size of the icon by the provided factor. The new + /// pixel size of the image will be the original pixel size multiplied by + /// `icon-size`. 1 is the original size; 3 triples the size of the image. static const iconSize = "icon-size"; - /// Scales the icon to fit around the associated text. + /// Scales the icon to fit around the associated text. static const iconTextFit = "icon-text-fit"; - /// Size of the additional area added to dimensions determined by - /// `icon-text-fit`, in clockwise order: top, right, bottom, left. + /// Size of the additional area added to dimensions determined by + /// `icon-text-fit`, in clockwise order: top, right, bottom, left. static const iconTextFitPadding = "icon-text-fit-padding"; - /// Name of image in sprite to use for drawing an image background. + /// Name of image in sprite to use for drawing an image background. static const iconImage = "icon-image"; - /// Rotates the icon clockwise. + /// Rotates the icon clockwise. static const iconRotate = "icon-rotate"; - /// Size of the additional area around the icon bounding box used for - /// detecting symbol collisions. + /// Size of the additional area around the icon bounding box used for + /// detecting symbol collisions. static const iconPadding = "icon-padding"; - /// If true, the icon may be flipped to prevent it from being rendered - /// upside-down. + /// If true, the icon may be flipped to prevent it from being rendered + /// upside-down. static const iconKeepUpright = "icon-keep-upright"; - /// Offset distance of icon from its anchor. Positive values indicate - /// right and down, while negative values indicate left and up. Each - /// component is multiplied by the value of `icon-size` to obtain the - /// final offset in pixels. When combined with `icon-rotate` the offset - /// will be as if the rotated direction was up. + /// Offset distance of icon from its anchor. Positive values indicate + /// right and down, while negative values indicate left and up. Each + /// component is multiplied by the value of `icon-size` to obtain the + /// final offset in pixels. When combined with `icon-rotate` the offset + /// will be as if the rotated direction was up. static const iconOffset = "icon-offset"; - /// Part of the icon placed closest to the anchor. + /// Part of the icon placed closest to the anchor. static const iconAnchor = "icon-anchor"; - /// Orientation of icon when map is pitched. + /// Orientation of icon when map is pitched. static const iconPitchAlignment = "icon-pitch-alignment"; - /// Orientation of text when map is pitched. + /// Orientation of text when map is pitched. static const textPitchAlignment = "text-pitch-alignment"; - /// In combination with `symbol-placement`, determines the rotation - /// behavior of the individual glyphs forming the text. + /// In combination with `symbol-placement`, determines the rotation + /// behavior of the individual glyphs forming the text. static const textRotationAlignment = "text-rotation-alignment"; - /// Value to use for a text label. If a plain `string` is provided, it - /// will be treated as a `formatted` with default/inherited formatting - /// options. + /// Value to use for a text label. If a plain `string` is provided, it + /// will be treated as a `formatted` with default/inherited formatting + /// options. static const textField = "text-field"; - /// Font stack to use for displaying text. + /// Font stack to use for displaying text. static const textFont = "text-font"; - /// Font size. + /// Font size. static const textSize = "text-size"; - /// The maximum line width for text wrapping. + /// The maximum line width for text wrapping. static const textMaxWidth = "text-max-width"; - /// Text leading value for multi-line text. + /// Text leading value for multi-line text. static const textLineHeight = "text-line-height"; - /// Text tracking amount. + /// Text tracking amount. static const textLetterSpacing = "text-letter-spacing"; - /// Text justification options. + /// Text justification options. static const textJustify = "text-justify"; - /// Radial offset of text, in the direction of the symbol's anchor. Useful - /// in combination with `text-variable-anchor`, which defaults to using - /// the two-dimensional `text-offset` if present. + /// Radial offset of text, in the direction of the symbol's anchor. + /// Useful in combination with `text-variable-anchor`, which defaults to + /// using the two-dimensional `text-offset` if present. static const textRadialOffset = "text-radial-offset"; - /// To increase the chance of placing high-priority labels on the map, you - /// can provide an array of `text-anchor` locations: the renderer will - /// attempt to place the label at each location, in order, before moving - /// onto the next label. Use `text-justify: auto` to choose justification - /// based on anchor position. To apply an offset, use the - /// `text-radial-offset` or the two-dimensional `text-offset`. + /// To increase the chance of placing high-priority labels on the map, + /// you can provide an array of `text-anchor` locations: the renderer + /// will attempt to place the label at each location, in order, before + /// moving onto the next label. Use `text-justify: auto` to choose + /// justification based on anchor position. To apply an offset, use the + /// `text-radial-offset` or the two-dimensional `text-offset`. static const textVariableAnchor = "text-variable-anchor"; - /// Part of the text placed closest to the anchor. + /// Part of the text placed closest to the anchor. static const textAnchor = "text-anchor"; - /// Maximum angle change between adjacent characters. + /// Maximum angle change between adjacent characters. static const textMaxAngle = "text-max-angle"; - /// The property allows control over a symbol's orientation. Note that the - /// property values act as a hint, so that a symbol whose language doesn’t - /// support the provided orientation will be laid out in its natural - /// orientation. Example: English point symbol will be rendered - /// horizontally even if array value contains single 'vertical' enum - /// value. The order of elements in an array define priority order for the - /// placement of an orientation variant. + /// The property allows control over a symbol's orientation. Note that + /// the property values act as a hint, so that a symbol whose language + /// doesn’t support the provided orientation will be laid out in its + /// natural orientation. Example: English point symbol will be rendered + /// horizontally even if array value contains single 'vertical' enum + /// value. The order of elements in an array define priority order for + /// the placement of an orientation variant. static const textWritingMode = "text-writing-mode"; - /// Rotates the text clockwise. + /// Rotates the text clockwise. static const textRotate = "text-rotate"; - /// Size of the additional area around the text bounding box used for - /// detecting symbol collisions. + /// Size of the additional area around the text bounding box used for + /// detecting symbol collisions. static const textPadding = "text-padding"; - /// If true, the text may be flipped vertically to prevent it from being - /// rendered upside-down. + /// If true, the text may be flipped vertically to prevent it from being + /// rendered upside-down. static const textKeepUpright = "text-keep-upright"; - /// Specifies how to capitalize text, similar to the CSS `text-transform` - /// property. + /// Specifies how to capitalize text, similar to the CSS `text-transform` + /// property. static const textTransform = "text-transform"; - /// Offset distance of text from its anchor. Positive values indicate - /// right and down, while negative values indicate left and up. If used - /// with text-variable-anchor, input values will be taken as absolute - /// values. Offsets along the x- and y-axis will be applied automatically - /// based on the anchor position. + /// Offset distance of text from its anchor. Positive values indicate + /// right and down, while negative values indicate left and up. If used + /// with text-variable-anchor, input values will be taken as absolute + /// values. Offsets along the x- and y-axis will be applied automatically + /// based on the anchor position. static const textOffset = "text-offset"; - /// If true, the text will be visible even if it collides with other - /// previously drawn symbols. + /// If true, the text will be visible even if it collides with other + /// previously drawn symbols. static const textAllowOverlap = "text-allow-overlap"; - /// If true, other symbols can be visible even if they collide with the - /// text. + /// If true, other symbols can be visible even if they collide with the + /// text. static const textIgnorePlacement = "text-ignore-placement"; - /// If true, icons will display without their corresponding text when the - /// text collides with other symbols and the icon does not. + /// If true, icons will display without their corresponding text when the + /// text collides with other symbols and the icon does not. static const textOptional = "text-optional"; - /// Whether this layer is displayed. + /// Whether this layer is displayed. static const visibility = "visibility"; - /// The opacity at which the icon will be drawn. - static const iconOpacity = "icon-opacity"; - - /// The color of the icon. This can only be used with sdf icons. - static const iconColor = "icon-color"; - - /// The color of the icon's halo. Icon halos can only be used with SDF - /// icons. - static const iconHaloColor = "icon-halo-color"; - - /// Distance of halo to the icon outline. - static const iconHaloWidth = "icon-halo-width"; - - /// Fade out the halo towards the outside. - static const iconHaloBlur = "icon-halo-blur"; - - /// 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. - static const iconTranslate = "icon-translate"; - - /// Controls the frame of reference for `icon-translate`. - static const iconTranslateAnchor = "icon-translate-anchor"; - - /// The opacity at which the text will be drawn. - static const textOpacity = "text-opacity"; - - /// The color with which the text will be drawn. - static const textColor = "text-color"; - - /// The color of the text's halo, which helps it stand out from - /// backgrounds. - static const textHaloColor = "text-halo-color"; - - /// Distance of halo to the font outline. Max text halo width is 1/4 of - /// the font-size. - static const textHaloWidth = "text-halo-width"; - - /// The halo's fadeout distance towards the outside. - static const textHaloBlur = "text-halo-blur"; - - /// 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. - static const textTranslate = "text-translate"; - - /// Controls the frame of reference for `text-translate`. - static const textTranslateAnchor = "text-translate-anchor"; - } class CircleProperties{ - /// Sorts features in ascending order based on this value. Features with a - /// higher sort key will appear above features with a lower sort key. - static const circleSortKey = "circle-sort-key"; - - /// Whether this layer is displayed. - static const visibility = "visibility"; - - /// Circle radius. + // Paint Properties + /// Circle radius. static const circleRadius = "circle-radius"; - /// The fill color of the circle. + /// The fill color of the circle. static const circleColor = "circle-color"; - /// Amount to blur the circle. 1 blurs the circle such that only the - /// centerpoint is full opacity. + /// Amount to blur the circle. 1 blurs the circle such that only the + /// centerpoint is full opacity. static const circleBlur = "circle-blur"; - /// The opacity at which the circle will be drawn. + /// The opacity at which the circle will be drawn. static const circleOpacity = "circle-opacity"; - /// The geometry's offset. Values are [x, y] where negatives indicate left - /// and up, respectively. + /// The geometry's offset. Values are [x, y] where negatives indicate + /// left and up, respectively. static const circleTranslate = "circle-translate"; - /// Controls the frame of reference for `circle-translate`. + /// Controls the frame of reference for `circle-translate`. static const circleTranslateAnchor = "circle-translate-anchor"; - /// Controls the scaling behavior of the circle when the map is pitched. + /// Controls the scaling behavior of the circle when the map is pitched. static const circlePitchScale = "circle-pitch-scale"; - /// Orientation of circle when map is pitched. + /// Orientation of circle when map is pitched. static const circlePitchAlignment = "circle-pitch-alignment"; - /// The width of the circle's stroke. Strokes are placed outside of the - /// `circle-radius`. + /// The width of the circle's stroke. Strokes are placed outside of the + /// `circle-radius`. static const circleStrokeWidth = "circle-stroke-width"; - /// The stroke color of the circle. + /// The stroke color of the circle. static const circleStrokeColor = "circle-stroke-color"; - /// The opacity of the circle's stroke. + /// The opacity of the circle's stroke. static const circleStrokeOpacity = "circle-stroke-opacity"; -} + // Layout Properties + /// Sorts features in ascending order based on this value. Features with + /// a higher sort key will appear above features with a lower sort key. + static const circleSortKey = "circle-sort-key"; -class LineProperties{ - /// The display of line endings. - static const lineCap = "line-cap"; - - /// The display of lines when joining. - static const lineJoin = "line-join"; - - /// Used to automatically convert miter joins to bevel joins for sharp - /// angles. - static const lineMiterLimit = "line-miter-limit"; - - /// Used to automatically convert round joins to miter joins for shallow - /// angles. - static const lineRoundLimit = "line-round-limit"; + /// Whether this layer is displayed. + static const visibility = "visibility"; - /// Sorts features in ascending order based on this value. Features with a - /// higher sort key will appear above features with a lower sort key. - static const lineSortKey = "line-sort-key"; +} - /// Whether this layer is displayed. - static const visibility = "visibility"; - /// The opacity at which the line will be drawn. +class LineProperties{ + // Paint Properties + /// The opacity at which the line will be drawn. static const lineOpacity = "line-opacity"; - /// The color with which the line will be drawn. + /// The color with which the line will be drawn. static const lineColor = "line-color"; - /// The geometry's offset. Values are [x, y] where negatives indicate left - /// and up, respectively. + /// The geometry's offset. Values are [x, y] where negatives indicate + /// left and up, respectively. static const lineTranslate = "line-translate"; - /// Controls the frame of reference for `line-translate`. + /// Controls the frame of reference for `line-translate`. static const lineTranslateAnchor = "line-translate-anchor"; - /// Stroke thickness. + /// Stroke thickness. static const lineWidth = "line-width"; - /// Draws a line casing outside of a line's actual path. Value indicates - /// the width of the inner gap. + /// Draws a line casing outside of a line's actual path. Value indicates + /// the width of the inner gap. static const lineGapWidth = "line-gap-width"; - /// The line's offset. For linear features, a positive value offsets the - /// line to the right, relative to the direction of the line, and a - /// negative value to the left. For polygon features, a positive value - /// results in an inset, and a negative value results in an outset. + /// The line's offset. For linear features, a positive value offsets the + /// line to the right, relative to the direction of the line, and a + /// negative value to the left. For polygon features, a positive value + /// results in an inset, and a negative value results in an outset. static const lineOffset = "line-offset"; - /// Blur applied to the line, in pixels. + /// Blur applied to the line, in pixels. static const lineBlur = "line-blur"; - /// 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. Note that GeoJSON sources with `lineMetrics: true` - /// specified won't render dashed lines to the expected scale. Also note - /// that zoom-dependent expressions will be evaluated only at integer zoom - /// levels. + /// 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. Note that GeoJSON sources with `lineMetrics: true` + /// specified won't render dashed lines to the expected scale. Also note + /// that zoom-dependent expressions will be evaluated only at integer + /// zoom levels. static const lineDasharray = "line-dasharray"; - /// 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). - /// Note that zoom-dependent expressions will be evaluated only at integer - /// zoom levels. + /// 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). + /// Note that zoom-dependent expressions will be evaluated only at + /// integer zoom levels. static const linePattern = "line-pattern"; - /// Defines a gradient with which to color a line feature. Can only be - /// used with GeoJSON sources that specify `"lineMetrics": true`. + /// Defines a gradient with which to color a line feature. Can only be + /// used with GeoJSON sources that specify `"lineMetrics": true`. static const lineGradient = "line-gradient"; -} + // Layout Properties + /// The display of line endings. + static const lineCap = "line-cap"; + + /// The display of lines when joining. + static const lineJoin = "line-join"; -class FillProperties{ - /// Sorts features in ascending order based on this value. Features with a - /// higher sort key will appear above features with a lower sort key. - static const fillSortKey = "fill-sort-key"; + /// Used to automatically convert miter joins to bevel joins for sharp + /// angles. + static const lineMiterLimit = "line-miter-limit"; - /// Whether this layer is displayed. + /// Used to automatically convert round joins to miter joins for shallow + /// angles. + static const lineRoundLimit = "line-round-limit"; + + /// Sorts features in ascending order based on this value. Features with + /// a higher sort key will appear above features with a lower sort key. + static const lineSortKey = "line-sort-key"; + + /// Whether this layer is displayed. static const visibility = "visibility"; - /// Whether or not the fill should be antialiased. +} + + +class FillProperties{ + // Paint Properties + /// Whether or not the fill should be antialiased. static const fillAntialias = "fill-antialias"; - /// 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. + /// 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. static const fillOpacity = "fill-opacity"; - /// 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. + /// 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. static const fillColor = "fill-color"; - /// The outline color of the fill. Matches the value of `fill-color` if - /// unspecified. + /// The outline color of the fill. Matches the value of `fill-color` if + /// unspecified. static const fillOutlineColor = "fill-outline-color"; - /// The geometry's offset. Values are [x, y] where negatives indicate left - /// and up, respectively. + /// The geometry's offset. Values are [x, y] where negatives indicate + /// left and up, respectively. static const fillTranslate = "fill-translate"; - /// Controls the frame of reference for `fill-translate`. + /// Controls the frame of reference for `fill-translate`. static const fillTranslateAnchor = "fill-translate-anchor"; - /// 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). Note that zoom-dependent expressions will be evaluated only - /// at integer zoom levels. + /// 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). Note that zoom-dependent expressions will be evaluated + /// only at integer zoom levels. static const fillPattern = "fill-pattern"; + + // Layout Properties + /// Sorts features in ascending order based on this value. Features with + /// a higher sort key will appear above features with a lower sort key. + static const fillSortKey = "fill-sort-key"; + + /// Whether this layer is displayed. + static const visibility = "visibility"; + } + + class Expressions{ + /// Binds expressions to named variables, which can then be referenced in + /// the result expression using ["var", "variable_name"]. static const let = "let"; + + /// References variable bound using "let". static const varExpression = "var"; + + /// Provides a literal array or object value. static const literal = "literal"; + + /// Asserts that the input is an array (optionally with a specific item + /// type and length). If, when the input expression is evaluated, it is + /// not of the asserted type, then this assertion will cause the whole + /// expression to be aborted. static const array = "array"; + + /// Retrieves an item from an array. static const at = "at"; + + /// Determines whether an item exists in an array or a substring exists + /// in a string. static const inExpression = "in"; + + /// Selects the first output whose corresponding test condition evaluates + /// to true, or the fallback value otherwise. static const caseExpression = "case"; + + /// Selects the output whose label value matches the input value, or the + /// fallback value if no match is found. The input can be any expression + /// (e.g. `["get", "building_type"]`). Each label must be either: + /// * a single literal value; or + /// * an array of literal values, whose values must be all strings or all + /// numbers (e.g. `[100, 101]` or `["c", "b"]`). The input matches if any + /// of the values in the array matches, similar to the `"in"` + /// operator.Each label must be unique. If the input type does not + /// match the type of the labels, the result will be the fallback value. static const match = "match"; + + /// Evaluates each expression in turn until the first non-null value is + /// obtained, and returns that value. static const coalesce = "coalesce"; + + /// Produces discrete, stepped results by evaluating a piecewise-constant + /// function defined by pairs of input and output values ("stops"). The + /// `input` may be any numeric expression (e.g., `["get", + /// "population"]`). Stop inputs must be numeric literals in strictly + /// ascending order. Returns the output value of the stop just less than + /// the input, or the first output if the input is less than the first + /// stop. static const step = "step"; + + /// Produces continuous, smooth results by interpolating between pairs of + /// input and output values ("stops"). The `input` may be any numeric + /// expression (e.g., `["get", "population"]`). Stop inputs must be + /// numeric literals in strictly ascending order. The output type must be + /// `number`, `array`, or `color`.Interpolation types:- + /// `["linear"]`: interpolates linearly between the pair of stops just + /// less than and just greater than the input.- `["exponential", base]`: + /// interpolates exponentially between the stops just less than and just + /// greater than the input. `base` controls the rate at which the output + /// increases: higher values make the output increase more towards the + /// high end of the range. With values close to 1 the output increases + /// linearly.- `["cubic-bezier", x1, y1, x2, y2]`: interpolates using + /// the cubic bezier curve defined by the given control points. static const interpolate = "interpolate"; + + /// Produces continuous, smooth results by interpolating between pairs of + /// input and output values ("stops"). Works like `interpolate`, but the + /// output type must be `color`, and the interpolation is performed in + /// the Hue-Chroma-Luminance color space. static const interpolateHcl = "interpolate-hcl"; + + /// Produces continuous, smooth results by interpolating between pairs of + /// input and output values ("stops"). Works like `interpolate`, but the + /// output type must be `color`, and the interpolation is performed in + /// the CIELAB color space. static const interpolateLab = "interpolate-lab"; + + /// Returns mathematical constant ln(2). static const ln2 = "ln2"; + + /// Returns the mathematical constant pi. static const pi = "pi"; + + /// Returns the mathematical constant e. static const e = "e"; + + /// Returns a string describing the type of the given value. static const typeof = "typeof"; + + /// Asserts that the input value is a string. If multiple values are + /// provided, each one is evaluated in order until a string is obtained. + /// If none of the inputs are strings, the expression is an error. static const string = "string"; + + /// Asserts that the input value is a number. If multiple values are + /// provided, each one is evaluated in order until a number is obtained. + /// If none of the inputs are numbers, the expression is an error. static const number = "number"; + + /// Asserts that the input value is a boolean. If multiple values are + /// provided, each one is evaluated in order until a boolean is obtained. + /// If none of the inputs are booleans, the expression is an error. static const boolean = "boolean"; + + /// Asserts that the input value is an object. If multiple values are + /// provided, each one is evaluated in order until an object is obtained. + /// If none of the inputs are objects, the expression is an error. static const object = "object"; + + /// Returns a `collator` for use in locale-dependent comparison + /// operations. The `case-sensitive` and `diacritic-sensitive` options + /// default to `false`. The `locale` argument specifies the IETF language + /// tag of the locale to use. If none is provided, the default locale is + /// used. If the requested locale is not available, the `collator` will + /// use a system-defined fallback locale. Use `resolved-locale` to test + /// the results of locale fallback behavior. static const collator = "collator"; + + /// Returns `formatted` text containing annotations for use in + /// mixed-format `text-field` entries. For a `text-field` entries of a + /// string type, following option object's properties are supported: If + /// set, the `text-font` value overrides the font specified by the root + /// layout properties. If set, the `font-scale` value specifies a scaling + /// factor relative to the `text-size` specified in the root layout + /// properties. If set, the `text-color` value overrides the color + /// specified by the root paint properties for this layer. static const format = "format"; + + /// Returns an `image` type for use in `icon-image`, `*-pattern` entries + /// and as a section in the `format` expression. If set, the `image` + /// argument will check that the requested image exists in the style and + /// will return either the resolved image name or `null`, depending on + /// whether or not the image is currently in the style. This validation + /// process is synchronous and requires the image to have been added to + /// the style before requesting it in the `image` argument. static const image = "image"; + + /// Converts the input number into a string representation using the + /// providing formatting rules. If set, the `locale` argument specifies + /// the locale to use, as a BCP 47 language tag. If set, the `currency` + /// argument specifies an ISO 4217 code to use for currency-style + /// formatting. If set, the `min-fraction-digits` and + /// `max-fraction-digits` arguments specify the minimum and maximum + /// number of fractional digits to include. static const numberFormat = "number-format"; + + /// Converts the input value to a string. If the input is `null`, the + /// result is `""`. If the input is a boolean, the result is `"true"` or + /// `"false"`. If the input is a number, it is converted to a string as + /// specified by the ["NumberToString" + /// algorithm](https://tc39.github.io/ecma262/#sec-tostring-applied-to-the-number-type) + /// of the ECMAScript Language Specification. If the input is a color, it + /// is converted to a string of the form `"rgba(r,g,b,a)"`, where `r`, + /// `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from + /// 0 to 1. Otherwise, the input is converted to a string in the format + /// specified by the + /// [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) + /// function of the ECMAScript Language Specification. static const toStringExpression = "to-string"; + + /// Converts the input value to a number, if possible. If the input is + /// `null` or `false`, the result is 0. If the input is `true`, the + /// result is 1. If the input is a string, it is converted to a number as + /// specified by the ["ToNumber Applied to the String Type" + /// algorithm](https://tc39.github.io/ecma262/#sec-tonumber-applied-to-the-string-type) + /// of the ECMAScript Language Specification. If multiple values are + /// provided, each one is evaluated in order until the first successful + /// conversion is obtained. If none of the inputs can be converted, the + /// expression is an error. static const toNumber = "to-number"; + + /// Converts the input value to a boolean. The result is `false` when + /// then input is an empty string, 0, `false`, `null`, or `NaN`; + /// otherwise it is `true`. static const toBoolean = "to-boolean"; + + /// Returns a four-element array containing the input color's red, green, + /// blue, and alpha components, in that order. static const toRgba = "to-rgba"; + + /// Converts the input value to a color. If multiple values are provided, + /// each one is evaluated in order until the first successful conversion + /// is obtained. If none of the inputs can be converted, the expression + /// is an error. static const toColor = "to-color"; + + /// Creates a color value from red, green, and blue components, which + /// must range between 0 and 255, and an alpha component of 1. If any + /// component is out of range, the expression is an error. static const rgb = "rgb"; + + /// Creates a color value from red, green, blue components, which must + /// range between 0 and 255, and an alpha component which must range + /// between 0 and 1. If any component is out of range, the expression is + /// an error. static const rgba = "rgba"; + + /// Retrieves a property value from the current feature's properties, or + /// from another object if a second argument is provided. Returns null if + /// the requested property is missing. static const get = "get"; + + /// Tests for the presence of an property value in the current feature's + /// properties, or from another object if a second argument is provided. static const has = "has"; + + /// Gets the length of an array or string. static const length = "length"; + + /// Gets the feature properties object. Note that in some cases, it may + /// be more efficient to use ["get", "property_name"] directly. static const properties = "properties"; + + /// Retrieves a property value from the current feature's state. Returns + /// null if the requested property is not present on the feature's state. + /// A feature's state is not part of the GeoJSON or vector tile data, and + /// must be set programmatically on each feature. Features are identified + /// by their `id` attribute, which must be an integer or a string that + /// can be cast to an integer. Note that ["feature-state"] can only be + /// used with paint properties that support data-driven styling. static const featureState = "feature-state"; + + /// Gets the feature's geometry type: Point, MultiPoint, LineString, + /// MultiLineString, Polygon, MultiPolygon. static const geometryType = "geometry-type"; + + /// Gets the feature's id, if it has one. static const id = "id"; + + /// Gets the current zoom level. Note that in style layout and paint + /// properties, ["zoom"] may only appear as the input to a top-level + /// "step" or "interpolate" expression. static const zoom = "zoom"; + + /// Gets the kernel density estimation of a pixel in a heatmap layer, + /// which is a relative measure of how many data points are crowded + /// around a particular pixel. Can only be used in the `heatmap-color` + /// property. static const heatmapDensity = "heatmap-density"; + + /// Gets the progress along a gradient line. Can only be used in the + /// `line-gradient` property. static const lineProgress = "line-progress"; + + /// Gets the value of a cluster property accumulated so far. Can only be + /// used in the `clusterProperties` option of a clustered GeoJSON source. static const accumulated = "accumulated"; + + /// Returns the sum of the inputs. static const plus = "+"; + + /// Returns the product of the inputs. static const multiply = "*"; + + /// For two inputs, returns the result of subtracting the second input + /// from the first. For a single input, returns the result of subtracting + /// it from 0. static const minus = "-"; + + /// Returns the result of floating point division of the first input by + /// the second. static const divide = "/"; + + /// Returns the remainder after integer division of the first input by + /// the second. static const precent = "%"; + + /// Returns the result of raising the first input to the power specified + /// by the second. static const xor = "^"; + + /// Returns the square root of the input. static const sqrt = "sqrt"; + + /// Returns the base-ten logarithm of the input. static const log10 = "log10"; + + /// Returns the natural logarithm of the input. static const ln = "ln"; + + /// Returns the base-two logarithm of the input. static const log2 = "log2"; + + /// Returns the sine of the input. static const sin = "sin"; + + /// Returns the cosine of the input. static const cos = "cos"; + + /// Returns the tangent of the input. static const tan = "tan"; + + /// Returns the arcsine of the input. static const asin = "asin"; + + /// Returns the arccosine of the input. static const acos = "acos"; + + /// Returns the arctangent of the input. static const atan = "atan"; + + /// Returns the minimum value of the inputs. static const min = "min"; + + /// Returns the maximum value of the inputs. static const max = "max"; + + /// Rounds the input to the nearest integer. Halfway values are rounded + /// away from zero. For example, `["round", -1.5]` evaluates to -2. static const round = "round"; + + /// Returns the absolute value of the input. static const abs = "abs"; + + /// Returns the smallest integer that is greater than or equal to the + /// input. static const ceil = "ceil"; + + /// Returns the largest integer that is less than or equal to the input. static const floor = "floor"; + + /// Returns `true` if the input values are equal, `false` otherwise. The + /// comparison is strictly typed: values of different runtime types are + /// always considered unequal. Cases where the types are known to be + /// different at parse time are considered invalid and will produce a + /// parse error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. static const equal = "=="; + + /// Returns `true` if the input values are not equal, `false` otherwise. + /// The comparison is strictly typed: values of different runtime types + /// are always considered unequal. Cases where the types are known to be + /// different at parse time are considered invalid and will produce a + /// parse error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. static const notEqual = "!="; + + /// Returns `true` if the first input is strictly greater than the + /// second, `false` otherwise. The arguments are required to be either + /// both strings or both numbers; if during evaluation they are not, + /// expression evaluation produces an error. Cases where this constraint + /// is known not to hold at parse time are considered in valid and will + /// produce a parse error. Accepts an optional `collator` argument to + /// control locale-dependent string comparisons. static const larger = ">"; + + /// Returns `true` if the first input is strictly less than the second, + /// `false` otherwise. The arguments are required to be either both + /// strings or both numbers; if during evaluation they are not, + /// expression evaluation produces an error. Cases where this constraint + /// is known not to hold at parse time are considered in valid and will + /// produce a parse error. Accepts an optional `collator` argument to + /// control locale-dependent string comparisons. static const smaller = "<"; + + /// Returns `true` if the first input is greater than or equal to the + /// second, `false` otherwise. The arguments are required to be either + /// both strings or both numbers; if during evaluation they are not, + /// expression evaluation produces an error. Cases where this constraint + /// is known not to hold at parse time are considered in valid and will + /// produce a parse error. Accepts an optional `collator` argument to + /// control locale-dependent string comparisons. static const largerOrEqual = ">="; + + /// Returns `true` if the first input is less than or equal to the + /// second, `false` otherwise. The arguments are required to be either + /// both strings or both numbers; if during evaluation they are not, + /// expression evaluation produces an error. Cases where this constraint + /// is known not to hold at parse time are considered in valid and will + /// produce a parse error. Accepts an optional `collator` argument to + /// control locale-dependent string comparisons. static const smallerOrEqual = "<="; + + /// Returns `true` if all the inputs are `true`, `false` otherwise. The + /// inputs are evaluated in order, and evaluation is short-circuiting: + /// once an input expression evaluates to `false`, the result is `false` + /// and no further input expressions are evaluated. static const all = "all"; + + /// Returns `true` if any of the inputs are `true`, `false` otherwise. + /// The inputs are evaluated in order, and evaluation is + /// short-circuiting: once an input expression evaluates to `true`, the + /// result is `true` and no further input expressions are evaluated. static const any = "any"; + + /// Logical negation. Returns `true` if the input is `false`, and `false` + /// if the input is `true`. static const not = "!"; + + /// Returns `true` if the input string is expected to render legibly. + /// Returns `false` if the input string contains sections that cannot be + /// rendered without potential loss of meaning (e.g. Indic scripts that + /// require complex text shaping, or right-to-left scripts if the the + /// `mapbox-gl-rtl-text` plugin is not in use in Mapbox GL JS). static const isSupportedScript = "is-supported-script"; + + /// Returns the input string converted to uppercase. Follows the Unicode + /// Default Case Conversion algorithm and the locale-insensitive case + /// mappings in the Unicode Character Database. static const upcase = "upcase"; + + /// Returns the input string converted to lowercase. Follows the Unicode + /// Default Case Conversion algorithm and the locale-insensitive case + /// mappings in the Unicode Character Database. static const downcase = "downcase"; + + /// Returns a `string` consisting of the concatenation of the inputs. + /// Each input is converted to a string as if by `to-string`. static const concat = "concat"; + + /// Returns the IETF language tag of the locale being used by the + /// provided `collator`. This can be used to determine the default system + /// locale, or to determine if a requested locale was successfully + /// loaded. static const resolvedLocale = "resolved-locale"; + } diff --git a/mapbox_gl_web/lib/mapbox_gl_web.dart b/mapbox_gl_web/lib/mapbox_gl_web.dart index da703e15c..8aada7d83 100644 --- a/mapbox_gl_web/lib/mapbox_gl_web.dart +++ b/mapbox_gl_web/lib/mapbox_gl_web.dart @@ -18,6 +18,7 @@ import 'package:mapbox_gl_platform_interface/mapbox_gl_platform_interface.dart'; import 'package:mapbox_gl_dart/mapbox_gl_dart.dart' hide Point; import 'package:mapbox_gl_dart/mapbox_gl_dart.dart' as mapbox show Point; import 'package:image/image.dart' hide Point; +import 'package:mapbox_gl_web/src/layer_tools.dart'; part 'src/convert.dart'; part 'src/mapbox_map_plugin.dart'; diff --git a/mapbox_gl_web/lib/src/layer_tools.dart b/mapbox_gl_web/lib/src/layer_tools.dart new file mode 100644 index 000000000..31ad59d92 --- /dev/null +++ b/mapbox_gl_web/lib/src/layer_tools.dart @@ -0,0 +1,58 @@ +// This file is generated by +// ./scripts/lib/generate.dart + +const _layoutProperties = { + "symbol-placement", + "symbol-spacing", + "symbol-avoid-edges", + "symbol-sort-key", + "symbol-z-order", + "icon-allow-overlap", + "icon-ignore-placement", + "icon-optional", + "icon-rotation-alignment", + "icon-size", + "icon-text-fit", + "icon-text-fit-padding", + "icon-image", + "icon-rotate", + "icon-padding", + "icon-keep-upright", + "icon-offset", + "icon-anchor", + "icon-pitch-alignment", + "text-pitch-alignment", + "text-rotation-alignment", + "text-field", + "text-font", + "text-size", + "text-max-width", + "text-line-height", + "text-letter-spacing", + "text-justify", + "text-radial-offset", + "text-variable-anchor", + "text-anchor", + "text-max-angle", + "text-writing-mode", + "text-rotate", + "text-padding", + "text-keep-upright", + "text-transform", + "text-offset", + "text-allow-overlap", + "text-ignore-placement", + "text-optional", + "visibility", + "circle-sort-key", + "line-cap", + "line-join", + "line-miter-limit", + "line-round-limit", + "line-sort-key", + "fill-sort-key", +}; + +bool isLayoutProperty(String property){ + return _layoutProperties.contains(property); +} \ No newline at end of file diff --git a/mapbox_gl_web/lib/src/mapbox_map_controller.dart b/mapbox_gl_web/lib/src/mapbox_map_controller.dart index 308df853a..0a66ff753 100644 --- a/mapbox_gl_web/lib/src/mapbox_map_controller.dart +++ b/mapbox_gl_web/lib/src/mapbox_map_controller.dart @@ -766,4 +766,49 @@ class MapboxMapController extends MapboxGlPlatform var zoom = _map.getZoom(); return circumference * cos(latitude * (pi / 180)) / pow(2, zoom + 9); } + + Future addSource(String sourceId, String source) async { + _map.addSource(sourceId, source); + } + + Future addGeoJsonSource( + String sourceId, Map source) async { + _map.addSource(sourceId, source); + } + + Future addCircleLayer( + String sourceId, String layerId, Map properties) async { + return _addLayer(sourceId, layerId, properties, "circle"); + } + + Future addFillLayer( + String sourceId, String layerId, Map properties) async { + return _addLayer(sourceId, layerId, properties, "fill"); + } + + Future addLineLayer( + String sourceId, String layerId, Map properties) async { + return _addLayer(sourceId, layerId, properties, "line"); + } + + Future addSymbolLayer( + String sourceId, String layerId, Map properties) async { + return _addLayer(sourceId, layerId, properties, "symbol"); + } + + Future _addLayer(String sourceId, String layerId, + Map properties, String layerType) async { + final layout = Map.fromEntries( + properties.entries.where((entry) => isLayoutProperty(entry.value))); + final paint = Map.fromEntries( + properties.entries.where((entry) => isLayoutProperty(entry.value))); + + _map.addLayer({ + 'id': layerId, + 'type': layerType, + 'source': sourceId, + 'layout': layout, + 'paint': paint + }); + } } diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index 1e59b4826..d3e8e5df9 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -10,19 +10,26 @@ main() async { '/Users/ocell/code/flutter-mapbox-gl/scripts/input/style.json') .readAsString()); + final layerTypes = ["symbol", "circle", "line", "fill"]; + final renderContext = { "layerTypes": [ - for (var type in ["symbol", "circle", "line", "fill"]) + for (var type in layerTypes) { "type": type, "typePascal": ReCase(type).pascalCase, - "properties": buildStyleProperties(styleJson, "layout_$type") + - buildStyleProperties(styleJson, "paint_$type") + "paint_properties": buildStyleProperties(styleJson, "paint_$type"), + "layout_properties": buildStyleProperties(styleJson, "layout_$type") }, ], 'expressions': buildExpressionProperties(styleJson) }; + renderContext["all_layout_properties"] = [ + for (final type in renderContext["layerTypes"]!) + ...type["layout_properties"].map((p) => p["value"]).toList() + ].toSet().map((p) => {"property": p}).toList(); + print("generating java"); await renderLayerPropertyConverter( renderContext, @@ -38,6 +45,7 @@ main() async { print("generating dart"); await renderDart(renderContext); + await renderWebDart(renderContext); } Future renderLayerPropertyConverter(Map renderContext, @@ -65,6 +73,18 @@ Future renderDart( outputFile.writeAsString(template.renderString(renderContext)); } +Future renderWebDart( + Map renderContext, +) async { + var templateFile = await File('./scripts/templates/layer_tools.dart.template') + .readAsString(); + + var template = Template(templateFile); + var outputFile = File("./mapbox_gl_web/lib/src/layer_tools.dart"); + + outputFile.writeAsString(template.renderString(renderContext)); +} + List> buildStyleProperties( Map styleJson, String key) { final Map items = styleJson[key]; @@ -73,7 +93,7 @@ List> buildStyleProperties( .map((e) => { 'value': e.key, 'doc': e.value["doc"], - 'docSplit': chunkSubstr(e.value["doc"], 70) + 'docSplit': buildDocLines(e.value["doc"], 70) .map((s) => {"part": s}) .toList(), 'valueAsCamelCase': new ReCase(e.key).camelCase @@ -81,16 +101,16 @@ List> buildStyleProperties( .toList(); } -List chunkSubstr(String input, int size) { +List buildDocLines(String input, int lineLength) { final words = input.split(" "); final chunks = []; String chunk = ""; for (var word in words) { - final nextChunk = chunk.length > 0 ? chunk + " " + word : word; - if (nextChunk.length > size) { - chunks.add(chunk); - chunk = word; + final nextChunk = chunk + " " + word; + if (nextChunk.length > lineLength || chunk.endsWith("\n")) { + chunks.add(chunk.replaceAll("\n", "")); + chunk = " " + word; } else { chunk = nextChunk; } @@ -100,7 +120,7 @@ List chunkSubstr(String input, int size) { return chunks; } -List> buildExpressionProperties( +List> buildExpressionProperties( Map styleJson) { final Map items = styleJson["expression_name"]["values"]; @@ -124,10 +144,14 @@ List> buildExpressionProperties( "!": "not", }; - return items.keys - .map((f) => { - 'value': f, - 'valueAsCamelCase': new ReCase(renamed[f] ?? f).camelCase + return items.entries + .map((e) => { + 'value': e.key, + 'doc': e.value["doc"], + 'docSplit': buildDocLines(e.value["doc"], 70) + .map((s) => {"part": s}) + .toList(), + 'valueAsCamelCase': new ReCase(renamed[e.key] ?? e.key).camelCase }) .toList(); } diff --git a/scripts/templates/LayerPropertyConverter.java.template b/scripts/templates/LayerPropertyConverter.java.template index 9f623e95b..f26c2009f 100644 --- a/scripts/templates/LayerPropertyConverter.java.template +++ b/scripts/templates/LayerPropertyConverter.java.template @@ -22,11 +22,16 @@ class LayerPropertyConverter { for (Map.Entry entry : data.entrySet()) { Expression expression = Expression.Converter.convert(entry.getValue()); switch (entry.getKey()) { - {{#properties}} + {{#paint_properties}} case "{{value}}": properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); break; - {{/properties}} + {{/paint_properties}} + {{#layout_properties}} + case "{{value}}": + properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); + break; + {{/layout_properties}} default: break; } diff --git a/scripts/templates/LayerPropertyConverter.swift.template b/scripts/templates/LayerPropertyConverter.swift.template index 87201943c..f0bf091d5 100644 --- a/scripts/templates/LayerPropertyConverter.swift.template +++ b/scripts/templates/LayerPropertyConverter.swift.template @@ -10,13 +10,17 @@ class LayerPropertyConverter { for (propertyName, propertyValue) in properties { let expression = interpretExpression(expression: propertyValue) switch propertyName { - {{#properties}} + {{#paint_properties}} case "{{{value}}}": lineLayer.{{valueAsCamelCase}} = expression; break; - {{/properties}} - case "line-blur": - lineLayer.lineBlur = expression + {{/paint_properties}} + {{#layout_properties}} + case "{{{value}}}": + lineLayer.{{valueAsCamelCase}} = expression; + break; + {{/layout_properties}} + default: break } diff --git a/scripts/templates/layer_helper.dart.template b/scripts/templates/layer_helper.dart.template index a7b262aab..145eecb73 100644 --- a/scripts/templates/layer_helper.dart.template +++ b/scripts/templates/layer_helper.dart.template @@ -6,19 +6,35 @@ part of mapbox_gl; class {{typePascal}}Properties{ - {{#properties}} + // Paint Properties + {{#paint_properties}} {{#docSplit}} /// {{{part}}} {{/docSplit}} static const {{valueAsCamelCase}} = "{{{value}}}"; - {{/properties}} + {{/paint_properties}} + + // Layout Properties + {{#layout_properties}} + {{#docSplit}} + /// {{{part}}} + {{/docSplit}} + static const {{valueAsCamelCase}} = "{{{value}}}"; + + {{/layout_properties}} } {{/layerTypes}} + + class Expressions{ {{#expressions}} + {{#docSplit}} + ///{{{part}}} + {{/docSplit}} static const {{valueAsCamelCase}} = "{{{value}}}"; + {{/expressions}} } diff --git a/scripts/templates/layer_tools.dart.template b/scripts/templates/layer_tools.dart.template new file mode 100644 index 000000000..b5e28b1ab --- /dev/null +++ b/scripts/templates/layer_tools.dart.template @@ -0,0 +1,12 @@ +// This file is generated by +// ./scripts/lib/generate.dart + +const _layoutProperties = { +{{#all_layout_properties}} + "{{{property}}}", +{{/all_layout_properties}} +}; + +bool isLayoutProperty(String property){ + return _layoutProperties.contains(property); +} \ No newline at end of file From 8f29a8ab367d1ddb79fbb66c08503c486832ec05 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Fri, 22 Oct 2021 19:19:26 +0200 Subject: [PATCH 11/33] working android implementation --- .../mapboxgl/LayerPropertyConverter.java | 35 +++-- .../mapbox/mapboxgl/MapboxMapController.java | 19 ++- example/lib/layer.dart | 143 +++++++++++++++--- example/lib/main.dart | 3 +- ios/Classes/MapboxMapController.swift | 2 +- lib/src/controller.dart | 4 - .../lib/src/mapbox_gl_platform_interface.dart | 5 - .../lib/src/method_channel_mapbox_gl.dart | 6 +- .../lib/src/mapbox_map_controller.dart | 4 - scripts/lib/generate.dart | 33 ++-- .../LayerPropertyConverter.java.template | 25 ++- 11 files changed, 209 insertions(+), 70 deletions(-) diff --git a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java index abf409362..bc03c5c00 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java +++ b/android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java @@ -11,15 +11,22 @@ import java.util.List; import java.util.Map; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; + + import static com.mapbox.mapboxgl.Convert.toMap; class LayerPropertyConverter { static PropertyValue[] interpretSymbolLayerProperties(Object o) { final Map data = (Map) toMap(o); final List properties = new LinkedList(); + final JsonParser parser = new JsonParser(); for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); + final JsonElement jsonElement = parser.parse(entry.getValue()); + Expression expression = Expression.Converter.convert(jsonElement); switch (entry.getKey()) { case "icon-opacity": properties.add(PropertyFactory.iconOpacity(expression)); @@ -100,7 +107,11 @@ static PropertyValue[] interpretSymbolLayerProperties(Object o) { properties.add(PropertyFactory.iconTextFitPadding(expression)); break; case "icon-image": - properties.add(PropertyFactory.iconImage(expression)); + if(jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isString()){ + properties.add(PropertyFactory.iconImage(jsonElement.getAsString())); + }else{ + properties.add(PropertyFactory.iconImage(expression)); + } break; case "icon-rotate": properties.add(PropertyFactory.iconRotate(expression)); @@ -187,7 +198,7 @@ static PropertyValue[] interpretSymbolLayerProperties(Object o) { properties.add(PropertyFactory.textOptional(expression)); break; case "visibility": - properties.add(PropertyFactory.visibility(expression)); + properties.add(PropertyFactory.visibility(entry.getValue())); break; default: break; @@ -200,9 +211,11 @@ static PropertyValue[] interpretSymbolLayerProperties(Object o) { static PropertyValue[] interpretCircleLayerProperties(Object o) { final Map data = (Map) toMap(o); final List properties = new LinkedList(); + final JsonParser parser = new JsonParser(); for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); + final JsonElement jsonElement = parser.parse(entry.getValue()); + Expression expression = Expression.Converter.convert(jsonElement); switch (entry.getKey()) { case "circle-radius": properties.add(PropertyFactory.circleRadius(expression)); @@ -241,7 +254,7 @@ static PropertyValue[] interpretCircleLayerProperties(Object o) { properties.add(PropertyFactory.circleSortKey(expression)); break; case "visibility": - properties.add(PropertyFactory.visibility(expression)); + properties.add(PropertyFactory.visibility(entry.getValue())); break; default: break; @@ -254,9 +267,11 @@ static PropertyValue[] interpretCircleLayerProperties(Object o) { static PropertyValue[] interpretLineLayerProperties(Object o) { final Map data = (Map) toMap(o); final List properties = new LinkedList(); + final JsonParser parser = new JsonParser(); for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); + final JsonElement jsonElement = parser.parse(entry.getValue()); + Expression expression = Expression.Converter.convert(jsonElement); switch (entry.getKey()) { case "line-opacity": properties.add(PropertyFactory.lineOpacity(expression)); @@ -307,7 +322,7 @@ static PropertyValue[] interpretLineLayerProperties(Object o) { properties.add(PropertyFactory.lineSortKey(expression)); break; case "visibility": - properties.add(PropertyFactory.visibility(expression)); + properties.add(PropertyFactory.visibility(entry.getValue())); break; default: break; @@ -320,9 +335,11 @@ static PropertyValue[] interpretLineLayerProperties(Object o) { static PropertyValue[] interpretFillLayerProperties(Object o) { final Map data = (Map) toMap(o); final List properties = new LinkedList(); + final JsonParser parser = new JsonParser(); for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); + final JsonElement jsonElement = parser.parse(entry.getValue()); + Expression expression = Expression.Converter.convert(jsonElement); switch (entry.getKey()) { case "fill-antialias": properties.add(PropertyFactory.fillAntialias(expression)); @@ -349,7 +366,7 @@ static PropertyValue[] interpretFillLayerProperties(Object o) { properties.add(PropertyFactory.fillSortKey(expression)); break; case "visibility": - properties.add(PropertyFactory.visibility(expression)); + properties.add(PropertyFactory.visibility(entry.getValue())); break; default: break; diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index 384943909..9dfc74057 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -73,10 +73,12 @@ import com.mapbox.mapboxsdk.style.layers.RasterLayer; import com.mapbox.mapboxsdk.style.sources.ImageSource; import com.mapbox.mapboxsdk.style.layers.LineLayer; +import com.mapbox.mapboxsdk.style.layers.CircleLayer; +import com.mapbox.mapboxsdk.style.layers.FillLayer; +import com.mapbox.mapboxsdk.style.layers.SymbolLayer; import com.mapbox.mapboxsdk.style.layers.Property; import com.mapbox.mapboxsdk.style.layers.PropertyFactory; import com.mapbox.mapboxsdk.style.layers.PropertyValue; -import com.mapbox.mapboxsdk.style.layers.SymbolLayer; import com.mapbox.mapboxsdk.style.sources.GeoJsonSource; import io.flutter.plugin.common.MethodCall; @@ -387,8 +389,8 @@ private void onUserLocationUpdate(Location location){ methodChannel.invokeMethod("map#onUserLocationUpdated", arguments); } - private void addSource(String sourceName, String geojson) { - FeatureCollection featureCollection = FeatureCollection.fromJson(geojson); + private void addGeoJsonSource(String sourceName, String source) { + FeatureCollection featureCollection = FeatureCollection.fromJson(source); GeoJsonSource geoJsonSource = new GeoJsonSource(sourceName, featureCollection); style.addSource(geoJsonSource); @@ -420,7 +422,7 @@ private void addFillLayer(String layerName, String sourceName, PropertyValue[] properties, Expression filter) { - LineLayer fillLayer = new FillLayer(layerName, sourceName); + FillLayer fillLayer = new FillLayer(layerName, sourceName); fillLayer.setProperties(properties); @@ -431,7 +433,7 @@ private void addCircleLayer(String layerName, String sourceName, PropertyValue[] properties, Expression filter) { - LineLayer circleLayer = new CircleLayer(layerName, sourceName); + CircleLayer circleLayer = new CircleLayer(layerName, sourceName); circleLayer.setProperties(properties); @@ -962,16 +964,17 @@ public void onError(@NonNull String message) { break; } case "fill#update": { - Log.e(TAG, "update fill"); final String fillId = call.argument("fill"); final FillController fill = fill(fillId); Convert.interpretFillOptions(call.argument("options"), fill); fill.update(fillManager); result.success(null); - case "source#add": { + break; + } + case "source#addGeoJson": { final String sourceId = call.argument("sourceId"); final String geojson = call.argument("geojson"); - addSource(sourceId, geojson); + addGeoJsonSource(sourceId, geojson); break; } case "symbolLayer#add": { diff --git a/example/lib/layer.dart b/example/lib/layer.dart index c2083dd23..89077d8f9 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -17,22 +17,6 @@ class LayerBody extends StatefulWidget { class LayerState extends State { static final LatLng center = const LatLng(-33.86711, 151.1947171); - static final Map geojsonLines = { - "type": "FeatureCollection", - "features": [ - { - "type": "Feature", - "properties": {}, - "geometry": { - "type": "LineString", - "coordinates": [ - [151.19213104248047, -33.87112820031405], - [151.4770858764648, -33.853737857223145] - ] - } - } - ] - }; late MapboxMapController controller; @@ -65,17 +49,134 @@ class LayerState extends State { } void _onStyleLoadedCallback() { - controller.addGeoJsonSource("lines", geojsonLines); - controller.addLineLayer("lines", "layer_1", { + controller.addGeoJsonSource("fills", _fills); + controller.addGeoJsonSource("points", _points); + + controller.addFillLayer("fills", "fills", { + FillProperties.fillColor: [ + 'interpolate', + ['exponential', 0.5], + ['zoom'], + 11, + 'red', + 18, + 'green' + ], + FillProperties.fillOpacity: 0.4 + }); + + controller.addLineLayer("fills", "lines", { LineProperties.lineWidth: [ Expressions.interpolate, ["linear"], [Expressions.zoom], - 15.0, - 1.0, - 23.0, + 11.0, + 2.0, + 20.0, 10.0 ] }); + + controller.addCircleLayer("fills", "circles", { + CircleProperties.circleRadius: 4.0, + CircleProperties.circleColor: "#ff0000" + }); + + controller.addSymbolLayer("points", "symbols", { + SymbolProperties.iconImage: "{type}-15", + SymbolProperties.iconSize: 2, + }); } } + +const _fills = { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [151.178099204457737, -33.901517742631846], + [151.179025547977773, -33.872845324482071], + [151.147000529140399, -33.868230472039514], + [151.150838238009328, -33.883172899638311], + [151.14223647675135, -33.894158309528244], + [151.155999294764086, -33.904812805307806], + [151.178099204457737, -33.901517742631846] + ], + [ + [151.162657925954278, -33.879168932438581], + [151.155323416087612, -33.890737666431583], + [151.173659690754278, -33.897637567778119], + [151.162657925954278, -33.879168932438581] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [151.18735077583878, -33.891143558434102], + [151.197374605989864, -33.878357032551868], + [151.213021560372084, -33.886475683791488], + [151.204953599518745, -33.899463918807818], + [151.18735077583878, -33.891143558434102] + ] + ] + } + } + ] +}; + +final _points = { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "type": "restaurant", + }, + "geometry": { + "type": "Point", + "coordinates": [151.184913929732943, -33.874874486427181] + } + }, + { + "type": "Feature", + "properties": { + "type": "airport", + }, + "geometry": { + "type": "Point", + "coordinates": [151.215730044667879, -33.874616048776858] + } + }, + { + "type": "Feature", + "properties": { + "type": "bakery", + }, + "geometry": { + "type": "Point", + "coordinates": [151.228803547973598, -33.892188026142584] + } + }, + { + "type": "Feature", + "properties": { + "type": "college", + }, + "geometry": { + "type": "Point", + "coordinates": [151.186470299174118, -33.902781145804774] + } + } + ] +}; diff --git a/example/lib/main.dart b/example/lib/main.dart index 7cfeb7b20..3983e85d7 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -46,7 +46,8 @@ final List _allPages = [ class MapsDemo extends StatelessWidget { //FIXME: Add your Mapbox access token here - static const String ACCESS_TOKEN = "pk.eyJ1Ijoib3V0d2F5LWFkbWluIiwiYSI6ImNrMnRxYnQ3bzFlNTEzbXVpNXIxZG00dG0ifQ.jt1gMJMirDNJneqN3G1O8w"; + static const String ACCESS_TOKEN = + "pk.eyJ1Ijoib2NlbGwiLCJhIjoiY2pvdTE5bnhoMTc1cDNrcWlha2todGFkYiJ9.hW9Q853ix58dukevFHX1pw"; void _pushPage(BuildContext context, ExamplePage page) async { if (!kIsWeb) { diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index c41b76158..150378e04 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -712,7 +712,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma guard let imageLayerId = arguments["imageLayerId"] as? String else { return } guard let layer = self.mapView.style?.layer(withIdentifier: imageLayerId) else { return } self.mapView.style?.removeLayer(layer) - case "source#add": + case "source#addGeoJson": guard let arguments = methodCall.arguments as? [String: Any] else { return } guard let sourceId = arguments["sourceId"] as? String else { return } guard let geojson = arguments["geojson"] as? String else { return } diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 0dc2cc88b..8b945eaa4 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -259,10 +259,6 @@ class MapboxMapController extends ChangeNotifier { return _mapboxGlPlatform.moveCamera(cameraUpdate); } - Future addSource(String sourceId, String source) async { - await MapboxGlPlatform.getInstance(_id).addSource(sourceId, source); - } - Future addGeoJsonSource( String sourceId, Map source) async { await MapboxGlPlatform.getInstance(_id).addGeoJsonSource(sourceId, source); diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index 220ab0a49..b6705c31d 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -279,11 +279,6 @@ abstract class MapboxGlPlatform { 'getMetersPerPixelAtLatitude() has not been implemented.'); } - Future addSource(String sourceId, String source) async { - throw UnimplementedError( - 'setSymbolTextIgnorePlacement() has not been implemented.'); - } - Future addGeoJsonSource( String sourceId, Map source) async { throw UnimplementedError( diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index 7357e4e51..0f0771d51 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -730,10 +730,10 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { @override Future addGeoJsonSource( - String sourceId, Map source) async { - await _channel.invokeMethod('source#add', { + String sourceId, Map geojson) async { + await _channel.invokeMethod('source#addGeoJson', { 'sourceId': sourceId, - 'geojson': jsonEncode(source), + 'geojson': jsonEncode(geojson), }); } diff --git a/mapbox_gl_web/lib/src/mapbox_map_controller.dart b/mapbox_gl_web/lib/src/mapbox_map_controller.dart index 0a66ff753..e4eb21667 100644 --- a/mapbox_gl_web/lib/src/mapbox_map_controller.dart +++ b/mapbox_gl_web/lib/src/mapbox_map_controller.dart @@ -767,10 +767,6 @@ class MapboxMapController extends MapboxGlPlatform return circumference * cos(latitude * (pi / 180)) / pow(2, zoom + 9); } - Future addSource(String sourceId, String source) async { - _map.addSource(sourceId, source); - } - Future addGeoJsonSource( String sourceId, Map source) async { _map.addSource(sourceId, source); diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index d3e8e5df9..9de0e4f6e 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -19,7 +19,7 @@ main() async { "type": type, "typePascal": ReCase(type).pascalCase, "paint_properties": buildStyleProperties(styleJson, "paint_$type"), - "layout_properties": buildStyleProperties(styleJson, "layout_$type") + "layout_properties": buildStyleProperties(styleJson, "layout_$type"), }, ], 'expressions': buildExpressionProperties(styleJson) @@ -48,8 +48,11 @@ main() async { await renderWebDart(renderContext); } -Future renderLayerPropertyConverter(Map renderContext, - String templateType, String outputPath) async { +Future renderLayerPropertyConverter( + Map renderContext, + String templateType, + String outputPath, +) async { var templateFile = await File( './scripts/templates/LayerPropertyConverter.$templateType.template') .readAsString(); @@ -89,16 +92,20 @@ List> buildStyleProperties( Map styleJson, String key) { final Map items = styleJson[key]; - return items.entries - .map((e) => { - 'value': e.key, - 'doc': e.value["doc"], - 'docSplit': buildDocLines(e.value["doc"], 70) - .map((s) => {"part": s}) - .toList(), - 'valueAsCamelCase': new ReCase(e.key).camelCase - }) - .toList(); + return items.entries.map((e) => buildStyleProperty(e.key, e.value)).toList(); +} + +Map buildStyleProperty( + String key, Map value) { + return { + 'value': key, + 'isStringProperty': key == "visibility", + 'requiresLiteral': key == "icon-image", + 'doc': value["doc"], + 'docSplit': + buildDocLines(value["doc"], 70).map((s) => {"part": s}).toList(), + 'valueAsCamelCase': new ReCase(key).camelCase + }; } List buildDocLines(String input, int lineLength) { diff --git a/scripts/templates/LayerPropertyConverter.java.template b/scripts/templates/LayerPropertyConverter.java.template index f26c2009f..f88ee8c94 100644 --- a/scripts/templates/LayerPropertyConverter.java.template +++ b/scripts/templates/LayerPropertyConverter.java.template @@ -11,6 +11,11 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; + + import static com.mapbox.mapboxgl.Convert.toMap; class LayerPropertyConverter { @@ -18,9 +23,11 @@ class LayerPropertyConverter { static PropertyValue[] interpret{{typePascal}}LayerProperties(Object o) { final Map data = (Map) toMap(o); final List properties = new LinkedList(); + final JsonParser parser = new JsonParser(); for (Map.Entry entry : data.entrySet()) { - Expression expression = Expression.Converter.convert(entry.getValue()); + final JsonElement jsonElement = parser.parse(entry.getValue()); + Expression expression = Expression.Converter.convert(jsonElement); switch (entry.getKey()) { {{#paint_properties}} case "{{value}}": @@ -28,8 +35,24 @@ class LayerPropertyConverter { break; {{/paint_properties}} {{#layout_properties}} + {{^isStringProperty}} + {{^requiresLiteral}} case "{{value}}": properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); + {{/requiresLiteral}} + {{/isStringProperty}} + {{#requiresLiteral}} + case "{{value}}": + if(jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isString()){ + properties.add(PropertyFactory.iconImage(jsonElement.getAsString())); + }else{ + properties.add(PropertyFactory.iconImage(expression)); + } + {{/requiresLiteral}} + {{#isStringProperty}} + case "{{value}}": + properties.add(PropertyFactory.{{valueAsCamelCase}}(entry.getValue())); + {{/isStringProperty}} break; {{/layout_properties}} default: From 196ca0eb828fcebf8f2fb4f43349757b251662fb Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Fri, 22 Oct 2021 19:45:13 +0200 Subject: [PATCH 12/33] working web version --- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 6 +++--- example/lib/layer.dart | 3 ++- lib/src/controller.dart | 4 ++-- .../lib/src/mapbox_gl_platform_interface.dart | 2 +- mapbox_gl_web/lib/mapbox_gl_web.dart | 1 + mapbox_gl_web/lib/src/mapbox_map_controller.dart | 8 ++++---- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9367d483e..8d4492f97 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 2c4ace91c..dc6827f25 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -363,7 +363,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -442,7 +442,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -491,7 +491,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 89077d8f9..1eb1dfbfb 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -85,11 +85,12 @@ class LayerState extends State { controller.addSymbolLayer("points", "symbols", { SymbolProperties.iconImage: "{type}-15", SymbolProperties.iconSize: 2, + SymbolProperties.iconAllowOverlap: true }); } } -const _fills = { +final _fills = { "type": "FeatureCollection", "features": [ { diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 8b945eaa4..6ee6b8f61 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -260,8 +260,8 @@ class MapboxMapController extends ChangeNotifier { } Future addGeoJsonSource( - String sourceId, Map source) async { - await MapboxGlPlatform.getInstance(_id).addGeoJsonSource(sourceId, source); + String sourceId, Map geojson) async { + await MapboxGlPlatform.getInstance(_id).addGeoJsonSource(sourceId, geojson); } Future addSymbolLayer( diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index b6705c31d..adba5a4b4 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -280,7 +280,7 @@ abstract class MapboxGlPlatform { } Future addGeoJsonSource( - String sourceId, Map source) async { + String sourceId, Map geojson) async { throw UnimplementedError( 'setSymbolTextIgnorePlacement() has not been implemented.'); } diff --git a/mapbox_gl_web/lib/mapbox_gl_web.dart b/mapbox_gl_web/lib/mapbox_gl_web.dart index 8aada7d83..d4c81a458 100644 --- a/mapbox_gl_web/lib/mapbox_gl_web.dart +++ b/mapbox_gl_web/lib/mapbox_gl_web.dart @@ -1,6 +1,7 @@ library mapbox_gl_web; import 'dart:async'; +import 'dart:convert'; // FIXED HERE: https://github.com/dart-lang/linter/pull/1985 // ignore_for_file: avoid_web_libraries_in_flutter import 'dart:html'; diff --git a/mapbox_gl_web/lib/src/mapbox_map_controller.dart b/mapbox_gl_web/lib/src/mapbox_map_controller.dart index e4eb21667..86356027c 100644 --- a/mapbox_gl_web/lib/src/mapbox_map_controller.dart +++ b/mapbox_gl_web/lib/src/mapbox_map_controller.dart @@ -768,8 +768,8 @@ class MapboxMapController extends MapboxGlPlatform } Future addGeoJsonSource( - String sourceId, Map source) async { - _map.addSource(sourceId, source); + String sourceId, Map geojson) async { + _map.addSource(sourceId, {"type": 'geojson', "data": geojson}); } Future addCircleLayer( @@ -795,9 +795,9 @@ class MapboxMapController extends MapboxGlPlatform Future _addLayer(String sourceId, String layerId, Map properties, String layerType) async { final layout = Map.fromEntries( - properties.entries.where((entry) => isLayoutProperty(entry.value))); + properties.entries.where((entry) => isLayoutProperty(entry.key))); final paint = Map.fromEntries( - properties.entries.where((entry) => isLayoutProperty(entry.value))); + properties.entries.where((entry) => !isLayoutProperty(entry.key))); _map.addLayer({ 'id': layerId, From 982f62c75406586bbb6d5cbe8255e9231cbbee7d Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Fri, 22 Oct 2021 22:05:39 +0200 Subject: [PATCH 13/33] basic working ios version --- example/lib/layer.dart | 10 +- ios/Classes/LayerPropertyConverter.swift | 164 +++++++++--------- ios/Classes/MapboxMapController.swift | 36 ++-- scripts/lib/generate.dart | 42 ++++- .../LayerPropertyConverter.java.template | 8 +- .../LayerPropertyConverter.swift.template | 19 +- 6 files changed, 176 insertions(+), 103 deletions(-) diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 1eb1dfbfb..960735d03 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -62,7 +62,15 @@ class LayerState extends State { 18, 'green' ], - FillProperties.fillOpacity: 0.4 + FillProperties.fillOpacity: [ + 'interpolate', + ['exponential', 0.5], + ['zoom'], + 11, + 0.5, + 18, + 0.5 + ], }); controller.addLineLayer("fills", "lines", { diff --git a/ios/Classes/LayerPropertyConverter.swift b/ios/Classes/LayerPropertyConverter.swift index 17a5ceae4..c0bcf222e 100644 --- a/ios/Classes/LayerPropertyConverter.swift +++ b/ios/Classes/LayerPropertyConverter.swift @@ -10,172 +10,172 @@ class LayerPropertyConverter { let expression = interpretExpression(expression: propertyValue) switch propertyName { case "icon-opacity": - lineLayer.iconOpacity = expression; + symbolLayer.iconOpacity = expression; break; case "icon-color": - lineLayer.iconColor = expression; + symbolLayer.iconColor = expression; break; case "icon-halo-color": - lineLayer.iconHaloColor = expression; + symbolLayer.iconHaloColor = expression; break; case "icon-halo-width": - lineLayer.iconHaloWidth = expression; + symbolLayer.iconHaloWidth = expression; break; case "icon-halo-blur": - lineLayer.iconHaloBlur = expression; + symbolLayer.iconHaloBlur = expression; break; case "icon-translate": - lineLayer.iconTranslate = expression; + symbolLayer.iconTranslation = expression; break; case "icon-translate-anchor": - lineLayer.iconTranslateAnchor = expression; + symbolLayer.iconTranslationAnchor = expression; break; case "text-opacity": - lineLayer.textOpacity = expression; + symbolLayer.textOpacity = expression; break; case "text-color": - lineLayer.textColor = expression; + symbolLayer.textColor = expression; break; case "text-halo-color": - lineLayer.textHaloColor = expression; + symbolLayer.textHaloColor = expression; break; case "text-halo-width": - lineLayer.textHaloWidth = expression; + symbolLayer.textHaloWidth = expression; break; case "text-halo-blur": - lineLayer.textHaloBlur = expression; + symbolLayer.textHaloBlur = expression; break; case "text-translate": - lineLayer.textTranslate = expression; + symbolLayer.textTranslation = expression; break; case "text-translate-anchor": - lineLayer.textTranslateAnchor = expression; + symbolLayer.textTranslationAnchor = expression; break; case "symbol-placement": - lineLayer.symbolPlacement = expression; + symbolLayer.symbolPlacement = expression; break; case "symbol-spacing": - lineLayer.symbolSpacing = expression; + symbolLayer.symbolSpacing = expression; break; case "symbol-avoid-edges": - lineLayer.symbolAvoidEdges = expression; + symbolLayer.symbolAvoidsEdges = expression; break; case "symbol-sort-key": - lineLayer.symbolSortKey = expression; + symbolLayer.symbolSortKey = expression; break; case "symbol-z-order": - lineLayer.symbolZOrder = expression; + symbolLayer.symbolZOrder = expression; break; case "icon-allow-overlap": - lineLayer.iconAllowOverlap = expression; + symbolLayer.iconAllowsOverlap = expression; break; case "icon-ignore-placement": - lineLayer.iconIgnorePlacement = expression; + symbolLayer.iconIgnoresPlacement = expression; break; case "icon-optional": - lineLayer.iconOptional = expression; + symbolLayer.iconOptional = expression; break; case "icon-rotation-alignment": - lineLayer.iconRotationAlignment = expression; + symbolLayer.iconRotationAlignment = expression; break; case "icon-size": - lineLayer.iconSize = expression; + symbolLayer.iconScale = expression; break; case "icon-text-fit": - lineLayer.iconTextFit = expression; + symbolLayer.iconTextFit = expression; break; case "icon-text-fit-padding": - lineLayer.iconTextFitPadding = expression; + symbolLayer.iconTextFitPadding = expression; break; case "icon-image": - lineLayer.iconImage = expression; + symbolLayer.iconImageName = expression; break; case "icon-rotate": - lineLayer.iconRotate = expression; + symbolLayer.iconRotation = expression; break; case "icon-padding": - lineLayer.iconPadding = expression; + symbolLayer.iconPadding = expression; break; case "icon-keep-upright": - lineLayer.iconKeepUpright = expression; + symbolLayer.keepsIconUpright = expression; break; case "icon-offset": - lineLayer.iconOffset = expression; + symbolLayer.iconOffset = expression; break; case "icon-anchor": - lineLayer.iconAnchor = expression; + symbolLayer.iconAnchor = expression; break; case "icon-pitch-alignment": - lineLayer.iconPitchAlignment = expression; + symbolLayer.iconPitchAlignment = expression; break; case "text-pitch-alignment": - lineLayer.textPitchAlignment = expression; + symbolLayer.textPitchAlignment = expression; break; case "text-rotation-alignment": - lineLayer.textRotationAlignment = expression; + symbolLayer.textRotationAlignment = expression; break; case "text-field": - lineLayer.textField = expression; + symbolLayer.text = expression; break; case "text-font": - lineLayer.textFont = expression; + symbolLayer.textFontNames = expression; break; case "text-size": - lineLayer.textSize = expression; + symbolLayer.textFontSize = expression; break; case "text-max-width": - lineLayer.textMaxWidth = expression; + symbolLayer.maximumTextWidth = expression; break; case "text-line-height": - lineLayer.textLineHeight = expression; + symbolLayer.textLineHeight = expression; break; case "text-letter-spacing": - lineLayer.textLetterSpacing = expression; + symbolLayer.textLetterSpacing = expression; break; case "text-justify": - lineLayer.textJustify = expression; + symbolLayer.textJustification = expression; break; case "text-radial-offset": - lineLayer.textRadialOffset = expression; + symbolLayer.textRadialOffset = expression; break; case "text-variable-anchor": - lineLayer.textVariableAnchor = expression; + symbolLayer.textVariableAnchor = expression; break; case "text-anchor": - lineLayer.textAnchor = expression; + symbolLayer.textAnchor = expression; break; case "text-max-angle": - lineLayer.textMaxAngle = expression; + symbolLayer.maximumTextAngle = expression; break; case "text-writing-mode": - lineLayer.textWritingMode = expression; + symbolLayer.textWritingModes = expression; break; case "text-rotate": - lineLayer.textRotate = expression; + symbolLayer.textRotation = expression; break; case "text-padding": - lineLayer.textPadding = expression; + symbolLayer.textPadding = expression; break; case "text-keep-upright": - lineLayer.textKeepUpright = expression; + symbolLayer.keepsTextUpright = expression; break; case "text-transform": - lineLayer.textTransform = expression; + symbolLayer.textTransform = expression; break; case "text-offset": - lineLayer.textOffset = expression; + symbolLayer.textOffset = expression; break; case "text-allow-overlap": - lineLayer.textAllowOverlap = expression; + symbolLayer.textAllowsOverlap = expression; break; case "text-ignore-placement": - lineLayer.textIgnorePlacement = expression; + symbolLayer.textIgnoresPlacement = expression; break; case "text-optional": - lineLayer.textOptional = expression; + symbolLayer.textOptional = expression; break; case "visibility": - lineLayer.visibility = expression; + symbolLayer.isVisible = propertyValue == "visible"; break; default: @@ -189,43 +189,43 @@ class LayerPropertyConverter { let expression = interpretExpression(expression: propertyValue) switch propertyName { case "circle-radius": - lineLayer.circleRadius = expression; + circleLayer.circleRadius = expression; break; case "circle-color": - lineLayer.circleColor = expression; + circleLayer.circleColor = expression; break; case "circle-blur": - lineLayer.circleBlur = expression; + circleLayer.circleBlur = expression; break; case "circle-opacity": - lineLayer.circleOpacity = expression; + circleLayer.circleOpacity = expression; break; case "circle-translate": - lineLayer.circleTranslate = expression; + circleLayer.circleTranslation = expression; break; case "circle-translate-anchor": - lineLayer.circleTranslateAnchor = expression; + circleLayer.circleTranslationAnchor = expression; break; case "circle-pitch-scale": - lineLayer.circlePitchScale = expression; + circleLayer.circleScaleAlignment = expression; break; case "circle-pitch-alignment": - lineLayer.circlePitchAlignment = expression; + circleLayer.circlePitchAlignment = expression; break; case "circle-stroke-width": - lineLayer.circleStrokeWidth = expression; + circleLayer.circleStrokeWidth = expression; break; case "circle-stroke-color": - lineLayer.circleStrokeColor = expression; + circleLayer.circleStrokeColor = expression; break; case "circle-stroke-opacity": - lineLayer.circleStrokeOpacity = expression; + circleLayer.circleStrokeOpacity = expression; break; case "circle-sort-key": - lineLayer.circleSortKey = expression; + circleLayer.circleSortKey = expression; break; case "visibility": - lineLayer.visibility = expression; + circleLayer.isVisible = propertyValue == "visible"; break; default: @@ -245,10 +245,10 @@ class LayerPropertyConverter { lineLayer.lineColor = expression; break; case "line-translate": - lineLayer.lineTranslate = expression; + lineLayer.lineTranslation = expression; break; case "line-translate-anchor": - lineLayer.lineTranslateAnchor = expression; + lineLayer.lineTranslationAnchor = expression; break; case "line-width": lineLayer.lineWidth = expression; @@ -263,7 +263,7 @@ class LayerPropertyConverter { lineLayer.lineBlur = expression; break; case "line-dasharray": - lineLayer.lineDasharray = expression; + lineLayer.lineDashPattern = expression; break; case "line-pattern": lineLayer.linePattern = expression; @@ -287,7 +287,7 @@ class LayerPropertyConverter { lineLayer.lineSortKey = expression; break; case "visibility": - lineLayer.visibility = expression; + lineLayer.isVisible = propertyValue == "visible"; break; default: @@ -301,31 +301,31 @@ class LayerPropertyConverter { let expression = interpretExpression(expression: propertyValue) switch propertyName { case "fill-antialias": - lineLayer.fillAntialias = expression; + fillLayer.fillAntialiased = expression; break; case "fill-opacity": - lineLayer.fillOpacity = expression; + fillLayer.fillOpacity = expression; break; case "fill-color": - lineLayer.fillColor = expression; + fillLayer.fillColor = expression; break; case "fill-outline-color": - lineLayer.fillOutlineColor = expression; + fillLayer.fillOutlineColor = expression; break; case "fill-translate": - lineLayer.fillTranslate = expression; + fillLayer.fillTranslation = expression; break; case "fill-translate-anchor": - lineLayer.fillTranslateAnchor = expression; + fillLayer.fillTranslationAnchor = expression; break; case "fill-pattern": - lineLayer.fillPattern = expression; + fillLayer.fillPattern = expression; break; case "fill-sort-key": - lineLayer.fillSortKey = expression; + fillLayer.fillSortKey = expression; break; case "visibility": - lineLayer.visibility = expression; + fillLayer.isVisible = propertyValue == "visible"; break; default: diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index 150378e04..021b6b133 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -499,18 +499,39 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma removeAllForController(controller:lineAnnotationController, ids:ids) result(nil) + case "symbolLayer#add": guard let arguments = methodCall.arguments as? [String: Any] else { return } guard let sourceId = arguments["sourceId"] as? String else { return } guard let layerId = arguments["layerId"] as? String else { return } guard let properties = arguments["properties"] as? [String: String] else { return } - addSymbolLayer(sourceId: sourceId, layerId: layerId, properties: properties) + result(nil) + case "lineLayer#add": guard let arguments = methodCall.arguments as? [String: Any] else { return } guard let sourceId = arguments["sourceId"] as? String else { return } guard let layerId = arguments["layerId"] as? String else { return } guard let properties = arguments["properties"] as? [String: String] else { return } + addLineLayer(sourceId: sourceId, layerId: layerId, properties: properties) + result(nil) + + case "fillLayer#add": + guard let arguments = methodCall.arguments as? [String: Any] else { return } + guard let sourceId = arguments["sourceId"] as? String else { return } + guard let layerId = arguments["layerId"] as? String else { return } + guard let properties = arguments["properties"] as? [String: String] else { return } + addFillLayer(sourceId: sourceId, layerId: layerId, properties: properties) + result(nil) + + case "circleLayer#add": + guard let arguments = methodCall.arguments as? [String: Any] else { return } + guard let sourceId = arguments["sourceId"] as? String else { return } + guard let layerId = arguments["layerId"] as? String else { return } + guard let properties = arguments["properties"] as? [String: String] else { return } + addCircleLayer(sourceId: sourceId, layerId: layerId, properties: properties) + result(nil) + case "line#getGeometry": guard let lineAnnotationController = lineAnnotationController else { return } @@ -984,15 +1005,6 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } } - func addSource(sourceId: String, geojson: String) { - do { - let parsed = try MGLShape.init(data: geojson.data(using: .utf8)!, encoding: String.Encoding.utf8.rawValue) - let source = MGLShapeSource(identifier: sourceId, shape: parsed, options: [:]) - mapView.style?.addSource(source) - } catch { - } - } - func addSymbolLayer(sourceId: String, layerId: String, properties: [String: String]) { if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { @@ -1013,7 +1025,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } } - func addLineLayer(sourceId: String, layerId: String, properties: [String: String]) { + func addFillLayer(sourceId: String, layerId: String, properties: [String: String]) { if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { let layer = MGLFillStyleLayer(identifier: layerId, source: source) @@ -1027,7 +1039,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { let layer = MGLCircleStyleLayer(identifier: layerId, source: source) - LayerPropertyConverter.addCircleProperties(cricleLayer: layer, properties: properties) + LayerPropertyConverter.addCircleProperties(circleLayer: layer, properties: properties) style.addLayer(layer) } } diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index 9de0e4f6e..7982e3d98 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -95,16 +95,54 @@ List> buildStyleProperties( return items.entries.map((e) => buildStyleProperty(e.key, e.value)).toList(); } +const renamedIosProperties = { + "iconImage": "iconImageName", + "iconRotate": "iconRotation", + "iconSize": "iconScale", + "iconKeepUpright": "keepsIconUpright", + "iconTranslate": "iconTranslation", + "iconTranslateAnchor": "iconTranslationAnchor", + "iconAllowOverlap": "iconAllowsOverlap", + "iconIgnorePlacement": "iconIgnoresPlacement", + "textTranslate": "textTranslation", + "textTranslateAnchor": "textTranslationAnchor", + "textIgnorePlacement": "textIgnoresPlacement", + "textField": "text", + "textFont": "textFontNames", + "textSize": "textFontSize", + "textMaxWidth": "maximumTextWidth", + "textJustify": "textJustification", + "textMaxAngle": "maximumTextAngle", + "textWritingMode": "textWritingModes", + "textRotate": "textRotation", + "textKeepUpright": "keepsTextUpright", + "textAllowOverlap": "textAllowsOverlap", + "symbolAvoidEdges": "symbolAvoidsEdges", + "circleTranslate": "circleTranslation", + "circleTranslateAnchor": "circleTranslationAnchor", + "circlePitchScale": "circleScaleAlignment", + "lineTranslate": "lineTranslation", + "lineTranslateAnchor": "lineTranslationAnchor", + "lineDasharray": "lineDashPattern", + "fillAntialias": "fillAntialiased", + "fillTranslate": "fillTranslation", + "fillTranslateAnchor": "fillTranslationAnchor", + "visibility": "isVisible", +}; + Map buildStyleProperty( String key, Map value) { + final camelCase = ReCase(key).camelCase; return { 'value': key, - 'isStringProperty': key == "visibility", + 'isVisibilityProperty': key == "visibility", 'requiresLiteral': key == "icon-image", + 'isIosAsCamelCase': renamedIosProperties.containsKey(camelCase), + 'iosAsCamelCase': renamedIosProperties[camelCase], 'doc': value["doc"], 'docSplit': buildDocLines(value["doc"], 70).map((s) => {"part": s}).toList(), - 'valueAsCamelCase': new ReCase(key).camelCase + 'valueAsCamelCase': camelCase }; } diff --git a/scripts/templates/LayerPropertyConverter.java.template b/scripts/templates/LayerPropertyConverter.java.template index f88ee8c94..25c56680e 100644 --- a/scripts/templates/LayerPropertyConverter.java.template +++ b/scripts/templates/LayerPropertyConverter.java.template @@ -35,12 +35,12 @@ class LayerPropertyConverter { break; {{/paint_properties}} {{#layout_properties}} - {{^isStringProperty}} + {{^isVisibilityProperty}} {{^requiresLiteral}} case "{{value}}": properties.add(PropertyFactory.{{valueAsCamelCase}}(expression)); {{/requiresLiteral}} - {{/isStringProperty}} + {{/isVisibilityProperty}} {{#requiresLiteral}} case "{{value}}": if(jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isString()){ @@ -49,10 +49,10 @@ class LayerPropertyConverter { properties.add(PropertyFactory.iconImage(expression)); } {{/requiresLiteral}} - {{#isStringProperty}} + {{#isVisibilityProperty}} case "{{value}}": properties.add(PropertyFactory.{{valueAsCamelCase}}(entry.getValue())); - {{/isStringProperty}} + {{/isVisibilityProperty}} break; {{/layout_properties}} default: diff --git a/scripts/templates/LayerPropertyConverter.swift.template b/scripts/templates/LayerPropertyConverter.swift.template index f0bf091d5..44f81c895 100644 --- a/scripts/templates/LayerPropertyConverter.swift.template +++ b/scripts/templates/LayerPropertyConverter.swift.template @@ -12,12 +12,27 @@ class LayerPropertyConverter { switch propertyName { {{#paint_properties}} case "{{{value}}}": - lineLayer.{{valueAsCamelCase}} = expression; + {{#isIosAsCamelCase}} + {{type}}Layer.{{iosAsCamelCase}} = expression; + {{/isIosAsCamelCase}} + {{^isIosAsCamelCase}} + {{type}}Layer.{{valueAsCamelCase}} = expression; + {{/isIosAsCamelCase}} break; {{/paint_properties}} {{#layout_properties}} case "{{{value}}}": - lineLayer.{{valueAsCamelCase}} = expression; + {{^isVisibilityProperty}} + {{#isIosAsCamelCase}} + {{type}}Layer.{{iosAsCamelCase}} = expression; + {{/isIosAsCamelCase}} + {{^isIosAsCamelCase}} + {{type}}Layer.{{valueAsCamelCase}} = expression; + {{/isIosAsCamelCase}} + {{/isVisibilityProperty}} + {{#isVisibilityProperty}} + {{type}}Layer.{{iosAsCamelCase}} = propertyValue == "visible"; + {{/isVisibilityProperty}} break; {{/layout_properties}} From 0a97e2c01a9644bea4a7fe6086eff8be98ddb924 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Sun, 24 Oct 2021 13:28:38 +0200 Subject: [PATCH 14/33] working ios version --- ios/Classes/Convert.swift | 166 ------------------ ios/Classes/LayerPropertyConverter.swift | 16 +- .../LayerPropertyConverter.swift.template | 10 +- 3 files changed, 17 insertions(+), 175 deletions(-) diff --git a/ios/Classes/Convert.swift b/ios/Classes/Convert.swift index 6897a7540..bcaed1638 100644 --- a/ios/Classes/Convert.swift +++ b/ios/Classes/Convert.swift @@ -355,170 +355,4 @@ class Convert { } return polygons } - class func addSymbolProperties(symbolLayer: MGLSymbolStyleLayer, properties: [String: String]) { - for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) - switch propertyName { - case "icon-allow-overlap": - symbolLayer.iconAllowsOverlap = expression - case "icon-anchor": - symbolLayer.iconAnchor = expression - case "icon-color": - symbolLayer.iconColor = expression - case "icon-halo-blur": - symbolLayer.iconHaloBlur = expression - case "icon-halo-color": - symbolLayer.iconHaloColor = expression - case "icon-halo-width": - symbolLayer.iconHaloWidth = expression - case "icon-ignore-placement": - symbolLayer.iconIgnoresPlacement = expression - case "icon-image": - symbolLayer.iconImageName = expression - case "icon-keep-upright": - symbolLayer.keepsIconUpright = expression - case "icon-offset": - symbolLayer.iconOffset = expression - case "icon-opacity": - symbolLayer.iconOpacity = expression - case "icon-optional": - symbolLayer.iconOptional = expression - case "icon-padding": - symbolLayer.iconPadding = expression - case "icon-pitch-alignment": - symbolLayer.iconPitchAlignment = expression - case "icon-rotate": - symbolLayer.iconRotation = expression - case "icon-rotation-alignment": - symbolLayer.iconRotationAlignment = expression - case "icon-size": - symbolLayer.iconScale = expression - case "icon-text-fit": - symbolLayer.iconTextFit = expression - case "icon-text-fit-padding": - symbolLayer.iconTextFitPadding = expression - case "icon-translate": - symbolLayer.iconTranslation = expression - case "icon-translate-anchor": - symbolLayer.iconTranslationAnchor = expression - case "symbol-avoid-edges": - symbolLayer.symbolAvoidsEdges = expression - case "symbol-placement": - symbolLayer.symbolPlacement = expression - case "symbol-sort-key": - symbolLayer.symbolSortKey = expression - case "symbol-spacing": - symbolLayer.symbolSpacing = expression - case "symbol-z-order": - symbolLayer.symbolZOrder = expression - case "text-allow-overlap": - symbolLayer.textAllowsOverlap = expression - case "text-anchor": - symbolLayer.textAnchor = expression - case "text-color": - symbolLayer.textColor = expression - case "text-field": - symbolLayer.text = expression - case "text-font": - symbolLayer.textFontNames = expression - case "text-halo-blur": - symbolLayer.textHaloBlur = expression - case "text-halo-color": - symbolLayer.textHaloColor = expression - case "text-halo-width": - symbolLayer.textHaloWidth = expression - case "text-ignore-placement": - symbolLayer.textIgnoresPlacement = expression - case "text-justify": - symbolLayer.textJustification = expression - case "text-keep-upright": - symbolLayer.keepsTextUpright = expression - case "text-letter-spacing": - symbolLayer.textLetterSpacing = expression - case "text-line-height": - symbolLayer.textLineHeight = expression - case "text-max-angle": - symbolLayer.maximumTextAngle = expression - case "text-max-width": - symbolLayer.maximumTextWidth = expression - case "text-offset": - symbolLayer.textOffset = expression - case "text-opacity": - symbolLayer.textOpacity = expression - case "text-optional": - symbolLayer.textOptional = expression - case "text-padding": - symbolLayer.textPadding = expression - case "text-pitch-alignment": - symbolLayer.textPitchAlignment = expression - case "text-radial-offset": - symbolLayer.textRadialOffset = expression - case "text-rotate": - symbolLayer.textRotation = expression - case "text-rotation-alignment": - symbolLayer.textRotationAlignment = expression - case "text-size": - symbolLayer.textFontSize = expression - case "text-transform": - symbolLayer.textTransform = expression - case "text-translate": - symbolLayer.textTranslation = expression - case "text-translate-anchor": - symbolLayer.textTranslationAnchor = expression - case "text-variable-anchor": - symbolLayer.textVariableAnchor = expression - case "text-writing-mode": - symbolLayer.textWritingModes = expression - default: - break - } - } - } - - class func addLineProperties(lineLayer: MGLLineStyleLayer, properties: [String: String]) { - for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) - switch propertyName { - case "line-blur": - lineLayer.lineBlur = expression - case "line-cap": - lineLayer.lineCap = expression - case "line-color": - lineLayer.lineColor = expression - case "line-dasharray": - lineLayer.lineDashPattern = expression - case "line-gap-width": - lineLayer.lineGapWidth = expression - case "line-gradient": - lineLayer.lineGradient = expression - case "line-join": - lineLayer.lineJoin = expression - case "line-miter-limit": - lineLayer.lineMiterLimit = expression - case "line-offset": - lineLayer.lineOffset = expression - case "line-pattern": - lineLayer.linePattern = expression - case "line-round-limit": - lineLayer.lineRoundLimit = expression - case "line-translate": - lineLayer.lineTranslation = expression - case "line-translate-anchor": - lineLayer.lineTranslationAnchor = expression - case "line-width": - lineLayer.lineWidth = expression - default: - break - } - } - } - - private class func interpretExpression(expression: String) -> NSExpression? { - do { - let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: []) - return NSExpression.init(mglJSONObject: json) - } catch { - } - return nil - } } diff --git a/ios/Classes/LayerPropertyConverter.swift b/ios/Classes/LayerPropertyConverter.swift index c0bcf222e..3bde90439 100644 --- a/ios/Classes/LayerPropertyConverter.swift +++ b/ios/Classes/LayerPropertyConverter.swift @@ -7,7 +7,7 @@ import MapboxAnnotationExtension class LayerPropertyConverter { class func addSymbolProperties(symbolLayer: MGLSymbolStyleLayer, properties: [String: String]) { for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) + let expression = interpretExpression(propertyName: propertyName, expression: propertyValue) switch propertyName { case "icon-opacity": symbolLayer.iconOpacity = expression; @@ -186,7 +186,7 @@ class LayerPropertyConverter { class func addCircleProperties(circleLayer: MGLCircleStyleLayer, properties: [String: String]) { for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) + let expression = interpretExpression(propertyName: propertyName, expression: propertyValue) switch propertyName { case "circle-radius": circleLayer.circleRadius = expression; @@ -236,7 +236,7 @@ class LayerPropertyConverter { class func addLineProperties(lineLayer: MGLLineStyleLayer, properties: [String: String]) { for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) + let expression = interpretExpression(propertyName: propertyName, expression: propertyValue) switch propertyName { case "line-opacity": lineLayer.lineOpacity = expression; @@ -298,7 +298,7 @@ class LayerPropertyConverter { class func addFillProperties(fillLayer: MGLFillStyleLayer, properties: [String: String]) { for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) + let expression = interpretExpression(propertyName: propertyName, expression: propertyValue) switch propertyName { case "fill-antialias": fillLayer.fillAntialiased = expression; @@ -334,9 +334,13 @@ class LayerPropertyConverter { } } - private class func interpretExpression(expression: String) -> NSExpression? { + private class func interpretExpression(propertyName: String, expression: String) -> NSExpression? { + let isColor = propertyName.contains("color"); do { - let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: []) + let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: .fragmentsAllowed) + if(isColor && json is String){ + return NSExpression(forConstantValue: UIColor(hexString: json as! String)) + } return NSExpression.init(mglJSONObject: json) } catch { } diff --git a/scripts/templates/LayerPropertyConverter.swift.template b/scripts/templates/LayerPropertyConverter.swift.template index 44f81c895..f94bfdad1 100644 --- a/scripts/templates/LayerPropertyConverter.swift.template +++ b/scripts/templates/LayerPropertyConverter.swift.template @@ -8,7 +8,7 @@ class LayerPropertyConverter { {{#layerTypes}} class func add{{typePascal}}Properties({{type}}Layer: MGL{{typePascal}}StyleLayer, properties: [String: String]) { for (propertyName, propertyValue) in properties { - let expression = interpretExpression(expression: propertyValue) + let expression = interpretExpression(propertyName: propertyName, expression: propertyValue) switch propertyName { {{#paint_properties}} case "{{{value}}}": @@ -43,9 +43,13 @@ class LayerPropertyConverter { } {{/layerTypes}} - private class func interpretExpression(expression: String) -> NSExpression? { + private class func interpretExpression(propertyName: String, expression: String) -> NSExpression? { + let isColor = propertyName.contains("color"); do { - let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: []) + let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: .fragmentsAllowed) + if(isColor && json is String){ + return NSExpression(forConstantValue: UIColor(hexString: json as! String)) + } return NSExpression.init(mglJSONObject: json) } catch { } From 9502e1725a31b1859d0b32d4cfe8b57774d80ae2 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Sun, 24 Oct 2021 13:41:33 +0200 Subject: [PATCH 15/33] added color tools --- example/lib/layer.dart | 13 +++---------- lib/mapbox_gl.dart | 1 + lib/src/color_tools.dart | 10 ++++++++++ 3 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 lib/src/color_tools.dart diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 960735d03..8f8576b8e 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -62,18 +62,11 @@ class LayerState extends State { 18, 'green' ], - FillProperties.fillOpacity: [ - 'interpolate', - ['exponential', 0.5], - ['zoom'], - 11, - 0.5, - 18, - 0.5 - ], + FillProperties.fillOpacity: 0.4 }); controller.addLineLayer("fills", "lines", { + LineProperties.lineColor: Colors.lightBlue.toHexStringRGB(), LineProperties.lineWidth: [ Expressions.interpolate, ["linear"], @@ -87,7 +80,7 @@ class LayerState extends State { controller.addCircleLayer("fills", "circles", { CircleProperties.circleRadius: 4.0, - CircleProperties.circleColor: "#ff0000" + CircleProperties.circleColor: Colors.blue.toHexStringRGB() }); controller.addSymbolLayer("points", "symbols", { diff --git a/lib/mapbox_gl.dart b/lib/mapbox_gl.dart index d29c89615..c9ddc252b 100644 --- a/lib/mapbox_gl.dart +++ b/lib/mapbox_gl.dart @@ -46,3 +46,4 @@ part 'src/global.dart'; part 'src/offline_region.dart'; part 'src/download_region_status.dart'; part 'src/layer_helper.dart'; +part 'src/color_tools.dart'; diff --git a/lib/src/color_tools.dart b/lib/src/color_tools.dart new file mode 100644 index 000000000..f78a5a1c8 --- /dev/null +++ b/lib/src/color_tools.dart @@ -0,0 +1,10 @@ +part of mapbox_gl; + +extension MapBoxColorConversion on Color { + String toHexStringRGB() { + final r = red.toRadixString(16).padLeft(2, '0'); + final g = green.toRadixString(16).padLeft(2, '0'); + final b = blue.toRadixString(16).padLeft(2, '0'); + return '#$r$g$b'; + } +} From bce10602d88313035894efe95b3faf60014d3475 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Mon, 25 Oct 2021 11:59:10 +0200 Subject: [PATCH 16/33] added layer_properties --- example/lib/layer.dart | 70 +- lib/mapbox_gl.dart | 3 +- lib/src/controller.dart | 16 +- lib/src/layer_expressions.dart | 658 +++++++ lib/src/layer_helper.dart | 831 -------- lib/src/layer_properties.dart | 1750 +++++++++++++++++ scripts/lib/generate.dart | 124 +- .../templates/layer_expressions.dart.template | 14 + scripts/templates/layer_helper.dart.template | 40 - .../templates/layer_properties.dart.template | 76 + 10 files changed, 2622 insertions(+), 960 deletions(-) create mode 100644 lib/src/layer_expressions.dart delete mode 100644 lib/src/layer_helper.dart create mode 100644 lib/src/layer_properties.dart create mode 100644 scripts/templates/layer_expressions.dart.template delete mode 100644 scripts/templates/layer_helper.dart.template create mode 100644 scripts/templates/layer_properties.dart.template diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 8f8576b8e..1dea6539b 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -52,46 +52,56 @@ class LayerState extends State { controller.addGeoJsonSource("fills", _fills); controller.addGeoJsonSource("points", _points); - controller.addFillLayer("fills", "fills", { - FillProperties.fillColor: [ - 'interpolate', + controller.addFillLayer( + "fills", + "fills", + FillLayerProperties(fillColor: [ + Expressions.interpolate, ['exponential', 0.5], - ['zoom'], + [Expressions.zoom], 11, 'red', 18, 'green' - ], - FillProperties.fillOpacity: 0.4 - }); + ], fillOpacity: 0.4), + ); - controller.addLineLayer("fills", "lines", { - LineProperties.lineColor: Colors.lightBlue.toHexStringRGB(), - LineProperties.lineWidth: [ - Expressions.interpolate, - ["linear"], - [Expressions.zoom], - 11.0, - 2.0, - 20.0, - 10.0 - ] - }); + controller.addLineLayer( + "fills", + "lines", + LineLayerProperties( + lineColor: Colors.lightBlue.toHexStringRGB(), + lineWidth: [ + Expressions.interpolate, + ["linear"], + [Expressions.zoom], + 11.0, + 2.0, + 20.0, + 10.0 + ]), + ); - controller.addCircleLayer("fills", "circles", { - CircleProperties.circleRadius: 4.0, - CircleProperties.circleColor: Colors.blue.toHexStringRGB() - }); + controller.addCircleLayer( + "fills", + "circles", + CircleLayerProperties( + circleRadius: 4, + circleColor: Colors.blue.toHexStringRGB(), + )); - controller.addSymbolLayer("points", "symbols", { - SymbolProperties.iconImage: "{type}-15", - SymbolProperties.iconSize: 2, - SymbolProperties.iconAllowOverlap: true - }); + controller.addSymbolLayer( + "points", + "symbols", + SymbolLayerProperties( + iconImage: "{type}-15", + iconSize: 2, + iconAllowOverlap: true, + )); } } -final _fills = { +const _fills = { "type": "FeatureCollection", "features": [ { @@ -137,7 +147,7 @@ final _fills = { ] }; -final _points = { +const _points = { "type": "FeatureCollection", "features": [ { diff --git a/lib/mapbox_gl.dart b/lib/mapbox_gl.dart index c9ddc252b..d44c61fa5 100644 --- a/lib/mapbox_gl.dart +++ b/lib/mapbox_gl.dart @@ -45,5 +45,6 @@ part 'src/mapbox_map.dart'; part 'src/global.dart'; part 'src/offline_region.dart'; part 'src/download_region_status.dart'; -part 'src/layer_helper.dart'; +part 'src/layer_expressions.dart'; +part 'src/layer_properties.dart'; part 'src/color_tools.dart'; diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 6ee6b8f61..f61eaf3c5 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -265,27 +265,27 @@ class MapboxMapController extends ChangeNotifier { } Future addSymbolLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, SymbolLayerProperties properties) async { await MapboxGlPlatform.getInstance(_id) - .addSymbolLayer(sourceId, layerId, properties); + .addSymbolLayer(sourceId, layerId, properties.toJson()); } Future addLineLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, LineLayerProperties properties) async { await MapboxGlPlatform.getInstance(_id) - .addLineLayer(sourceId, layerId, properties); + .addLineLayer(sourceId, layerId, properties.toJson()); } Future addFillLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, FillLayerProperties properties) async { await MapboxGlPlatform.getInstance(_id) - .addFillLayer(sourceId, layerId, properties); + .addFillLayer(sourceId, layerId, properties.toJson()); } Future addCircleLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, CircleLayerProperties properties) async { await MapboxGlPlatform.getInstance(_id) - .addCircleLayer(sourceId, layerId, properties); + .addCircleLayer(sourceId, layerId, properties.toJson()); } /// Updates user location tracking mode. diff --git a/lib/src/layer_expressions.dart b/lib/src/layer_expressions.dart new file mode 100644 index 000000000..91451361f --- /dev/null +++ b/lib/src/layer_expressions.dart @@ -0,0 +1,658 @@ +// This file is generated by +// ./scripts/lib/generate.dart + +part of mapbox_gl; + +class Expressions{ + /// Binds expressions to named variables, which can then be referenced in + /// the result expression using ["var", "variable_name"]. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const let = "let"; + + /// References variable bound using "let". + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const varExpression = "var"; + + /// Provides a literal array or object value. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const literal = "literal"; + + /// Asserts that the input is an array (optionally with a specific item + /// type and length). If, when the input expression is evaluated, it is + /// not of the asserted type, then this assertion will cause the whole + /// expression to be aborted. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const array = "array"; + + /// Retrieves an item from an array. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const at = "at"; + + /// Determines whether an item exists in an array or a substring exists in + /// a string. + /// + /// Sdk Support + /// basic functionality with js + static const inExpression = "in"; + + /// Selects the first output whose corresponding test condition evaluates + /// to true, or the fallback value otherwise. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const caseExpression = "case"; + + /// Selects the output whose label value matches the input value, or the + /// fallback value if no match is found. The input can be any expression + /// (e.g. `["get", "building_type"]`). Each label must be either: + /// * a single literal value; or + /// * an array of literal values, whose values must be all strings or all + /// numbers (e.g. `[100, 101]` or `["c", "b"]`). The input matches if any + /// of the values in the array matches, similar to the `"in"` + /// operator.Each label must be unique. If the input type does not match + /// the type of the labels, the result will be the fallback value. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const match = "match"; + + /// Evaluates each expression in turn until the first non-null value is + /// obtained, and returns that value. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const coalesce = "coalesce"; + + /// Produces discrete, stepped results by evaluating a piecewise-constant + /// function defined by pairs of input and output values ("stops"). The + /// `input` may be any numeric expression (e.g., `["get", "population"]`). + /// Stop inputs must be numeric literals in strictly ascending order. + /// Returns the output value of the stop just less than the input, or the + /// first output if the input is less than the first stop. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const step = "step"; + + /// Produces continuous, smooth results by interpolating between pairs of + /// input and output values ("stops"). The `input` may be any numeric + /// expression (e.g., `["get", "population"]`). Stop inputs must be + /// numeric literals in strictly ascending order. The output type must be + /// `number`, `array`, or `color`.Interpolation types:- + /// `["linear"]`: interpolates linearly between the pair of stops just + /// less than and just greater than the input.- `["exponential", base]`: + /// interpolates exponentially between the stops just less than and just + /// greater than the input. `base` controls the rate at which the output + /// increases: higher values make the output increase more towards the + /// high end of the range. With values close to 1 the output increases + /// linearly.- `["cubic-bezier", x1, y1, x2, y2]`: interpolates using the + /// cubic bezier curve defined by the given control points. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const interpolate = "interpolate"; + + /// Produces continuous, smooth results by interpolating between pairs of + /// input and output values ("stops"). Works like `interpolate`, but the + /// output type must be `color`, and the interpolation is performed in the + /// Hue-Chroma-Luminance color space. + /// + /// Sdk Support + /// basic functionality with js + static const interpolateHcl = "interpolate-hcl"; + + /// Produces continuous, smooth results by interpolating between pairs of + /// input and output values ("stops"). Works like `interpolate`, but the + /// output type must be `color`, and the interpolation is performed in the + /// CIELAB color space. + /// + /// Sdk Support + /// basic functionality with js + static const interpolateLab = "interpolate-lab"; + + /// Returns mathematical constant ln(2). + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const ln2 = "ln2"; + + /// Returns the mathematical constant pi. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const pi = "pi"; + + /// Returns the mathematical constant e. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const e = "e"; + + /// Returns a string describing the type of the given value. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const typeof = "typeof"; + + /// Asserts that the input value is a string. If multiple values are + /// provided, each one is evaluated in order until a string is obtained. + /// If none of the inputs are strings, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const string = "string"; + + /// Asserts that the input value is a number. If multiple values are + /// provided, each one is evaluated in order until a number is obtained. + /// If none of the inputs are numbers, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const number = "number"; + + /// Asserts that the input value is a boolean. If multiple values are + /// provided, each one is evaluated in order until a boolean is obtained. + /// If none of the inputs are booleans, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const boolean = "boolean"; + + /// Asserts that the input value is an object. If multiple values are + /// provided, each one is evaluated in order until an object is obtained. + /// If none of the inputs are objects, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const object = "object"; + + /// Returns a `collator` for use in locale-dependent comparison + /// operations. The `case-sensitive` and `diacritic-sensitive` options + /// default to `false`. The `locale` argument specifies the IETF language + /// tag of the locale to use. If none is provided, the default locale is + /// used. If the requested locale is not available, the `collator` will + /// use a system-defined fallback locale. Use `resolved-locale` to test + /// the results of locale fallback behavior. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const collator = "collator"; + + /// Returns `formatted` text containing annotations for use in + /// mixed-format `text-field` entries. For a `text-field` entries of a + /// string type, following option object's properties are supported: If + /// set, the `text-font` value overrides the font specified by the root + /// layout properties. If set, the `font-scale` value specifies a scaling + /// factor relative to the `text-size` specified in the root layout + /// properties. If set, the `text-color` value overrides the color + /// specified by the root paint properties for this layer. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const format = "format"; + + /// Returns an `image` type for use in `icon-image`, `*-pattern` entries + /// and as a section in the `format` expression. If set, the `image` + /// argument will check that the requested image exists in the style and + /// will return either the resolved image name or `null`, depending on + /// whether or not the image is currently in the style. This validation + /// process is synchronous and requires the image to have been added to + /// the style before requesting it in the `image` argument. + /// + /// Sdk Support + /// basic functionality with js android ios + static const image = "image"; + + /// Converts the input number into a string representation using the + /// providing formatting rules. If set, the `locale` argument specifies + /// the locale to use, as a BCP 47 language tag. If set, the `currency` + /// argument specifies an ISO 4217 code to use for currency-style + /// formatting. If set, the `min-fraction-digits` and + /// `max-fraction-digits` arguments specify the minimum and maximum number + /// of fractional digits to include. + /// + /// Sdk Support + /// basic functionality with js + static const numberFormat = "number-format"; + + /// Converts the input value to a string. If the input is `null`, the + /// result is `""`. If the input is a boolean, the result is `"true"` or + /// `"false"`. If the input is a number, it is converted to a string as + /// specified by the ["NumberToString" + /// algorithm](https://tc39.github.io/ecma262/#sec-tostring-applied-to-the-number-type) + /// of the ECMAScript Language Specification. If the input is a color, it + /// is converted to a string of the form `"rgba(r,g,b,a)"`, where `r`, + /// `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from 0 + /// to 1. Otherwise, the input is converted to a string in the format + /// specified by the + /// [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) + /// function of the ECMAScript Language Specification. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const toStringExpression = "to-string"; + + /// Converts the input value to a number, if possible. If the input is + /// `null` or `false`, the result is 0. If the input is `true`, the result + /// is 1. If the input is a string, it is converted to a number as + /// specified by the ["ToNumber Applied to the String Type" + /// algorithm](https://tc39.github.io/ecma262/#sec-tonumber-applied-to-the-string-type) + /// of the ECMAScript Language Specification. If multiple values are + /// provided, each one is evaluated in order until the first successful + /// conversion is obtained. If none of the inputs can be converted, the + /// expression is an error. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const toNumber = "to-number"; + + /// Converts the input value to a boolean. The result is `false` when then + /// input is an empty string, 0, `false`, `null`, or `NaN`; otherwise it + /// is `true`. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const toBoolean = "to-boolean"; + + /// Returns a four-element array containing the input color's red, green, + /// blue, and alpha components, in that order. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const toRgba = "to-rgba"; + + /// Converts the input value to a color. If multiple values are provided, + /// each one is evaluated in order until the first successful conversion + /// is obtained. If none of the inputs can be converted, the expression is + /// an error. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const toColor = "to-color"; + + /// Creates a color value from red, green, and blue components, which must + /// range between 0 and 255, and an alpha component of 1. If any component + /// is out of range, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const rgb = "rgb"; + + /// Creates a color value from red, green, blue components, which must + /// range between 0 and 255, and an alpha component which must range + /// between 0 and 1. If any component is out of range, the expression is + /// an error. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const rgba = "rgba"; + + /// Retrieves a property value from the current feature's properties, or + /// from another object if a second argument is provided. Returns null if + /// the requested property is missing. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const get = "get"; + + /// Tests for the presence of an property value in the current feature's + /// properties, or from another object if a second argument is provided. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const has = "has"; + + /// Gets the length of an array or string. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const length = "length"; + + /// Gets the feature properties object. Note that in some cases, it may + /// be more efficient to use ["get", "property_name"] directly. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const properties = "properties"; + + /// Retrieves a property value from the current feature's state. Returns + /// null if the requested property is not present on the feature's state. + /// A feature's state is not part of the GeoJSON or vector tile data, and + /// must be set programmatically on each feature. Features are identified + /// by their `id` attribute, which must be an integer or a string that can + /// be cast to an integer. Note that ["feature-state"] can only be used + /// with paint properties that support data-driven styling. + /// + /// Sdk Support + /// basic functionality with js + static const featureState = "feature-state"; + + /// Gets the feature's geometry type: Point, MultiPoint, LineString, + /// MultiLineString, Polygon, MultiPolygon. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const geometryType = "geometry-type"; + + /// Gets the feature's id, if it has one. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const id = "id"; + + /// Gets the current zoom level. Note that in style layout and paint + /// properties, ["zoom"] may only appear as the input to a top-level + /// "step" or "interpolate" expression. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const zoom = "zoom"; + + /// Gets the kernel density estimation of a pixel in a heatmap layer, + /// which is a relative measure of how many data points are crowded around + /// a particular pixel. Can only be used in the `heatmap-color` property. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const heatmapDensity = "heatmap-density"; + + /// Gets the progress along a gradient line. Can only be used in the + /// `line-gradient` property. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const lineProgress = "line-progress"; + + /// Gets the value of a cluster property accumulated so far. Can only be + /// used in the `clusterProperties` option of a clustered GeoJSON source. + /// + /// Sdk Support + /// basic functionality with js + static const accumulated = "accumulated"; + + /// Returns the sum of the inputs. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const plus = "+"; + + /// Returns the product of the inputs. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const multiply = "*"; + + /// For two inputs, returns the result of subtracting the second input + /// from the first. For a single input, returns the result of subtracting + /// it from 0. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const minus = "-"; + + /// Returns the result of floating point division of the first input by + /// the second. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const divide = "/"; + + /// Returns the remainder after integer division of the first input by the + /// second. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const precent = "%"; + + /// Returns the result of raising the first input to the power specified + /// by the second. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const xor = "^"; + + /// Returns the square root of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const sqrt = "sqrt"; + + /// Returns the base-ten logarithm of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const log10 = "log10"; + + /// Returns the natural logarithm of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const ln = "ln"; + + /// Returns the base-two logarithm of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const log2 = "log2"; + + /// Returns the sine of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const sin = "sin"; + + /// Returns the cosine of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const cos = "cos"; + + /// Returns the tangent of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const tan = "tan"; + + /// Returns the arcsine of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const asin = "asin"; + + /// Returns the arccosine of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const acos = "acos"; + + /// Returns the arctangent of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const atan = "atan"; + + /// Returns the minimum value of the inputs. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const min = "min"; + + /// Returns the maximum value of the inputs. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const max = "max"; + + /// Rounds the input to the nearest integer. Halfway values are rounded + /// away from zero. For example, `["round", -1.5]` evaluates to -2. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const round = "round"; + + /// Returns the absolute value of the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const abs = "abs"; + + /// Returns the smallest integer that is greater than or equal to the + /// input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const ceil = "ceil"; + + /// Returns the largest integer that is less than or equal to the input. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const floor = "floor"; + + /// Returns `true` if the input values are equal, `false` otherwise. The + /// comparison is strictly typed: values of different runtime types are + /// always considered unequal. Cases where the types are known to be + /// different at parse time are considered invalid and will produce a + /// parse error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const equal = "=="; + + /// Returns `true` if the input values are not equal, `false` otherwise. + /// The comparison is strictly typed: values of different runtime types + /// are always considered unequal. Cases where the types are known to be + /// different at parse time are considered invalid and will produce a + /// parse error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const notEqual = "!="; + + /// Returns `true` if the first input is strictly greater than the second, + /// `false` otherwise. The arguments are required to be either both + /// strings or both numbers; if during evaluation they are not, expression + /// evaluation produces an error. Cases where this constraint is known not + /// to hold at parse time are considered in valid and will produce a parse + /// error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const larger = ">"; + + /// Returns `true` if the first input is strictly less than the second, + /// `false` otherwise. The arguments are required to be either both + /// strings or both numbers; if during evaluation they are not, expression + /// evaluation produces an error. Cases where this constraint is known not + /// to hold at parse time are considered in valid and will produce a parse + /// error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const smaller = "<"; + + /// Returns `true` if the first input is greater than or equal to the + /// second, `false` otherwise. The arguments are required to be either + /// both strings or both numbers; if during evaluation they are not, + /// expression evaluation produces an error. Cases where this constraint + /// is known not to hold at parse time are considered in valid and will + /// produce a parse error. Accepts an optional `collator` argument to + /// control locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const largerOrEqual = ">="; + + /// Returns `true` if the first input is less than or equal to the second, + /// `false` otherwise. The arguments are required to be either both + /// strings or both numbers; if during evaluation they are not, expression + /// evaluation produces an error. Cases where this constraint is known not + /// to hold at parse time are considered in valid and will produce a parse + /// error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const smallerOrEqual = "<="; + + /// Returns `true` if all the inputs are `true`, `false` otherwise. The + /// inputs are evaluated in order, and evaluation is short-circuiting: + /// once an input expression evaluates to `false`, the result is `false` + /// and no further input expressions are evaluated. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const all = "all"; + + /// Returns `true` if any of the inputs are `true`, `false` otherwise. The + /// inputs are evaluated in order, and evaluation is short-circuiting: + /// once an input expression evaluates to `true`, the result is `true` and + /// no further input expressions are evaluated. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const any = "any"; + + /// Logical negation. Returns `true` if the input is `false`, and `false` + /// if the input is `true`. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const not = "!"; + + /// Returns `true` if the input string is expected to render legibly. + /// Returns `false` if the input string contains sections that cannot be + /// rendered without potential loss of meaning (e.g. Indic scripts that + /// require complex text shaping, or right-to-left scripts if the the + /// `mapbox-gl-rtl-text` plugin is not in use in Mapbox GL JS). + /// + /// Sdk Support + /// basic functionality with js android + static const isSupportedScript = "is-supported-script"; + + /// Returns the input string converted to uppercase. Follows the Unicode + /// Default Case Conversion algorithm and the locale-insensitive case + /// mappings in the Unicode Character Database. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const upcase = "upcase"; + + /// Returns the input string converted to lowercase. Follows the Unicode + /// Default Case Conversion algorithm and the locale-insensitive case + /// mappings in the Unicode Character Database. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const downcase = "downcase"; + + /// Returns a `string` consisting of the concatenation of the inputs. Each + /// input is converted to a string as if by `to-string`. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const concat = "concat"; + + /// Returns the IETF language tag of the locale being used by the provided + /// `collator`. This can be used to determine the default system locale, + /// or to determine if a requested locale was successfully loaded. + /// + /// Sdk Support + /// basic functionality with js android ios macos + static const resolvedLocale = "resolved-locale"; + +} diff --git a/lib/src/layer_helper.dart b/lib/src/layer_helper.dart deleted file mode 100644 index 7621d16f0..000000000 --- a/lib/src/layer_helper.dart +++ /dev/null @@ -1,831 +0,0 @@ -// This file is generated by -// ./scripts/lib/generate.dart - -part of mapbox_gl; - - -class SymbolProperties{ - // Paint Properties - /// The opacity at which the icon will be drawn. - static const iconOpacity = "icon-opacity"; - - /// The color of the icon. This can only be used with sdf icons. - static const iconColor = "icon-color"; - - /// The color of the icon's halo. Icon halos can only be used with SDF - /// icons. - static const iconHaloColor = "icon-halo-color"; - - /// Distance of halo to the icon outline. - static const iconHaloWidth = "icon-halo-width"; - - /// Fade out the halo towards the outside. - static const iconHaloBlur = "icon-halo-blur"; - - /// 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. - static const iconTranslate = "icon-translate"; - - /// Controls the frame of reference for `icon-translate`. - static const iconTranslateAnchor = "icon-translate-anchor"; - - /// The opacity at which the text will be drawn. - static const textOpacity = "text-opacity"; - - /// The color with which the text will be drawn. - static const textColor = "text-color"; - - /// The color of the text's halo, which helps it stand out from - /// backgrounds. - static const textHaloColor = "text-halo-color"; - - /// Distance of halo to the font outline. Max text halo width is 1/4 of - /// the font-size. - static const textHaloWidth = "text-halo-width"; - - /// The halo's fadeout distance towards the outside. - static const textHaloBlur = "text-halo-blur"; - - /// 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. - static const textTranslate = "text-translate"; - - /// Controls the frame of reference for `text-translate`. - static const textTranslateAnchor = "text-translate-anchor"; - - - // Layout Properties - /// Label placement relative to its geometry. - static const symbolPlacement = "symbol-placement"; - - /// Distance between two symbol anchors. - static const symbolSpacing = "symbol-spacing"; - - /// 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. When using a client that - /// supports global collision detection, like Mapbox GL JS version 0.42.0 - /// or greater, enabling this property is not needed to prevent clipped - /// labels at tile boundaries. - static const symbolAvoidEdges = "symbol-avoid-edges"; - - /// Sorts features in ascending order based on this value. Features with - /// lower sort keys are drawn and placed first. When - /// `icon-allow-overlap` or `text-allow-overlap` is `false`, features - /// with a lower sort key will have priority during placement. When - /// `icon-allow-overlap` or `text-allow-overlap` is set to `true`, - /// features with a higher sort key will overlap over features with a - /// lower sort key. - static const symbolSortKey = "symbol-sort-key"; - - /// Controls the order in which overlapping symbols in the same layer are - /// rendered - static const symbolZOrder = "symbol-z-order"; - - /// If true, the icon will be visible even if it collides with other - /// previously drawn symbols. - static const iconAllowOverlap = "icon-allow-overlap"; - - /// If true, other symbols can be visible even if they collide with the - /// icon. - static const iconIgnorePlacement = "icon-ignore-placement"; - - /// If true, text will display without their corresponding icons when the - /// icon collides with other symbols and the text does not. - static const iconOptional = "icon-optional"; - - /// In combination with `symbol-placement`, determines the rotation - /// behavior of icons. - static const iconRotationAlignment = "icon-rotation-alignment"; - - /// Scales the original size of the icon by the provided factor. The new - /// pixel size of the image will be the original pixel size multiplied by - /// `icon-size`. 1 is the original size; 3 triples the size of the image. - static const iconSize = "icon-size"; - - /// Scales the icon to fit around the associated text. - static const iconTextFit = "icon-text-fit"; - - /// Size of the additional area added to dimensions determined by - /// `icon-text-fit`, in clockwise order: top, right, bottom, left. - static const iconTextFitPadding = "icon-text-fit-padding"; - - /// Name of image in sprite to use for drawing an image background. - static const iconImage = "icon-image"; - - /// Rotates the icon clockwise. - static const iconRotate = "icon-rotate"; - - /// Size of the additional area around the icon bounding box used for - /// detecting symbol collisions. - static const iconPadding = "icon-padding"; - - /// If true, the icon may be flipped to prevent it from being rendered - /// upside-down. - static const iconKeepUpright = "icon-keep-upright"; - - /// Offset distance of icon from its anchor. Positive values indicate - /// right and down, while negative values indicate left and up. Each - /// component is multiplied by the value of `icon-size` to obtain the - /// final offset in pixels. When combined with `icon-rotate` the offset - /// will be as if the rotated direction was up. - static const iconOffset = "icon-offset"; - - /// Part of the icon placed closest to the anchor. - static const iconAnchor = "icon-anchor"; - - /// Orientation of icon when map is pitched. - static const iconPitchAlignment = "icon-pitch-alignment"; - - /// Orientation of text when map is pitched. - static const textPitchAlignment = "text-pitch-alignment"; - - /// In combination with `symbol-placement`, determines the rotation - /// behavior of the individual glyphs forming the text. - static const textRotationAlignment = "text-rotation-alignment"; - - /// Value to use for a text label. If a plain `string` is provided, it - /// will be treated as a `formatted` with default/inherited formatting - /// options. - static const textField = "text-field"; - - /// Font stack to use for displaying text. - static const textFont = "text-font"; - - /// Font size. - static const textSize = "text-size"; - - /// The maximum line width for text wrapping. - static const textMaxWidth = "text-max-width"; - - /// Text leading value for multi-line text. - static const textLineHeight = "text-line-height"; - - /// Text tracking amount. - static const textLetterSpacing = "text-letter-spacing"; - - /// Text justification options. - static const textJustify = "text-justify"; - - /// Radial offset of text, in the direction of the symbol's anchor. - /// Useful in combination with `text-variable-anchor`, which defaults to - /// using the two-dimensional `text-offset` if present. - static const textRadialOffset = "text-radial-offset"; - - /// To increase the chance of placing high-priority labels on the map, - /// you can provide an array of `text-anchor` locations: the renderer - /// will attempt to place the label at each location, in order, before - /// moving onto the next label. Use `text-justify: auto` to choose - /// justification based on anchor position. To apply an offset, use the - /// `text-radial-offset` or the two-dimensional `text-offset`. - static const textVariableAnchor = "text-variable-anchor"; - - /// Part of the text placed closest to the anchor. - static const textAnchor = "text-anchor"; - - /// Maximum angle change between adjacent characters. - static const textMaxAngle = "text-max-angle"; - - /// The property allows control over a symbol's orientation. Note that - /// the property values act as a hint, so that a symbol whose language - /// doesn’t support the provided orientation will be laid out in its - /// natural orientation. Example: English point symbol will be rendered - /// horizontally even if array value contains single 'vertical' enum - /// value. The order of elements in an array define priority order for - /// the placement of an orientation variant. - static const textWritingMode = "text-writing-mode"; - - /// Rotates the text clockwise. - static const textRotate = "text-rotate"; - - /// Size of the additional area around the text bounding box used for - /// detecting symbol collisions. - static const textPadding = "text-padding"; - - /// If true, the text may be flipped vertically to prevent it from being - /// rendered upside-down. - static const textKeepUpright = "text-keep-upright"; - - /// Specifies how to capitalize text, similar to the CSS `text-transform` - /// property. - static const textTransform = "text-transform"; - - /// Offset distance of text from its anchor. Positive values indicate - /// right and down, while negative values indicate left and up. If used - /// with text-variable-anchor, input values will be taken as absolute - /// values. Offsets along the x- and y-axis will be applied automatically - /// based on the anchor position. - static const textOffset = "text-offset"; - - /// If true, the text will be visible even if it collides with other - /// previously drawn symbols. - static const textAllowOverlap = "text-allow-overlap"; - - /// If true, other symbols can be visible even if they collide with the - /// text. - static const textIgnorePlacement = "text-ignore-placement"; - - /// If true, icons will display without their corresponding text when the - /// text collides with other symbols and the icon does not. - static const textOptional = "text-optional"; - - /// Whether this layer is displayed. - static const visibility = "visibility"; - -} - - -class CircleProperties{ - // Paint Properties - /// Circle radius. - static const circleRadius = "circle-radius"; - - /// The fill color of the circle. - static const circleColor = "circle-color"; - - /// Amount to blur the circle. 1 blurs the circle such that only the - /// centerpoint is full opacity. - static const circleBlur = "circle-blur"; - - /// The opacity at which the circle will be drawn. - static const circleOpacity = "circle-opacity"; - - /// The geometry's offset. Values are [x, y] where negatives indicate - /// left and up, respectively. - static const circleTranslate = "circle-translate"; - - /// Controls the frame of reference for `circle-translate`. - static const circleTranslateAnchor = "circle-translate-anchor"; - - /// Controls the scaling behavior of the circle when the map is pitched. - static const circlePitchScale = "circle-pitch-scale"; - - /// Orientation of circle when map is pitched. - static const circlePitchAlignment = "circle-pitch-alignment"; - - /// The width of the circle's stroke. Strokes are placed outside of the - /// `circle-radius`. - static const circleStrokeWidth = "circle-stroke-width"; - - /// The stroke color of the circle. - static const circleStrokeColor = "circle-stroke-color"; - - /// The opacity of the circle's stroke. - static const circleStrokeOpacity = "circle-stroke-opacity"; - - - // Layout Properties - /// Sorts features in ascending order based on this value. Features with - /// a higher sort key will appear above features with a lower sort key. - static const circleSortKey = "circle-sort-key"; - - /// Whether this layer is displayed. - static const visibility = "visibility"; - -} - - -class LineProperties{ - // Paint Properties - /// The opacity at which the line will be drawn. - static const lineOpacity = "line-opacity"; - - /// The color with which the line will be drawn. - static const lineColor = "line-color"; - - /// The geometry's offset. Values are [x, y] where negatives indicate - /// left and up, respectively. - static const lineTranslate = "line-translate"; - - /// Controls the frame of reference for `line-translate`. - static const lineTranslateAnchor = "line-translate-anchor"; - - /// Stroke thickness. - static const lineWidth = "line-width"; - - /// Draws a line casing outside of a line's actual path. Value indicates - /// the width of the inner gap. - static const lineGapWidth = "line-gap-width"; - - /// The line's offset. For linear features, a positive value offsets the - /// line to the right, relative to the direction of the line, and a - /// negative value to the left. For polygon features, a positive value - /// results in an inset, and a negative value results in an outset. - static const lineOffset = "line-offset"; - - /// Blur applied to the line, in pixels. - static const lineBlur = "line-blur"; - - /// 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. Note that GeoJSON sources with `lineMetrics: true` - /// specified won't render dashed lines to the expected scale. Also note - /// that zoom-dependent expressions will be evaluated only at integer - /// zoom levels. - static const lineDasharray = "line-dasharray"; - - /// 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). - /// Note that zoom-dependent expressions will be evaluated only at - /// integer zoom levels. - static const linePattern = "line-pattern"; - - /// Defines a gradient with which to color a line feature. Can only be - /// used with GeoJSON sources that specify `"lineMetrics": true`. - static const lineGradient = "line-gradient"; - - - // Layout Properties - /// The display of line endings. - static const lineCap = "line-cap"; - - /// The display of lines when joining. - static const lineJoin = "line-join"; - - /// Used to automatically convert miter joins to bevel joins for sharp - /// angles. - static const lineMiterLimit = "line-miter-limit"; - - /// Used to automatically convert round joins to miter joins for shallow - /// angles. - static const lineRoundLimit = "line-round-limit"; - - /// Sorts features in ascending order based on this value. Features with - /// a higher sort key will appear above features with a lower sort key. - static const lineSortKey = "line-sort-key"; - - /// Whether this layer is displayed. - static const visibility = "visibility"; - -} - - -class FillProperties{ - // Paint Properties - /// Whether or not the fill should be antialiased. - static const fillAntialias = "fill-antialias"; - - /// 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. - static const fillOpacity = "fill-opacity"; - - /// 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. - static const fillColor = "fill-color"; - - /// The outline color of the fill. Matches the value of `fill-color` if - /// unspecified. - static const fillOutlineColor = "fill-outline-color"; - - /// The geometry's offset. Values are [x, y] where negatives indicate - /// left and up, respectively. - static const fillTranslate = "fill-translate"; - - /// Controls the frame of reference for `fill-translate`. - static const fillTranslateAnchor = "fill-translate-anchor"; - - /// 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). Note that zoom-dependent expressions will be evaluated - /// only at integer zoom levels. - static const fillPattern = "fill-pattern"; - - - // Layout Properties - /// Sorts features in ascending order based on this value. Features with - /// a higher sort key will appear above features with a lower sort key. - static const fillSortKey = "fill-sort-key"; - - /// Whether this layer is displayed. - static const visibility = "visibility"; - -} - - - - -class Expressions{ - /// Binds expressions to named variables, which can then be referenced in - /// the result expression using ["var", "variable_name"]. - static const let = "let"; - - /// References variable bound using "let". - static const varExpression = "var"; - - /// Provides a literal array or object value. - static const literal = "literal"; - - /// Asserts that the input is an array (optionally with a specific item - /// type and length). If, when the input expression is evaluated, it is - /// not of the asserted type, then this assertion will cause the whole - /// expression to be aborted. - static const array = "array"; - - /// Retrieves an item from an array. - static const at = "at"; - - /// Determines whether an item exists in an array or a substring exists - /// in a string. - static const inExpression = "in"; - - /// Selects the first output whose corresponding test condition evaluates - /// to true, or the fallback value otherwise. - static const caseExpression = "case"; - - /// Selects the output whose label value matches the input value, or the - /// fallback value if no match is found. The input can be any expression - /// (e.g. `["get", "building_type"]`). Each label must be either: - /// * a single literal value; or - /// * an array of literal values, whose values must be all strings or all - /// numbers (e.g. `[100, 101]` or `["c", "b"]`). The input matches if any - /// of the values in the array matches, similar to the `"in"` - /// operator.Each label must be unique. If the input type does not - /// match the type of the labels, the result will be the fallback value. - static const match = "match"; - - /// Evaluates each expression in turn until the first non-null value is - /// obtained, and returns that value. - static const coalesce = "coalesce"; - - /// Produces discrete, stepped results by evaluating a piecewise-constant - /// function defined by pairs of input and output values ("stops"). The - /// `input` may be any numeric expression (e.g., `["get", - /// "population"]`). Stop inputs must be numeric literals in strictly - /// ascending order. Returns the output value of the stop just less than - /// the input, or the first output if the input is less than the first - /// stop. - static const step = "step"; - - /// Produces continuous, smooth results by interpolating between pairs of - /// input and output values ("stops"). The `input` may be any numeric - /// expression (e.g., `["get", "population"]`). Stop inputs must be - /// numeric literals in strictly ascending order. The output type must be - /// `number`, `array`, or `color`.Interpolation types:- - /// `["linear"]`: interpolates linearly between the pair of stops just - /// less than and just greater than the input.- `["exponential", base]`: - /// interpolates exponentially between the stops just less than and just - /// greater than the input. `base` controls the rate at which the output - /// increases: higher values make the output increase more towards the - /// high end of the range. With values close to 1 the output increases - /// linearly.- `["cubic-bezier", x1, y1, x2, y2]`: interpolates using - /// the cubic bezier curve defined by the given control points. - static const interpolate = "interpolate"; - - /// Produces continuous, smooth results by interpolating between pairs of - /// input and output values ("stops"). Works like `interpolate`, but the - /// output type must be `color`, and the interpolation is performed in - /// the Hue-Chroma-Luminance color space. - static const interpolateHcl = "interpolate-hcl"; - - /// Produces continuous, smooth results by interpolating between pairs of - /// input and output values ("stops"). Works like `interpolate`, but the - /// output type must be `color`, and the interpolation is performed in - /// the CIELAB color space. - static const interpolateLab = "interpolate-lab"; - - /// Returns mathematical constant ln(2). - static const ln2 = "ln2"; - - /// Returns the mathematical constant pi. - static const pi = "pi"; - - /// Returns the mathematical constant e. - static const e = "e"; - - /// Returns a string describing the type of the given value. - static const typeof = "typeof"; - - /// Asserts that the input value is a string. If multiple values are - /// provided, each one is evaluated in order until a string is obtained. - /// If none of the inputs are strings, the expression is an error. - static const string = "string"; - - /// Asserts that the input value is a number. If multiple values are - /// provided, each one is evaluated in order until a number is obtained. - /// If none of the inputs are numbers, the expression is an error. - static const number = "number"; - - /// Asserts that the input value is a boolean. If multiple values are - /// provided, each one is evaluated in order until a boolean is obtained. - /// If none of the inputs are booleans, the expression is an error. - static const boolean = "boolean"; - - /// Asserts that the input value is an object. If multiple values are - /// provided, each one is evaluated in order until an object is obtained. - /// If none of the inputs are objects, the expression is an error. - static const object = "object"; - - /// Returns a `collator` for use in locale-dependent comparison - /// operations. The `case-sensitive` and `diacritic-sensitive` options - /// default to `false`. The `locale` argument specifies the IETF language - /// tag of the locale to use. If none is provided, the default locale is - /// used. If the requested locale is not available, the `collator` will - /// use a system-defined fallback locale. Use `resolved-locale` to test - /// the results of locale fallback behavior. - static const collator = "collator"; - - /// Returns `formatted` text containing annotations for use in - /// mixed-format `text-field` entries. For a `text-field` entries of a - /// string type, following option object's properties are supported: If - /// set, the `text-font` value overrides the font specified by the root - /// layout properties. If set, the `font-scale` value specifies a scaling - /// factor relative to the `text-size` specified in the root layout - /// properties. If set, the `text-color` value overrides the color - /// specified by the root paint properties for this layer. - static const format = "format"; - - /// Returns an `image` type for use in `icon-image`, `*-pattern` entries - /// and as a section in the `format` expression. If set, the `image` - /// argument will check that the requested image exists in the style and - /// will return either the resolved image name or `null`, depending on - /// whether or not the image is currently in the style. This validation - /// process is synchronous and requires the image to have been added to - /// the style before requesting it in the `image` argument. - static const image = "image"; - - /// Converts the input number into a string representation using the - /// providing formatting rules. If set, the `locale` argument specifies - /// the locale to use, as a BCP 47 language tag. If set, the `currency` - /// argument specifies an ISO 4217 code to use for currency-style - /// formatting. If set, the `min-fraction-digits` and - /// `max-fraction-digits` arguments specify the minimum and maximum - /// number of fractional digits to include. - static const numberFormat = "number-format"; - - /// Converts the input value to a string. If the input is `null`, the - /// result is `""`. If the input is a boolean, the result is `"true"` or - /// `"false"`. If the input is a number, it is converted to a string as - /// specified by the ["NumberToString" - /// algorithm](https://tc39.github.io/ecma262/#sec-tostring-applied-to-the-number-type) - /// of the ECMAScript Language Specification. If the input is a color, it - /// is converted to a string of the form `"rgba(r,g,b,a)"`, where `r`, - /// `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from - /// 0 to 1. Otherwise, the input is converted to a string in the format - /// specified by the - /// [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) - /// function of the ECMAScript Language Specification. - static const toStringExpression = "to-string"; - - /// Converts the input value to a number, if possible. If the input is - /// `null` or `false`, the result is 0. If the input is `true`, the - /// result is 1. If the input is a string, it is converted to a number as - /// specified by the ["ToNumber Applied to the String Type" - /// algorithm](https://tc39.github.io/ecma262/#sec-tonumber-applied-to-the-string-type) - /// of the ECMAScript Language Specification. If multiple values are - /// provided, each one is evaluated in order until the first successful - /// conversion is obtained. If none of the inputs can be converted, the - /// expression is an error. - static const toNumber = "to-number"; - - /// Converts the input value to a boolean. The result is `false` when - /// then input is an empty string, 0, `false`, `null`, or `NaN`; - /// otherwise it is `true`. - static const toBoolean = "to-boolean"; - - /// Returns a four-element array containing the input color's red, green, - /// blue, and alpha components, in that order. - static const toRgba = "to-rgba"; - - /// Converts the input value to a color. If multiple values are provided, - /// each one is evaluated in order until the first successful conversion - /// is obtained. If none of the inputs can be converted, the expression - /// is an error. - static const toColor = "to-color"; - - /// Creates a color value from red, green, and blue components, which - /// must range between 0 and 255, and an alpha component of 1. If any - /// component is out of range, the expression is an error. - static const rgb = "rgb"; - - /// Creates a color value from red, green, blue components, which must - /// range between 0 and 255, and an alpha component which must range - /// between 0 and 1. If any component is out of range, the expression is - /// an error. - static const rgba = "rgba"; - - /// Retrieves a property value from the current feature's properties, or - /// from another object if a second argument is provided. Returns null if - /// the requested property is missing. - static const get = "get"; - - /// Tests for the presence of an property value in the current feature's - /// properties, or from another object if a second argument is provided. - static const has = "has"; - - /// Gets the length of an array or string. - static const length = "length"; - - /// Gets the feature properties object. Note that in some cases, it may - /// be more efficient to use ["get", "property_name"] directly. - static const properties = "properties"; - - /// Retrieves a property value from the current feature's state. Returns - /// null if the requested property is not present on the feature's state. - /// A feature's state is not part of the GeoJSON or vector tile data, and - /// must be set programmatically on each feature. Features are identified - /// by their `id` attribute, which must be an integer or a string that - /// can be cast to an integer. Note that ["feature-state"] can only be - /// used with paint properties that support data-driven styling. - static const featureState = "feature-state"; - - /// Gets the feature's geometry type: Point, MultiPoint, LineString, - /// MultiLineString, Polygon, MultiPolygon. - static const geometryType = "geometry-type"; - - /// Gets the feature's id, if it has one. - static const id = "id"; - - /// Gets the current zoom level. Note that in style layout and paint - /// properties, ["zoom"] may only appear as the input to a top-level - /// "step" or "interpolate" expression. - static const zoom = "zoom"; - - /// Gets the kernel density estimation of a pixel in a heatmap layer, - /// which is a relative measure of how many data points are crowded - /// around a particular pixel. Can only be used in the `heatmap-color` - /// property. - static const heatmapDensity = "heatmap-density"; - - /// Gets the progress along a gradient line. Can only be used in the - /// `line-gradient` property. - static const lineProgress = "line-progress"; - - /// Gets the value of a cluster property accumulated so far. Can only be - /// used in the `clusterProperties` option of a clustered GeoJSON source. - static const accumulated = "accumulated"; - - /// Returns the sum of the inputs. - static const plus = "+"; - - /// Returns the product of the inputs. - static const multiply = "*"; - - /// For two inputs, returns the result of subtracting the second input - /// from the first. For a single input, returns the result of subtracting - /// it from 0. - static const minus = "-"; - - /// Returns the result of floating point division of the first input by - /// the second. - static const divide = "/"; - - /// Returns the remainder after integer division of the first input by - /// the second. - static const precent = "%"; - - /// Returns the result of raising the first input to the power specified - /// by the second. - static const xor = "^"; - - /// Returns the square root of the input. - static const sqrt = "sqrt"; - - /// Returns the base-ten logarithm of the input. - static const log10 = "log10"; - - /// Returns the natural logarithm of the input. - static const ln = "ln"; - - /// Returns the base-two logarithm of the input. - static const log2 = "log2"; - - /// Returns the sine of the input. - static const sin = "sin"; - - /// Returns the cosine of the input. - static const cos = "cos"; - - /// Returns the tangent of the input. - static const tan = "tan"; - - /// Returns the arcsine of the input. - static const asin = "asin"; - - /// Returns the arccosine of the input. - static const acos = "acos"; - - /// Returns the arctangent of the input. - static const atan = "atan"; - - /// Returns the minimum value of the inputs. - static const min = "min"; - - /// Returns the maximum value of the inputs. - static const max = "max"; - - /// Rounds the input to the nearest integer. Halfway values are rounded - /// away from zero. For example, `["round", -1.5]` evaluates to -2. - static const round = "round"; - - /// Returns the absolute value of the input. - static const abs = "abs"; - - /// Returns the smallest integer that is greater than or equal to the - /// input. - static const ceil = "ceil"; - - /// Returns the largest integer that is less than or equal to the input. - static const floor = "floor"; - - /// Returns `true` if the input values are equal, `false` otherwise. The - /// comparison is strictly typed: values of different runtime types are - /// always considered unequal. Cases where the types are known to be - /// different at parse time are considered invalid and will produce a - /// parse error. Accepts an optional `collator` argument to control - /// locale-dependent string comparisons. - static const equal = "=="; - - /// Returns `true` if the input values are not equal, `false` otherwise. - /// The comparison is strictly typed: values of different runtime types - /// are always considered unequal. Cases where the types are known to be - /// different at parse time are considered invalid and will produce a - /// parse error. Accepts an optional `collator` argument to control - /// locale-dependent string comparisons. - static const notEqual = "!="; - - /// Returns `true` if the first input is strictly greater than the - /// second, `false` otherwise. The arguments are required to be either - /// both strings or both numbers; if during evaluation they are not, - /// expression evaluation produces an error. Cases where this constraint - /// is known not to hold at parse time are considered in valid and will - /// produce a parse error. Accepts an optional `collator` argument to - /// control locale-dependent string comparisons. - static const larger = ">"; - - /// Returns `true` if the first input is strictly less than the second, - /// `false` otherwise. The arguments are required to be either both - /// strings or both numbers; if during evaluation they are not, - /// expression evaluation produces an error. Cases where this constraint - /// is known not to hold at parse time are considered in valid and will - /// produce a parse error. Accepts an optional `collator` argument to - /// control locale-dependent string comparisons. - static const smaller = "<"; - - /// Returns `true` if the first input is greater than or equal to the - /// second, `false` otherwise. The arguments are required to be either - /// both strings or both numbers; if during evaluation they are not, - /// expression evaluation produces an error. Cases where this constraint - /// is known not to hold at parse time are considered in valid and will - /// produce a parse error. Accepts an optional `collator` argument to - /// control locale-dependent string comparisons. - static const largerOrEqual = ">="; - - /// Returns `true` if the first input is less than or equal to the - /// second, `false` otherwise. The arguments are required to be either - /// both strings or both numbers; if during evaluation they are not, - /// expression evaluation produces an error. Cases where this constraint - /// is known not to hold at parse time are considered in valid and will - /// produce a parse error. Accepts an optional `collator` argument to - /// control locale-dependent string comparisons. - static const smallerOrEqual = "<="; - - /// Returns `true` if all the inputs are `true`, `false` otherwise. The - /// inputs are evaluated in order, and evaluation is short-circuiting: - /// once an input expression evaluates to `false`, the result is `false` - /// and no further input expressions are evaluated. - static const all = "all"; - - /// Returns `true` if any of the inputs are `true`, `false` otherwise. - /// The inputs are evaluated in order, and evaluation is - /// short-circuiting: once an input expression evaluates to `true`, the - /// result is `true` and no further input expressions are evaluated. - static const any = "any"; - - /// Logical negation. Returns `true` if the input is `false`, and `false` - /// if the input is `true`. - static const not = "!"; - - /// Returns `true` if the input string is expected to render legibly. - /// Returns `false` if the input string contains sections that cannot be - /// rendered without potential loss of meaning (e.g. Indic scripts that - /// require complex text shaping, or right-to-left scripts if the the - /// `mapbox-gl-rtl-text` plugin is not in use in Mapbox GL JS). - static const isSupportedScript = "is-supported-script"; - - /// Returns the input string converted to uppercase. Follows the Unicode - /// Default Case Conversion algorithm and the locale-insensitive case - /// mappings in the Unicode Character Database. - static const upcase = "upcase"; - - /// Returns the input string converted to lowercase. Follows the Unicode - /// Default Case Conversion algorithm and the locale-insensitive case - /// mappings in the Unicode Character Database. - static const downcase = "downcase"; - - /// Returns a `string` consisting of the concatenation of the inputs. - /// Each input is converted to a string as if by `to-string`. - static const concat = "concat"; - - /// Returns the IETF language tag of the locale being used by the - /// provided `collator`. This can be used to determine the default system - /// locale, or to determine if a requested locale was successfully - /// loaded. - static const resolvedLocale = "resolved-locale"; - -} diff --git a/lib/src/layer_properties.dart b/lib/src/layer_properties.dart new file mode 100644 index 000000000..3a9474a2a --- /dev/null +++ b/lib/src/layer_properties.dart @@ -0,0 +1,1750 @@ +// This file is generated by +// ./scripts/lib/generate.dart + +part of mapbox_gl; + +class SymbolLayerProperties{ + // Paint Properties + /// The opacity at which the icon will be drawn. + /// + /// Type: number + /// default: 1 + /// minimum: 0 + /// maximum: 1 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic iconOpacity; + + /// The color of the icon. This can only be used with sdf icons. + /// + /// Type: color + /// default: #000000 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic iconColor; + + /// The color of the icon's halo. Icon halos can only be used with SDF + /// icons. + /// + /// Type: color + /// default: rgba(0, 0, 0, 0) + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic iconHaloColor; + + /// Distance of halo to the icon outline. + /// + /// Type: number + /// default: 0 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic iconHaloWidth; + + /// Fade out the halo towards the outside. + /// + /// Type: number + /// default: 0 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic 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. + /// + /// Type: array + /// default: [0, 0] + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconTranslate; + + /// Controls the frame of reference for `icon-translate`. + /// + /// Type: enum + /// default: map + /// Options: + /// map + /// Icons are translated relative to the map. + /// viewport + /// Icons are translated relative to the viewport. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconTranslateAnchor; + + /// The opacity at which the text will be drawn. + /// + /// Type: number + /// default: 1 + /// minimum: 0 + /// maximum: 1 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textOpacity; + + /// The color with which the text will be drawn. + /// + /// Type: color + /// default: #000000 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textColor; + + /// The color of the text's halo, which helps it stand out from + /// backgrounds. + /// + /// Type: color + /// default: rgba(0, 0, 0, 0) + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textHaloColor; + + /// Distance of halo to the font outline. Max text halo width is 1/4 of + /// the font-size. + /// + /// Type: number + /// default: 0 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textHaloWidth; + + /// The halo's fadeout distance towards the outside. + /// + /// Type: number + /// default: 0 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic 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. + /// + /// Type: array + /// default: [0, 0] + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textTranslate; + + /// Controls the frame of reference for `text-translate`. + /// + /// Type: enum + /// default: map + /// Options: + /// map + /// The text is translated relative to the map. + /// viewport + /// The text is translated relative to the viewport. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textTranslateAnchor; + + // Layout Properties + /// Label placement relative to its geometry. + /// + /// Type: enum + /// default: point + /// Options: + /// point + /// The label is placed at the point where the geometry is located. + /// line + /// The label is placed along the line of the geometry. Can only be + /// used on `LineString` and `Polygon` geometries. + /// line-center + /// The label is placed at the center of the line of the geometry. + /// Can only be used on `LineString` and `Polygon` geometries. Note + /// that a single feature in a vector tile may contain multiple line + /// geometries. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic symbolPlacement; + + /// Distance between two symbol anchors. + /// + /// Type: number + /// default: 250 + /// minimum: 1 + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic 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. When using a client that + /// supports global collision detection, like Mapbox GL JS version 0.42.0 + /// or greater, enabling this property is not needed to prevent clipped + /// labels at tile boundaries. + /// + /// Type: boolean + /// default: false + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic symbolAvoidEdges; + + /// Sorts features in ascending order based on this value. Features with + /// lower sort keys are drawn and placed first. When `icon-allow-overlap` + /// or `text-allow-overlap` is `false`, features with a lower sort key + /// will have priority during placement. When `icon-allow-overlap` or + /// `text-allow-overlap` is set to `true`, features with a higher sort key + /// will overlap over features with a lower sort key. + /// + /// Type: number + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic symbolSortKey; + + /// Controls the order in which overlapping symbols in the same layer are + /// rendered + /// + /// Type: enum + /// default: auto + /// Options: + /// auto + /// If `symbol-sort-key` is set, sort based on that. Otherwise sort + /// symbols by their y-position relative to the viewport. + /// viewport-y + /// Symbols will be sorted by their y-position relative to the + /// viewport. + /// source + /// Symbols will be rendered in the same order as the source data + /// with no sorting applied. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic symbolZOrder; + + /// If true, the icon will be visible even if it collides with other + /// previously drawn symbols. + /// + /// Type: boolean + /// default: false + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconAllowOverlap; + + /// If true, other symbols can be visible even if they collide with the + /// icon. + /// + /// Type: boolean + /// default: false + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconIgnorePlacement; + + /// If true, text will display without their corresponding icons when the + /// icon collides with other symbols and the text does not. + /// + /// Type: boolean + /// default: false + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconOptional; + + /// In combination with `symbol-placement`, determines the rotation + /// behavior of icons. + /// + /// Type: enum + /// default: auto + /// Options: + /// map + /// When `symbol-placement` is set to `point`, aligns icons + /// east-west. When `symbol-placement` is set to `line` or + /// `line-center`, aligns icon x-axes with the line. + /// viewport + /// Produces icons whose x-axes are aligned with the x-axis of the + /// viewport, regardless of the value of `symbol-placement`. + /// auto + /// When `symbol-placement` is set to `point`, this is equivalent to + /// `viewport`. When `symbol-placement` is set to `line` or + /// `line-center`, this is equivalent to `map`. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconRotationAlignment; + + /// Scales the original size of the icon by the provided factor. The new + /// pixel size of the image will be the original pixel size multiplied by + /// `icon-size`. 1 is the original size; 3 triples the size of the image. + /// + /// Type: number + /// default: 1 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic iconSize; + + /// Scales the icon to fit around the associated text. + /// + /// Type: enum + /// default: none + /// Options: + /// none + /// The icon is displayed at its intrinsic aspect ratio. + /// width + /// The icon is scaled in the x-dimension to fit the width of the + /// text. + /// height + /// The icon is scaled in the y-dimension to fit the height of the + /// text. + /// both + /// The icon is scaled in both x- and y-dimensions. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconTextFit; + + /// Size of the additional area added to dimensions determined by + /// `icon-text-fit`, in clockwise order: top, right, bottom, left. + /// + /// Type: array + /// default: [0, 0, 0, 0] + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconTextFitPadding; + + /// Name of image in sprite to use for drawing an image background. + /// + /// Type: resolvedImage + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic iconImage; + + /// Rotates the icon clockwise. + /// + /// Type: number + /// default: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic iconRotate; + + /// Size of the additional area around the icon bounding box used for + /// detecting symbol collisions. + /// + /// Type: number + /// default: 2 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconPadding; + + /// If true, the icon may be flipped to prevent it from being rendered + /// upside-down. + /// + /// Type: boolean + /// default: false + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconKeepUpright; + + /// Offset distance of icon from its anchor. Positive values indicate + /// right and down, while negative values indicate left and up. Each + /// component is multiplied by the value of `icon-size` to obtain the + /// final offset in pixels. When combined with `icon-rotate` the offset + /// will be as if the rotated direction was up. + /// + /// Type: array + /// default: [0, 0] + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic iconOffset; + + /// Part of the icon placed closest to the anchor. + /// + /// Type: enum + /// default: center + /// Options: + /// center + /// The center of the icon is placed closest to the anchor. + /// left + /// The left side of the icon is placed closest to the anchor. + /// right + /// The right side of the icon is placed closest to the anchor. + /// top + /// The top of the icon is placed closest to the anchor. + /// bottom + /// The bottom of the icon is placed closest to the anchor. + /// top-left + /// The top left corner of the icon is placed closest to the anchor. + /// top-right + /// The top right corner of the icon is placed closest to the anchor. + /// bottom-left + /// The bottom left corner of the icon is placed closest to the + /// anchor. + /// bottom-right + /// The bottom right corner of the icon is placed closest to the + /// anchor. + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic iconAnchor; + + /// Orientation of icon when map is pitched. + /// + /// Type: enum + /// default: auto + /// Options: + /// map + /// The icon is aligned to the plane of the map. + /// viewport + /// The icon is aligned to the plane of the viewport. + /// auto + /// Automatically matches the value of `icon-rotation-alignment`. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic iconPitchAlignment; + + /// Orientation of text when map is pitched. + /// + /// Type: enum + /// default: auto + /// Options: + /// map + /// The text is aligned to the plane of the map. + /// viewport + /// The text is aligned to the plane of the viewport. + /// auto + /// Automatically matches the value of `text-rotation-alignment`. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textPitchAlignment; + + /// In combination with `symbol-placement`, determines the rotation + /// behavior of the individual glyphs forming the text. + /// + /// Type: enum + /// default: auto + /// Options: + /// map + /// When `symbol-placement` is set to `point`, aligns text east-west. + /// When `symbol-placement` is set to `line` or `line-center`, aligns + /// text x-axes with the line. + /// viewport + /// Produces glyphs whose x-axes are aligned with the x-axis of the + /// viewport, regardless of the value of `symbol-placement`. + /// auto + /// When `symbol-placement` is set to `point`, this is equivalent to + /// `viewport`. When `symbol-placement` is set to `line` or + /// `line-center`, this is equivalent to `map`. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textRotationAlignment; + + /// Value to use for a text label. If a plain `string` is provided, it + /// will be treated as a `formatted` with default/inherited formatting + /// options. + /// + /// Type: formatted + /// default: + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textField; + + /// Font stack to use for displaying text. + /// + /// Type: array + /// default: [Open Sans Regular, Arial Unicode MS Regular] + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textFont; + + /// Font size. + /// + /// Type: number + /// default: 16 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textSize; + + /// The maximum line width for text wrapping. + /// + /// Type: number + /// default: 10 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textMaxWidth; + + /// Text leading value for multi-line text. + /// + /// Type: number + /// default: 1.2 + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textLineHeight; + + /// Text tracking amount. + /// + /// Type: number + /// default: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textLetterSpacing; + + /// Text justification options. + /// + /// Type: enum + /// default: center + /// Options: + /// auto + /// The text is aligned towards the anchor position. + /// left + /// The text is aligned to the left. + /// center + /// The text is centered. + /// right + /// The text is aligned to the right. + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textJustify; + + /// Radial offset of text, in the direction of the symbol's anchor. Useful + /// in combination with `text-variable-anchor`, which defaults to using + /// the two-dimensional `text-offset` if present. + /// + /// Type: number + /// default: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textRadialOffset; + + /// To increase the chance of placing high-priority labels on the map, you + /// can provide an array of `text-anchor` locations: the renderer will + /// attempt to place the label at each location, in order, before moving + /// onto the next label. Use `text-justify: auto` to choose justification + /// based on anchor position. To apply an offset, use the + /// `text-radial-offset` or the two-dimensional `text-offset`. + /// + /// Type: array + /// Options: + /// center + /// The center of the text is placed closest to the anchor. + /// left + /// The left side of the text is placed closest to the anchor. + /// right + /// The right side of the text is placed closest to the anchor. + /// top + /// The top of the text is placed closest to the anchor. + /// bottom + /// The bottom of the text is placed closest to the anchor. + /// top-left + /// The top left corner of the text is placed closest to the anchor. + /// top-right + /// The top right corner of the text is placed closest to the anchor. + /// bottom-left + /// The bottom left corner of the text is placed closest to the + /// anchor. + /// bottom-right + /// The bottom right corner of the text is placed closest to the + /// anchor. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textVariableAnchor; + + /// Part of the text placed closest to the anchor. + /// + /// Type: enum + /// default: center + /// Options: + /// center + /// The center of the text is placed closest to the anchor. + /// left + /// The left side of the text is placed closest to the anchor. + /// right + /// The right side of the text is placed closest to the anchor. + /// top + /// The top of the text is placed closest to the anchor. + /// bottom + /// The bottom of the text is placed closest to the anchor. + /// top-left + /// The top left corner of the text is placed closest to the anchor. + /// top-right + /// The top right corner of the text is placed closest to the anchor. + /// bottom-left + /// The bottom left corner of the text is placed closest to the + /// anchor. + /// bottom-right + /// The bottom right corner of the text is placed closest to the + /// anchor. + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textAnchor; + + /// Maximum angle change between adjacent characters. + /// + /// Type: number + /// default: 45 + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textMaxAngle; + + /// The property allows control over a symbol's orientation. Note that the + /// property values act as a hint, so that a symbol whose language doesn’t + /// support the provided orientation will be laid out in its natural + /// orientation. Example: English point symbol will be rendered + /// horizontally even if array value contains single 'vertical' enum + /// value. The order of elements in an array define priority order for the + /// placement of an orientation variant. + /// + /// Type: array + /// Options: + /// horizontal + /// If a text's language supports horizontal writing mode, symbols + /// with point placement would be laid out horizontally. + /// vertical + /// If a text's language supports vertical writing mode, symbols with + /// point placement would be laid out vertically. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textWritingMode; + + /// Rotates the text clockwise. + /// + /// Type: number + /// default: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textRotate; + + /// Size of the additional area around the text bounding box used for + /// detecting symbol collisions. + /// + /// Type: number + /// default: 2 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textPadding; + + /// If true, the text may be flipped vertically to prevent it from being + /// rendered upside-down. + /// + /// Type: boolean + /// default: true + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textKeepUpright; + + /// Specifies how to capitalize text, similar to the CSS `text-transform` + /// property. + /// + /// Type: enum + /// default: none + /// Options: + /// none + /// The text is not altered. + /// uppercase + /// Forces all letters to be displayed in uppercase. + /// lowercase + /// Forces all letters to be displayed in lowercase. + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textTransform; + + /// Offset distance of text from its anchor. Positive values indicate + /// right and down, while negative values indicate left and up. If used + /// with text-variable-anchor, input values will be taken as absolute + /// values. Offsets along the x- and y-axis will be applied automatically + /// based on the anchor position. + /// + /// Type: array + /// default: [0, 0] + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic textOffset; + + /// If true, the text will be visible even if it collides with other + /// previously drawn symbols. + /// + /// Type: boolean + /// default: false + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textAllowOverlap; + + /// If true, other symbols can be visible even if they collide with the + /// text. + /// + /// Type: boolean + /// default: false + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textIgnorePlacement; + + /// If true, icons will display without their corresponding text when the + /// text collides with other symbols and the icon does not. + /// + /// Type: boolean + /// default: false + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic textOptional; + + /// Whether this layer is displayed. + /// + /// Type: enum + /// default: visible + /// Options: + /// visible + /// The layer is shown. + /// none + /// The layer is not shown. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic visibility; + + const SymbolLayerProperties({ + this.iconOpacity, + this.iconColor, + this.iconHaloColor, + this.iconHaloWidth, + this.iconHaloBlur, + this.iconTranslate, + this.iconTranslateAnchor, + this.textOpacity, + this.textColor, + this.textHaloColor, + this.textHaloWidth, + this.textHaloBlur, + this.textTranslate, + this.textTranslateAnchor, + this.symbolPlacement, + this.symbolSpacing, + this.symbolAvoidEdges, + this.symbolSortKey, + this.symbolZOrder, + this.iconAllowOverlap, + this.iconIgnorePlacement, + this.iconOptional, + this.iconRotationAlignment, + this.iconSize, + this.iconTextFit, + this.iconTextFitPadding, + this.iconImage, + this.iconRotate, + this.iconPadding, + this.iconKeepUpright, + this.iconOffset, + this.iconAnchor, + this.iconPitchAlignment, + this.textPitchAlignment, + this.textRotationAlignment, + this.textField, + this.textFont, + this.textSize, + this.textMaxWidth, + this.textLineHeight, + this.textLetterSpacing, + this.textJustify, + this.textRadialOffset, + this.textVariableAnchor, + this.textAnchor, + this.textMaxAngle, + this.textWritingMode, + this.textRotate, + this.textPadding, + this.textKeepUpright, + this.textTransform, + this.textOffset, + this.textAllowOverlap, + this.textIgnorePlacement, + this.textOptional, + this.visibility, + }); + + SymbolLayerProperties copyWith(SymbolLayerProperties changes) { + return SymbolLayerProperties( + iconOpacity: changes.iconOpacity ?? iconOpacity, + iconColor: changes.iconColor ?? iconColor, + iconHaloColor: changes.iconHaloColor ?? iconHaloColor, + iconHaloWidth: changes.iconHaloWidth ?? iconHaloWidth, + iconHaloBlur: changes.iconHaloBlur ?? iconHaloBlur, + iconTranslate: changes.iconTranslate ?? iconTranslate, + iconTranslateAnchor: changes.iconTranslateAnchor ?? iconTranslateAnchor, + textOpacity: changes.textOpacity ?? textOpacity, + textColor: changes.textColor ?? textColor, + textHaloColor: changes.textHaloColor ?? textHaloColor, + textHaloWidth: changes.textHaloWidth ?? textHaloWidth, + textHaloBlur: changes.textHaloBlur ?? textHaloBlur, + textTranslate: changes.textTranslate ?? textTranslate, + textTranslateAnchor: changes.textTranslateAnchor ?? textTranslateAnchor, + symbolPlacement: changes.symbolPlacement ?? symbolPlacement, + symbolSpacing: changes.symbolSpacing ?? symbolSpacing, + symbolAvoidEdges: changes.symbolAvoidEdges ?? symbolAvoidEdges, + symbolSortKey: changes.symbolSortKey ?? symbolSortKey, + symbolZOrder: changes.symbolZOrder ?? symbolZOrder, + iconAllowOverlap: changes.iconAllowOverlap ?? iconAllowOverlap, + iconIgnorePlacement: changes.iconIgnorePlacement ?? iconIgnorePlacement, + iconOptional: changes.iconOptional ?? iconOptional, + iconRotationAlignment: changes.iconRotationAlignment ?? iconRotationAlignment, + iconSize: changes.iconSize ?? iconSize, + iconTextFit: changes.iconTextFit ?? iconTextFit, + iconTextFitPadding: changes.iconTextFitPadding ?? iconTextFitPadding, + iconImage: changes.iconImage ?? iconImage, + iconRotate: changes.iconRotate ?? iconRotate, + iconPadding: changes.iconPadding ?? iconPadding, + iconKeepUpright: changes.iconKeepUpright ?? iconKeepUpright, + iconOffset: changes.iconOffset ?? iconOffset, + iconAnchor: changes.iconAnchor ?? iconAnchor, + iconPitchAlignment: changes.iconPitchAlignment ?? iconPitchAlignment, + textPitchAlignment: changes.textPitchAlignment ?? textPitchAlignment, + textRotationAlignment: changes.textRotationAlignment ?? textRotationAlignment, + textField: changes.textField ?? textField, + textFont: changes.textFont ?? textFont, + textSize: changes.textSize ?? textSize, + textMaxWidth: changes.textMaxWidth ?? textMaxWidth, + textLineHeight: changes.textLineHeight ?? textLineHeight, + textLetterSpacing: changes.textLetterSpacing ?? textLetterSpacing, + textJustify: changes.textJustify ?? textJustify, + textRadialOffset: changes.textRadialOffset ?? textRadialOffset, + textVariableAnchor: changes.textVariableAnchor ?? textVariableAnchor, + textAnchor: changes.textAnchor ?? textAnchor, + textMaxAngle: changes.textMaxAngle ?? textMaxAngle, + textWritingMode: changes.textWritingMode ?? textWritingMode, + textRotate: changes.textRotate ?? textRotate, + textPadding: changes.textPadding ?? textPadding, + textKeepUpright: changes.textKeepUpright ?? textKeepUpright, + textTransform: changes.textTransform ?? textTransform, + textOffset: changes.textOffset ?? textOffset, + textAllowOverlap: changes.textAllowOverlap ?? textAllowOverlap, + textIgnorePlacement: changes.textIgnorePlacement ?? textIgnorePlacement, + textOptional: changes.textOptional ?? textOptional, + visibility: changes.visibility ?? visibility, + ); + } + + Map toJson() { + final Map json = {}; + + void addIfPresent(String fieldName, dynamic value) { + if (value != null) { + json[fieldName] = value; + } + } + + addIfPresent('icon-opacity', iconOpacity); + addIfPresent('icon-color', iconColor); + addIfPresent('icon-halo-color', iconHaloColor); + addIfPresent('icon-halo-width', iconHaloWidth); + addIfPresent('icon-halo-blur', iconHaloBlur); + addIfPresent('icon-translate', iconTranslate); + addIfPresent('icon-translate-anchor', iconTranslateAnchor); + addIfPresent('text-opacity', textOpacity); + addIfPresent('text-color', textColor); + addIfPresent('text-halo-color', textHaloColor); + addIfPresent('text-halo-width', textHaloWidth); + addIfPresent('text-halo-blur', textHaloBlur); + addIfPresent('text-translate', textTranslate); + addIfPresent('text-translate-anchor', textTranslateAnchor); + addIfPresent('symbol-placement', symbolPlacement); + addIfPresent('symbol-spacing', symbolSpacing); + addIfPresent('symbol-avoid-edges', symbolAvoidEdges); + addIfPresent('symbol-sort-key', symbolSortKey); + addIfPresent('symbol-z-order', symbolZOrder); + addIfPresent('icon-allow-overlap', iconAllowOverlap); + addIfPresent('icon-ignore-placement', iconIgnorePlacement); + addIfPresent('icon-optional', iconOptional); + addIfPresent('icon-rotation-alignment', iconRotationAlignment); + addIfPresent('icon-size', iconSize); + addIfPresent('icon-text-fit', iconTextFit); + addIfPresent('icon-text-fit-padding', iconTextFitPadding); + addIfPresent('icon-image', iconImage); + addIfPresent('icon-rotate', iconRotate); + addIfPresent('icon-padding', iconPadding); + addIfPresent('icon-keep-upright', iconKeepUpright); + addIfPresent('icon-offset', iconOffset); + addIfPresent('icon-anchor', iconAnchor); + addIfPresent('icon-pitch-alignment', iconPitchAlignment); + addIfPresent('text-pitch-alignment', textPitchAlignment); + addIfPresent('text-rotation-alignment', textRotationAlignment); + addIfPresent('text-field', textField); + addIfPresent('text-font', textFont); + addIfPresent('text-size', textSize); + addIfPresent('text-max-width', textMaxWidth); + addIfPresent('text-line-height', textLineHeight); + addIfPresent('text-letter-spacing', textLetterSpacing); + addIfPresent('text-justify', textJustify); + addIfPresent('text-radial-offset', textRadialOffset); + addIfPresent('text-variable-anchor', textVariableAnchor); + addIfPresent('text-anchor', textAnchor); + addIfPresent('text-max-angle', textMaxAngle); + addIfPresent('text-writing-mode', textWritingMode); + addIfPresent('text-rotate', textRotate); + addIfPresent('text-padding', textPadding); + addIfPresent('text-keep-upright', textKeepUpright); + addIfPresent('text-transform', textTransform); + addIfPresent('text-offset', textOffset); + addIfPresent('text-allow-overlap', textAllowOverlap); + addIfPresent('text-ignore-placement', textIgnorePlacement); + addIfPresent('text-optional', textOptional); + addIfPresent('visibility', visibility); + return json; + } + + factory SymbolLayerProperties.fromJson(Map json) { + return SymbolLayerProperties( + iconOpacity: json['icon-opacity'], + iconColor: json['icon-color'], + iconHaloColor: json['icon-halo-color'], + iconHaloWidth: json['icon-halo-width'], + iconHaloBlur: json['icon-halo-blur'], + iconTranslate: json['icon-translate'], + iconTranslateAnchor: json['icon-translate-anchor'], + textOpacity: json['text-opacity'], + textColor: json['text-color'], + textHaloColor: json['text-halo-color'], + textHaloWidth: json['text-halo-width'], + textHaloBlur: json['text-halo-blur'], + textTranslate: json['text-translate'], + textTranslateAnchor: json['text-translate-anchor'], + symbolPlacement: json['symbol-placement'], + symbolSpacing: json['symbol-spacing'], + symbolAvoidEdges: json['symbol-avoid-edges'], + symbolSortKey: json['symbol-sort-key'], + symbolZOrder: json['symbol-z-order'], + iconAllowOverlap: json['icon-allow-overlap'], + iconIgnorePlacement: json['icon-ignore-placement'], + iconOptional: json['icon-optional'], + iconRotationAlignment: json['icon-rotation-alignment'], + iconSize: json['icon-size'], + iconTextFit: json['icon-text-fit'], + iconTextFitPadding: json['icon-text-fit-padding'], + iconImage: json['icon-image'], + iconRotate: json['icon-rotate'], + iconPadding: json['icon-padding'], + iconKeepUpright: json['icon-keep-upright'], + iconOffset: json['icon-offset'], + iconAnchor: json['icon-anchor'], + iconPitchAlignment: json['icon-pitch-alignment'], + textPitchAlignment: json['text-pitch-alignment'], + textRotationAlignment: json['text-rotation-alignment'], + textField: json['text-field'], + textFont: json['text-font'], + textSize: json['text-size'], + textMaxWidth: json['text-max-width'], + textLineHeight: json['text-line-height'], + textLetterSpacing: json['text-letter-spacing'], + textJustify: json['text-justify'], + textRadialOffset: json['text-radial-offset'], + textVariableAnchor: json['text-variable-anchor'], + textAnchor: json['text-anchor'], + textMaxAngle: json['text-max-angle'], + textWritingMode: json['text-writing-mode'], + textRotate: json['text-rotate'], + textPadding: json['text-padding'], + textKeepUpright: json['text-keep-upright'], + textTransform: json['text-transform'], + textOffset: json['text-offset'], + textAllowOverlap: json['text-allow-overlap'], + textIgnorePlacement: json['text-ignore-placement'], + textOptional: json['text-optional'], + visibility: json['visibility'], + ); + } + +} + +class CircleLayerProperties{ + // Paint Properties + /// Circle radius. + /// + /// Type: number + /// default: 5 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic circleRadius; + + /// The fill color of the circle. + /// + /// Type: color + /// default: #000000 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic circleColor; + + /// Amount to blur the circle. 1 blurs the circle such that only the + /// centerpoint is full opacity. + /// + /// Type: number + /// default: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic circleBlur; + + /// The opacity at which the circle will be drawn. + /// + /// Type: number + /// default: 1 + /// minimum: 0 + /// maximum: 1 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic circleOpacity; + + /// The geometry's offset. Values are [x, y] where negatives indicate left + /// and up, respectively. + /// + /// Type: array + /// default: [0, 0] + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic circleTranslate; + + /// Controls the frame of reference for `circle-translate`. + /// + /// Type: enum + /// default: map + /// Options: + /// map + /// The circle is translated relative to the map. + /// viewport + /// The circle is translated relative to the viewport. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic circleTranslateAnchor; + + /// Controls the scaling behavior of the circle when the map is pitched. + /// + /// Type: enum + /// default: map + /// Options: + /// map + /// Circles are scaled according to their apparent distance to the + /// camera. + /// viewport + /// Circles are not scaled. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic circlePitchScale; + + /// Orientation of circle when map is pitched. + /// + /// Type: enum + /// default: viewport + /// Options: + /// map + /// The circle is aligned to the plane of the map. + /// viewport + /// The circle is aligned to the plane of the viewport. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic circlePitchAlignment; + + /// The width of the circle's stroke. Strokes are placed outside of the + /// `circle-radius`. + /// + /// Type: number + /// default: 0 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic circleStrokeWidth; + + /// The stroke color of the circle. + /// + /// Type: color + /// default: #000000 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic circleStrokeColor; + + /// The opacity of the circle's stroke. + /// + /// Type: number + /// default: 1 + /// minimum: 0 + /// maximum: 1 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic circleStrokeOpacity; + + // Layout Properties + /// Sorts features in ascending order based on this value. Features with a + /// higher sort key will appear above features with a lower sort key. + /// + /// Type: number + /// + /// Sdk Support + /// basic functionality with js + /// data-driven styling with js + final dynamic circleSortKey; + + /// Whether this layer is displayed. + /// + /// Type: enum + /// default: visible + /// Options: + /// visible + /// The layer is shown. + /// none + /// The layer is not shown. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic visibility; + + const CircleLayerProperties({ + this.circleRadius, + this.circleColor, + this.circleBlur, + this.circleOpacity, + this.circleTranslate, + this.circleTranslateAnchor, + this.circlePitchScale, + this.circlePitchAlignment, + this.circleStrokeWidth, + this.circleStrokeColor, + this.circleStrokeOpacity, + this.circleSortKey, + this.visibility, + }); + + CircleLayerProperties copyWith(CircleLayerProperties changes) { + return CircleLayerProperties( + circleRadius: changes.circleRadius ?? circleRadius, + circleColor: changes.circleColor ?? circleColor, + circleBlur: changes.circleBlur ?? circleBlur, + circleOpacity: changes.circleOpacity ?? circleOpacity, + circleTranslate: changes.circleTranslate ?? circleTranslate, + circleTranslateAnchor: changes.circleTranslateAnchor ?? circleTranslateAnchor, + circlePitchScale: changes.circlePitchScale ?? circlePitchScale, + circlePitchAlignment: changes.circlePitchAlignment ?? circlePitchAlignment, + circleStrokeWidth: changes.circleStrokeWidth ?? circleStrokeWidth, + circleStrokeColor: changes.circleStrokeColor ?? circleStrokeColor, + circleStrokeOpacity: changes.circleStrokeOpacity ?? circleStrokeOpacity, + circleSortKey: changes.circleSortKey ?? circleSortKey, + visibility: changes.visibility ?? visibility, + ); + } + + Map toJson() { + final Map json = {}; + + void addIfPresent(String fieldName, dynamic value) { + if (value != null) { + json[fieldName] = value; + } + } + + addIfPresent('circle-radius', circleRadius); + addIfPresent('circle-color', circleColor); + addIfPresent('circle-blur', circleBlur); + addIfPresent('circle-opacity', circleOpacity); + addIfPresent('circle-translate', circleTranslate); + addIfPresent('circle-translate-anchor', circleTranslateAnchor); + addIfPresent('circle-pitch-scale', circlePitchScale); + addIfPresent('circle-pitch-alignment', circlePitchAlignment); + addIfPresent('circle-stroke-width', circleStrokeWidth); + addIfPresent('circle-stroke-color', circleStrokeColor); + addIfPresent('circle-stroke-opacity', circleStrokeOpacity); + addIfPresent('circle-sort-key', circleSortKey); + addIfPresent('visibility', visibility); + return json; + } + + factory CircleLayerProperties.fromJson(Map json) { + return CircleLayerProperties( + circleRadius: json['circle-radius'], + circleColor: json['circle-color'], + circleBlur: json['circle-blur'], + circleOpacity: json['circle-opacity'], + circleTranslate: json['circle-translate'], + circleTranslateAnchor: json['circle-translate-anchor'], + circlePitchScale: json['circle-pitch-scale'], + circlePitchAlignment: json['circle-pitch-alignment'], + circleStrokeWidth: json['circle-stroke-width'], + circleStrokeColor: json['circle-stroke-color'], + circleStrokeOpacity: json['circle-stroke-opacity'], + circleSortKey: json['circle-sort-key'], + visibility: json['visibility'], + ); + } + +} + +class LineLayerProperties{ + // Paint Properties + /// The opacity at which the line will be drawn. + /// + /// Type: number + /// default: 1 + /// minimum: 0 + /// maximum: 1 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic lineOpacity; + + /// The color with which the line will be drawn. + /// + /// Type: color + /// default: #000000 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic lineColor; + + /// The geometry's offset. Values are [x, y] where negatives indicate left + /// and up, respectively. + /// + /// Type: array + /// default: [0, 0] + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic lineTranslate; + + /// Controls the frame of reference for `line-translate`. + /// + /// Type: enum + /// default: map + /// Options: + /// map + /// The line is translated relative to the map. + /// viewport + /// The line is translated relative to the viewport. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic lineTranslateAnchor; + + /// Stroke thickness. + /// + /// Type: number + /// default: 1 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic lineWidth; + + /// Draws a line casing outside of a line's actual path. Value indicates + /// the width of the inner gap. + /// + /// Type: number + /// default: 0 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic lineGapWidth; + + /// The line's offset. For linear features, a positive value offsets the + /// line to the right, relative to the direction of the line, and a + /// negative value to the left. For polygon features, a positive value + /// results in an inset, and a negative value results in an outset. + /// + /// Type: number + /// default: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic lineOffset; + + /// Blur applied to the line, in pixels. + /// + /// Type: number + /// default: 0 + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic 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. Note that GeoJSON sources with `lineMetrics: true` + /// specified won't render dashed lines to the expected scale. Also note + /// that zoom-dependent expressions will be evaluated only at integer zoom + /// levels. + /// + /// Type: array + /// minimum: 0 + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic 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). + /// Note that zoom-dependent expressions will be evaluated only at integer + /// zoom levels. + /// + /// Type: resolvedImage + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android macos ios + final dynamic linePattern; + + /// Defines a gradient with which to color a line feature. Can only be + /// used with GeoJSON sources that specify `"lineMetrics": true`. + /// + /// Type: color + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic lineGradient; + + // Layout Properties + /// The display of line endings. + /// + /// Type: enum + /// default: butt + /// Options: + /// butt + /// A cap with a squared-off end which is drawn to the exact endpoint + /// of the line. + /// round + /// A cap with a rounded end which is drawn beyond the endpoint of + /// the line at a radius of one-half of the line's width and centered + /// on the endpoint of the line. + /// square + /// A cap with a squared-off end which is drawn beyond the endpoint + /// of the line at a distance of one-half of the line's width. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic lineCap; + + /// The display of lines when joining. + /// + /// Type: enum + /// default: miter + /// Options: + /// bevel + /// A join with a squared-off end which is drawn beyond the endpoint + /// of the line at a distance of one-half of the line's width. + /// round + /// A join with a rounded end which is drawn beyond the endpoint of + /// the line at a radius of one-half of the line's width and centered + /// on the endpoint of the line. + /// miter + /// A join with a sharp, angled corner which is drawn with the outer + /// sides beyond the endpoint of the path until they meet. + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic lineJoin; + + /// Used to automatically convert miter joins to bevel joins for sharp + /// angles. + /// + /// Type: number + /// default: 2 + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic lineMiterLimit; + + /// Used to automatically convert round joins to miter joins for shallow + /// angles. + /// + /// Type: number + /// default: 1.05 + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic lineRoundLimit; + + /// Sorts features in ascending order based on this value. Features with a + /// higher sort key will appear above features with a lower sort key. + /// + /// Type: number + /// + /// Sdk Support + /// basic functionality with js + /// data-driven styling with js + final dynamic lineSortKey; + + /// Whether this layer is displayed. + /// + /// Type: enum + /// default: visible + /// Options: + /// visible + /// The layer is shown. + /// none + /// The layer is not shown. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic visibility; + + const LineLayerProperties({ + this.lineOpacity, + this.lineColor, + this.lineTranslate, + this.lineTranslateAnchor, + this.lineWidth, + this.lineGapWidth, + this.lineOffset, + this.lineBlur, + this.lineDasharray, + this.linePattern, + this.lineGradient, + this.lineCap, + this.lineJoin, + this.lineMiterLimit, + this.lineRoundLimit, + this.lineSortKey, + this.visibility, + }); + + LineLayerProperties copyWith(LineLayerProperties changes) { + return LineLayerProperties( + lineOpacity: changes.lineOpacity ?? lineOpacity, + lineColor: changes.lineColor ?? lineColor, + lineTranslate: changes.lineTranslate ?? lineTranslate, + lineTranslateAnchor: changes.lineTranslateAnchor ?? lineTranslateAnchor, + lineWidth: changes.lineWidth ?? lineWidth, + lineGapWidth: changes.lineGapWidth ?? lineGapWidth, + lineOffset: changes.lineOffset ?? lineOffset, + lineBlur: changes.lineBlur ?? lineBlur, + lineDasharray: changes.lineDasharray ?? lineDasharray, + linePattern: changes.linePattern ?? linePattern, + lineGradient: changes.lineGradient ?? lineGradient, + lineCap: changes.lineCap ?? lineCap, + lineJoin: changes.lineJoin ?? lineJoin, + lineMiterLimit: changes.lineMiterLimit ?? lineMiterLimit, + lineRoundLimit: changes.lineRoundLimit ?? lineRoundLimit, + lineSortKey: changes.lineSortKey ?? lineSortKey, + visibility: changes.visibility ?? visibility, + ); + } + + Map toJson() { + final Map json = {}; + + void addIfPresent(String fieldName, dynamic value) { + if (value != null) { + json[fieldName] = value; + } + } + + addIfPresent('line-opacity', lineOpacity); + addIfPresent('line-color', lineColor); + addIfPresent('line-translate', lineTranslate); + addIfPresent('line-translate-anchor', lineTranslateAnchor); + addIfPresent('line-width', lineWidth); + addIfPresent('line-gap-width', lineGapWidth); + addIfPresent('line-offset', lineOffset); + addIfPresent('line-blur', lineBlur); + addIfPresent('line-dasharray', lineDasharray); + addIfPresent('line-pattern', linePattern); + addIfPresent('line-gradient', lineGradient); + addIfPresent('line-cap', lineCap); + addIfPresent('line-join', lineJoin); + addIfPresent('line-miter-limit', lineMiterLimit); + addIfPresent('line-round-limit', lineRoundLimit); + addIfPresent('line-sort-key', lineSortKey); + addIfPresent('visibility', visibility); + return json; + } + + factory LineLayerProperties.fromJson(Map json) { + return LineLayerProperties( + lineOpacity: json['line-opacity'], + lineColor: json['line-color'], + lineTranslate: json['line-translate'], + lineTranslateAnchor: json['line-translate-anchor'], + lineWidth: json['line-width'], + lineGapWidth: json['line-gap-width'], + lineOffset: json['line-offset'], + lineBlur: json['line-blur'], + lineDasharray: json['line-dasharray'], + linePattern: json['line-pattern'], + lineGradient: json['line-gradient'], + lineCap: json['line-cap'], + lineJoin: json['line-join'], + lineMiterLimit: json['line-miter-limit'], + lineRoundLimit: json['line-round-limit'], + lineSortKey: json['line-sort-key'], + visibility: json['visibility'], + ); + } + +} + +class FillLayerProperties{ + // Paint Properties + /// Whether or not the fill should be antialiased. + /// + /// Type: boolean + /// default: true + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic 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. + /// + /// Type: number + /// default: 1 + /// minimum: 0 + /// maximum: 1 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic 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. + /// + /// Type: color + /// default: #000000 + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic fillColor; + + /// The outline color of the fill. Matches the value of `fill-color` if + /// unspecified. + /// + /// Type: color + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android ios macos + final dynamic fillOutlineColor; + + /// The geometry's offset. Values are [x, y] where negatives indicate left + /// and up, respectively. + /// + /// Type: array + /// default: [0, 0] + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic fillTranslate; + + /// Controls the frame of reference for `fill-translate`. + /// + /// Type: enum + /// default: map + /// Options: + /// map + /// The fill is translated relative to the map. + /// viewport + /// The fill is translated relative to the viewport. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic 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). Note that zoom-dependent expressions will be evaluated only + /// at integer zoom levels. + /// + /// Type: resolvedImage + /// + /// Sdk Support + /// basic functionality with js android ios macos + /// data-driven styling with js android macos ios + final dynamic fillPattern; + + // Layout Properties + /// Sorts features in ascending order based on this value. Features with a + /// higher sort key will appear above features with a lower sort key. + /// + /// Type: number + /// + /// Sdk Support + /// basic functionality with js + /// data-driven styling with js + final dynamic fillSortKey; + + /// Whether this layer is displayed. + /// + /// Type: enum + /// default: visible + /// Options: + /// visible + /// The layer is shown. + /// none + /// The layer is not shown. + /// + /// Sdk Support + /// basic functionality with js android ios macos + final dynamic visibility; + + const FillLayerProperties({ + this.fillAntialias, + this.fillOpacity, + this.fillColor, + this.fillOutlineColor, + this.fillTranslate, + this.fillTranslateAnchor, + this.fillPattern, + this.fillSortKey, + this.visibility, + }); + + FillLayerProperties copyWith(FillLayerProperties changes) { + return FillLayerProperties( + fillAntialias: changes.fillAntialias ?? fillAntialias, + fillOpacity: changes.fillOpacity ?? fillOpacity, + fillColor: changes.fillColor ?? fillColor, + fillOutlineColor: changes.fillOutlineColor ?? fillOutlineColor, + fillTranslate: changes.fillTranslate ?? fillTranslate, + fillTranslateAnchor: changes.fillTranslateAnchor ?? fillTranslateAnchor, + fillPattern: changes.fillPattern ?? fillPattern, + fillSortKey: changes.fillSortKey ?? fillSortKey, + visibility: changes.visibility ?? visibility, + ); + } + + Map toJson() { + final Map json = {}; + + void addIfPresent(String fieldName, dynamic value) { + if (value != null) { + json[fieldName] = value; + } + } + + addIfPresent('fill-antialias', fillAntialias); + addIfPresent('fill-opacity', fillOpacity); + addIfPresent('fill-color', fillColor); + addIfPresent('fill-outline-color', fillOutlineColor); + addIfPresent('fill-translate', fillTranslate); + addIfPresent('fill-translate-anchor', fillTranslateAnchor); + addIfPresent('fill-pattern', fillPattern); + addIfPresent('fill-sort-key', fillSortKey); + addIfPresent('visibility', visibility); + return json; + } + + factory FillLayerProperties.fromJson(Map json) { + return FillLayerProperties( + fillAntialias: json['fill-antialias'], + fillOpacity: json['fill-opacity'], + fillColor: json['fill-color'], + fillOutlineColor: json['fill-outline-color'], + fillTranslate: json['fill-translate'], + fillTranslateAnchor: json['fill-translate-anchor'], + fillPattern: json['fill-pattern'], + fillSortKey: json['fill-sort-key'], + visibility: json['visibility'], + ); + } + +} + + diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index 7982e3d98..9a17982c5 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -25,65 +25,50 @@ main() async { 'expressions': buildExpressionProperties(styleJson) }; + // required for deduplication renderContext["all_layout_properties"] = [ for (final type in renderContext["layerTypes"]!) ...type["layout_properties"].map((p) => p["value"]).toList() ].toSet().map((p) => {"property": p}).toList(); - print("generating java"); - await renderLayerPropertyConverter( + await render( renderContext, - "java", - './android/src/main/java/com/mapbox/mapboxgl/LayerPropertyConverter.java', + "android/src/main/java/com/mapbox/mapboxgl", + "LayerPropertyConverter.java", ); - print("generating swift"); - await renderLayerPropertyConverter( + await render( renderContext, - "swift", - "./ios/Classes/LayerPropertyConverter.swift", + "ios/Classes", + "LayerPropertyConverter.swift", + ); + await render( + renderContext, + "lib/src", + "layer_expressions.dart", + ); + await render( + renderContext, + "lib/src", + "layer_properties.dart", + ); + await render( + renderContext, + "mapbox_gl_web/lib/src", + "layer_tools.dart", ); - - print("generating dart"); - await renderDart(renderContext); - await renderWebDart(renderContext); } -Future renderLayerPropertyConverter( +Future render( Map renderContext, - String templateType, String outputPath, + String filename, ) async { - var templateFile = await File( - './scripts/templates/LayerPropertyConverter.$templateType.template') - .readAsString(); - - var template = Template(templateFile); - var outputFile = File(outputPath); - - outputFile.writeAsString(template.renderString(renderContext)); -} - -Future renderDart( - Map renderContext, -) async { + print("Rendering $filename"); var templateFile = - await File('./scripts/templates/layer_helper.dart.template') - .readAsString(); + await File('./scripts/templates/$filename.template').readAsString(); var template = Template(templateFile); - var outputFile = File("./lib/src/layer_helper.dart"); - - outputFile.writeAsString(template.renderString(renderContext)); -} - -Future renderWebDart( - Map renderContext, -) async { - var templateFile = await File('./scripts/templates/layer_tools.dart.template') - .readAsString(); - - var template = Template(templateFile); - var outputFile = File("./mapbox_gl_web/lib/src/layer_tools.dart"); + var outputFile = File('$outputPath/$filename'); outputFile.writeAsString(template.renderString(renderContext)); } @@ -140,22 +125,63 @@ Map buildStyleProperty( 'isIosAsCamelCase': renamedIosProperties.containsKey(camelCase), 'iosAsCamelCase': renamedIosProperties[camelCase], 'doc': value["doc"], - 'docSplit': - buildDocLines(value["doc"], 70).map((s) => {"part": s}).toList(), + 'docSplit': buildDocSplit(value).map((s) => {"part": s}).toList(), 'valueAsCamelCase': camelCase }; } -List buildDocLines(String input, int lineLength) { +List buildDocSplit(Map item) { + final defaultValue = item["default"]; + final maxValue = item["maximum"]; + final minValue = item["minimum"]; + final type = item["type"]; + final Map? sdkSupport = item["sdk-support"]; + + final Map? values = item["values"]; + final result = splitIntoChunks(item["doc"]!, 70); + if (type != null) { + result.add(""); + result.add("Type: $type"); + if (defaultValue != null) result.add(" default: $defaultValue"); + if (minValue != null) result.add(" minimum: $minValue"); + if (maxValue != null) result.add(" maximum: $maxValue"); + if (values != null) { + result.add("Options:"); + for (var value in values.entries) { + result.add(" ${value.key}"); + result.addAll( + splitIntoChunks("${value.value["doc"]}", 70, prefix: " ")); + } + } + } + if (sdkSupport != null) { + final Map? basic = sdkSupport["basic functionality"]; + final Map? dataDriven = sdkSupport["data-driven styling"]; + + result.add(""); + result.add("Sdk Support"); + if (basic != null && basic.isNotEmpty) { + result.add(" basic functionality with " + basic.keys.join(" ")); + } + if (dataDriven != null && dataDriven.isNotEmpty) { + result.add(" data-driven styling with " + dataDriven.keys.join(" ")); + } + } + + return result; +} + +List splitIntoChunks(String input, int lineLength, + {String prefix = ""}) { final words = input.split(" "); final chunks = []; String chunk = ""; for (var word in words) { - final nextChunk = chunk + " " + word; + final nextChunk = chunk.length == 0 ? prefix + word : chunk + " " + word; if (nextChunk.length > lineLength || chunk.endsWith("\n")) { chunks.add(chunk.replaceAll("\n", "")); - chunk = " " + word; + chunk = prefix + word; } else { chunk = nextChunk; } @@ -193,9 +219,7 @@ List> buildExpressionProperties( .map((e) => { 'value': e.key, 'doc': e.value["doc"], - 'docSplit': buildDocLines(e.value["doc"], 70) - .map((s) => {"part": s}) - .toList(), + 'docSplit': buildDocSplit(e.value).map((s) => {"part": s}).toList(), 'valueAsCamelCase': new ReCase(renamed[e.key] ?? e.key).camelCase }) .toList(); diff --git a/scripts/templates/layer_expressions.dart.template b/scripts/templates/layer_expressions.dart.template new file mode 100644 index 000000000..8ea98d4b9 --- /dev/null +++ b/scripts/templates/layer_expressions.dart.template @@ -0,0 +1,14 @@ +// This file is generated by +// ./scripts/lib/generate.dart + +part of mapbox_gl; + +class Expressions{ + {{#expressions}} + {{#docSplit}} + /// {{{part}}} + {{/docSplit}} + static const {{valueAsCamelCase}} = "{{{value}}}"; + + {{/expressions}} +} diff --git a/scripts/templates/layer_helper.dart.template b/scripts/templates/layer_helper.dart.template deleted file mode 100644 index 145eecb73..000000000 --- a/scripts/templates/layer_helper.dart.template +++ /dev/null @@ -1,40 +0,0 @@ -// This file is generated by -// ./scripts/lib/generate.dart - -part of mapbox_gl; -{{#layerTypes}} - - -class {{typePascal}}Properties{ - // Paint Properties - {{#paint_properties}} - {{#docSplit}} - /// {{{part}}} - {{/docSplit}} - static const {{valueAsCamelCase}} = "{{{value}}}"; - - {{/paint_properties}} - - // Layout Properties - {{#layout_properties}} - {{#docSplit}} - /// {{{part}}} - {{/docSplit}} - static const {{valueAsCamelCase}} = "{{{value}}}"; - - {{/layout_properties}} -} -{{/layerTypes}} - - - - -class Expressions{ - {{#expressions}} - {{#docSplit}} - ///{{{part}}} - {{/docSplit}} - static const {{valueAsCamelCase}} = "{{{value}}}"; - - {{/expressions}} -} diff --git a/scripts/templates/layer_properties.dart.template b/scripts/templates/layer_properties.dart.template new file mode 100644 index 000000000..40569fc1f --- /dev/null +++ b/scripts/templates/layer_properties.dart.template @@ -0,0 +1,76 @@ +// This file is generated by +// ./scripts/lib/generate.dart + +part of mapbox_gl; +{{#layerTypes}} + +class {{typePascal}}LayerProperties{ + // Paint Properties + {{#paint_properties}} + {{#docSplit}} + /// {{{part}}} + {{/docSplit}} + final dynamic {{valueAsCamelCase}}; + + {{/paint_properties}} + // Layout Properties + {{#layout_properties}} + {{#docSplit}} + /// {{{part}}} + {{/docSplit}} + final dynamic {{valueAsCamelCase}}; + + {{/layout_properties}} + const {{typePascal}}LayerProperties({ + {{#paint_properties}} + this.{{valueAsCamelCase}}, + {{/paint_properties}} + {{#layout_properties}} + this.{{valueAsCamelCase}}, + {{/layout_properties}} + }); + + {{typePascal}}LayerProperties copyWith({{typePascal}}LayerProperties changes) { + return {{typePascal}}LayerProperties( + {{#paint_properties}} + {{valueAsCamelCase}}: changes.{{valueAsCamelCase}} ?? {{valueAsCamelCase}}, + {{/paint_properties}} + {{#layout_properties}} + {{valueAsCamelCase}}: changes.{{valueAsCamelCase}} ?? {{valueAsCamelCase}}, + {{/layout_properties}} + ); + } + + Map toJson() { + final Map json = {}; + + void addIfPresent(String fieldName, dynamic value) { + if (value != null) { + json[fieldName] = value; + } + } + + {{#paint_properties}} + addIfPresent('{{value}}', {{valueAsCamelCase}}); + {{/paint_properties}} + {{#layout_properties}} + addIfPresent('{{value}}', {{valueAsCamelCase}}); + {{/layout_properties}} + return json; + } + + factory {{typePascal}}LayerProperties.fromJson(Map json) { + return {{typePascal}}LayerProperties( + {{#paint_properties}} + {{valueAsCamelCase}}: json['{{value}}'], + {{/paint_properties}} + {{#layout_properties}} + {{valueAsCamelCase}}: json['{{value}}'], + {{/layout_properties}} + ); + } + +} +{{/layerTypes}} + + From 93ebafd391f429cef107beb5d5d3f44e679c8744 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Mon, 25 Oct 2021 12:01:40 +0200 Subject: [PATCH 17/33] fixed doc issue --- lib/src/layer_properties.dart | 180 +++++++++--------- scripts/lib/generate.dart | 2 +- .../templates/layer_properties.dart.template | 2 +- 3 files changed, 92 insertions(+), 92 deletions(-) diff --git a/lib/src/layer_properties.dart b/lib/src/layer_properties.dart index 3a9474a2a..3c52a7346 100644 --- a/lib/src/layer_properties.dart +++ b/lib/src/layer_properties.dart @@ -3,7 +3,7 @@ part of mapbox_gl; -class SymbolLayerProperties{ +class SymbolLayerProperties { // Paint Properties /// The opacity at which the icon will be drawn. /// @@ -76,9 +76,9 @@ class SymbolLayerProperties{ /// Type: enum /// default: map /// Options: - /// map + /// "map" /// Icons are translated relative to the map. - /// viewport + /// "viewport" /// Icons are translated relative to the viewport. /// /// Sdk Support @@ -157,9 +157,9 @@ class SymbolLayerProperties{ /// Type: enum /// default: map /// Options: - /// map + /// "map" /// The text is translated relative to the map. - /// viewport + /// "viewport" /// The text is translated relative to the viewport. /// /// Sdk Support @@ -172,12 +172,12 @@ class SymbolLayerProperties{ /// Type: enum /// default: point /// Options: - /// point + /// "point" /// The label is placed at the point where the geometry is located. - /// line + /// "line" /// The label is placed along the line of the geometry. Can only be /// used on `LineString` and `Polygon` geometries. - /// line-center + /// "line-center" /// The label is placed at the center of the line of the geometry. /// Can only be used on `LineString` and `Polygon` geometries. Note /// that a single feature in a vector tile may contain multiple line @@ -232,13 +232,13 @@ class SymbolLayerProperties{ /// Type: enum /// default: auto /// Options: - /// auto + /// "auto" /// If `symbol-sort-key` is set, sort based on that. Otherwise sort /// symbols by their y-position relative to the viewport. - /// viewport-y + /// "viewport-y" /// Symbols will be sorted by their y-position relative to the /// viewport. - /// source + /// "source" /// Symbols will be rendered in the same order as the source data /// with no sorting applied. /// @@ -282,14 +282,14 @@ class SymbolLayerProperties{ /// Type: enum /// default: auto /// Options: - /// map + /// "map" /// When `symbol-placement` is set to `point`, aligns icons /// east-west. When `symbol-placement` is set to `line` or /// `line-center`, aligns icon x-axes with the line. - /// viewport + /// "viewport" /// Produces icons whose x-axes are aligned with the x-axis of the /// viewport, regardless of the value of `symbol-placement`. - /// auto + /// "auto" /// When `symbol-placement` is set to `point`, this is equivalent to /// `viewport`. When `symbol-placement` is set to `line` or /// `line-center`, this is equivalent to `map`. @@ -316,15 +316,15 @@ class SymbolLayerProperties{ /// Type: enum /// default: none /// Options: - /// none + /// "none" /// The icon is displayed at its intrinsic aspect ratio. - /// width + /// "width" /// The icon is scaled in the x-dimension to fit the width of the /// text. - /// height + /// "height" /// The icon is scaled in the y-dimension to fit the height of the /// text. - /// both + /// "both" /// The icon is scaled in both x- and y-dimensions. /// /// Sdk Support @@ -400,24 +400,24 @@ class SymbolLayerProperties{ /// Type: enum /// default: center /// Options: - /// center + /// "center" /// The center of the icon is placed closest to the anchor. - /// left + /// "left" /// The left side of the icon is placed closest to the anchor. - /// right + /// "right" /// The right side of the icon is placed closest to the anchor. - /// top + /// "top" /// The top of the icon is placed closest to the anchor. - /// bottom + /// "bottom" /// The bottom of the icon is placed closest to the anchor. - /// top-left + /// "top-left" /// The top left corner of the icon is placed closest to the anchor. - /// top-right + /// "top-right" /// The top right corner of the icon is placed closest to the anchor. - /// bottom-left + /// "bottom-left" /// The bottom left corner of the icon is placed closest to the /// anchor. - /// bottom-right + /// "bottom-right" /// The bottom right corner of the icon is placed closest to the /// anchor. /// @@ -431,11 +431,11 @@ class SymbolLayerProperties{ /// Type: enum /// default: auto /// Options: - /// map + /// "map" /// The icon is aligned to the plane of the map. - /// viewport + /// "viewport" /// The icon is aligned to the plane of the viewport. - /// auto + /// "auto" /// Automatically matches the value of `icon-rotation-alignment`. /// /// Sdk Support @@ -447,11 +447,11 @@ class SymbolLayerProperties{ /// Type: enum /// default: auto /// Options: - /// map + /// "map" /// The text is aligned to the plane of the map. - /// viewport + /// "viewport" /// The text is aligned to the plane of the viewport. - /// auto + /// "auto" /// Automatically matches the value of `text-rotation-alignment`. /// /// Sdk Support @@ -464,14 +464,14 @@ class SymbolLayerProperties{ /// Type: enum /// default: auto /// Options: - /// map + /// "map" /// When `symbol-placement` is set to `point`, aligns text east-west. /// When `symbol-placement` is set to `line` or `line-center`, aligns /// text x-axes with the line. - /// viewport + /// "viewport" /// Produces glyphs whose x-axes are aligned with the x-axis of the /// viewport, regardless of the value of `symbol-placement`. - /// auto + /// "auto" /// When `symbol-placement` is set to `point`, this is equivalent to /// `viewport`. When `symbol-placement` is set to `line` or /// `line-center`, this is equivalent to `map`. @@ -548,13 +548,13 @@ class SymbolLayerProperties{ /// Type: enum /// default: center /// Options: - /// auto + /// "auto" /// The text is aligned towards the anchor position. - /// left + /// "left" /// The text is aligned to the left. - /// center + /// "center" /// The text is centered. - /// right + /// "right" /// The text is aligned to the right. /// /// Sdk Support @@ -583,24 +583,24 @@ class SymbolLayerProperties{ /// /// Type: array /// Options: - /// center + /// "center" /// The center of the text is placed closest to the anchor. - /// left + /// "left" /// The left side of the text is placed closest to the anchor. - /// right + /// "right" /// The right side of the text is placed closest to the anchor. - /// top + /// "top" /// The top of the text is placed closest to the anchor. - /// bottom + /// "bottom" /// The bottom of the text is placed closest to the anchor. - /// top-left + /// "top-left" /// The top left corner of the text is placed closest to the anchor. - /// top-right + /// "top-right" /// The top right corner of the text is placed closest to the anchor. - /// bottom-left + /// "bottom-left" /// The bottom left corner of the text is placed closest to the /// anchor. - /// bottom-right + /// "bottom-right" /// The bottom right corner of the text is placed closest to the /// anchor. /// @@ -613,24 +613,24 @@ class SymbolLayerProperties{ /// Type: enum /// default: center /// Options: - /// center + /// "center" /// The center of the text is placed closest to the anchor. - /// left + /// "left" /// The left side of the text is placed closest to the anchor. - /// right + /// "right" /// The right side of the text is placed closest to the anchor. - /// top + /// "top" /// The top of the text is placed closest to the anchor. - /// bottom + /// "bottom" /// The bottom of the text is placed closest to the anchor. - /// top-left + /// "top-left" /// The top left corner of the text is placed closest to the anchor. - /// top-right + /// "top-right" /// The top right corner of the text is placed closest to the anchor. - /// bottom-left + /// "bottom-left" /// The bottom left corner of the text is placed closest to the /// anchor. - /// bottom-right + /// "bottom-right" /// The bottom right corner of the text is placed closest to the /// anchor. /// @@ -658,10 +658,10 @@ class SymbolLayerProperties{ /// /// Type: array /// Options: - /// horizontal + /// "horizontal" /// If a text's language supports horizontal writing mode, symbols /// with point placement would be laid out horizontally. - /// vertical + /// "vertical" /// If a text's language supports vertical writing mode, symbols with /// point placement would be laid out vertically. /// @@ -706,11 +706,11 @@ class SymbolLayerProperties{ /// Type: enum /// default: none /// Options: - /// none + /// "none" /// The text is not altered. - /// uppercase + /// "uppercase" /// Forces all letters to be displayed in uppercase. - /// lowercase + /// "lowercase" /// Forces all letters to be displayed in lowercase. /// /// Sdk Support @@ -767,9 +767,9 @@ class SymbolLayerProperties{ /// Type: enum /// default: visible /// Options: - /// visible + /// "visible" /// The layer is shown. - /// none + /// "none" /// The layer is not shown. /// /// Sdk Support @@ -1027,7 +1027,7 @@ class SymbolLayerProperties{ } -class CircleLayerProperties{ +class CircleLayerProperties { // Paint Properties /// Circle radius. /// @@ -1088,9 +1088,9 @@ class CircleLayerProperties{ /// Type: enum /// default: map /// Options: - /// map + /// "map" /// The circle is translated relative to the map. - /// viewport + /// "viewport" /// The circle is translated relative to the viewport. /// /// Sdk Support @@ -1102,10 +1102,10 @@ class CircleLayerProperties{ /// Type: enum /// default: map /// Options: - /// map + /// "map" /// Circles are scaled according to their apparent distance to the /// camera. - /// viewport + /// "viewport" /// Circles are not scaled. /// /// Sdk Support @@ -1117,9 +1117,9 @@ class CircleLayerProperties{ /// Type: enum /// default: viewport /// Options: - /// map + /// "map" /// The circle is aligned to the plane of the map. - /// viewport + /// "viewport" /// The circle is aligned to the plane of the viewport. /// /// Sdk Support @@ -1176,9 +1176,9 @@ class CircleLayerProperties{ /// Type: enum /// default: visible /// Options: - /// visible + /// "visible" /// The layer is shown. - /// none + /// "none" /// The layer is not shown. /// /// Sdk Support @@ -1264,7 +1264,7 @@ class CircleLayerProperties{ } -class LineLayerProperties{ +class LineLayerProperties { // Paint Properties /// The opacity at which the line will be drawn. /// @@ -1303,9 +1303,9 @@ class LineLayerProperties{ /// Type: enum /// default: map /// Options: - /// map + /// "map" /// The line is translated relative to the map. - /// viewport + /// "viewport" /// The line is translated relative to the viewport. /// /// Sdk Support @@ -1401,14 +1401,14 @@ class LineLayerProperties{ /// Type: enum /// default: butt /// Options: - /// butt + /// "butt" /// A cap with a squared-off end which is drawn to the exact endpoint /// of the line. - /// round + /// "round" /// A cap with a rounded end which is drawn beyond the endpoint of /// the line at a radius of one-half of the line's width and centered /// on the endpoint of the line. - /// square + /// "square" /// A cap with a squared-off end which is drawn beyond the endpoint /// of the line at a distance of one-half of the line's width. /// @@ -1421,14 +1421,14 @@ class LineLayerProperties{ /// Type: enum /// default: miter /// Options: - /// bevel + /// "bevel" /// A join with a squared-off end which is drawn beyond the endpoint /// of the line at a distance of one-half of the line's width. - /// round + /// "round" /// A join with a rounded end which is drawn beyond the endpoint of /// the line at a radius of one-half of the line's width and centered /// on the endpoint of the line. - /// miter + /// "miter" /// A join with a sharp, angled corner which is drawn with the outer /// sides beyond the endpoint of the path until they meet. /// @@ -1472,9 +1472,9 @@ class LineLayerProperties{ /// Type: enum /// default: visible /// Options: - /// visible + /// "visible" /// The layer is shown. - /// none + /// "none" /// The layer is not shown. /// /// Sdk Support @@ -1576,7 +1576,7 @@ class LineLayerProperties{ } -class FillLayerProperties{ +class FillLayerProperties { // Paint Properties /// Whether or not the fill should be antialiased. /// @@ -1638,9 +1638,9 @@ class FillLayerProperties{ /// Type: enum /// default: map /// Options: - /// map + /// "map" /// The fill is translated relative to the map. - /// viewport + /// "viewport" /// The fill is translated relative to the viewport. /// /// Sdk Support @@ -1675,9 +1675,9 @@ class FillLayerProperties{ /// Type: enum /// default: visible /// Options: - /// visible + /// "visible" /// The layer is shown. - /// none + /// "none" /// The layer is not shown. /// /// Sdk Support diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index 9a17982c5..f2edd9676 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -148,7 +148,7 @@ List buildDocSplit(Map item) { if (values != null) { result.add("Options:"); for (var value in values.entries) { - result.add(" ${value.key}"); + result.add(" \"${value.key}\""); result.addAll( splitIntoChunks("${value.value["doc"]}", 70, prefix: " ")); } diff --git a/scripts/templates/layer_properties.dart.template b/scripts/templates/layer_properties.dart.template index 40569fc1f..7b500ccda 100644 --- a/scripts/templates/layer_properties.dart.template +++ b/scripts/templates/layer_properties.dart.template @@ -4,7 +4,7 @@ part of mapbox_gl; {{#layerTypes}} -class {{typePascal}}LayerProperties{ +class {{typePascal}}LayerProperties { // Paint Properties {{#paint_properties}} {{#docSplit}} From ea6a5c92371bfaea8da74b336b625a5086322d2d Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Mon, 25 Oct 2021 19:52:43 +0200 Subject: [PATCH 18/33] added click support for ios, android, and web --- .../mapbox/mapboxgl/MapboxMapController.java | 42 +- example/lib/layer.dart | 57 +- ios/Classes/MapboxMapController.swift | 41 +- lib/src/controller.dart | 39 +- lib/src/layer_properties.dart | 498 +++++++++--------- .../lib/src/mapbox_gl_platform_interface.dart | 2 + .../lib/src/method_channel_mapbox_gl.dart | 18 +- .../lib/src/mapbox_map_controller.dart | 24 +- scripts/lib/generate.dart | 1 - .../templates/layer_properties.dart.template | 6 +- 10 files changed, 401 insertions(+), 327 deletions(-) diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index 9dfc74057..acdefd014 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -90,6 +90,8 @@ import java.io.InputStream; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; import java.util.List; import java.util.ArrayList; import java.util.Map; @@ -150,6 +152,7 @@ final class MapboxMapController private Style style; private List annotationOrder; private List annotationConsumeTapEvents; + private Set featureLayerIdentifiers; MapboxMapController( int id, @@ -166,6 +169,7 @@ final class MapboxMapController this.context = context; this.styleStringInitial = styleStringInitial; this.mapView = new MapView(context, options); + this.featureLayerIdentifiers = new HashSet<>(); this.symbols = new HashMap<>(); this.lines = new HashMap<>(); this.circles = new HashMap<>(); @@ -401,10 +405,10 @@ private void addSymbolLayer(String layerName, PropertyValue[] properties, Expression filter) { SymbolLayer symbolLayer = new SymbolLayer(layerName, sourceName); - symbolLayer.setProperties(properties); style.addLayer(symbolLayer); + featureLayerIdentifiers.add(layerName); } private void addLineLayer(String layerName, @@ -412,10 +416,10 @@ private void addLineLayer(String layerName, PropertyValue[] properties, Expression filter) { LineLayer lineLayer = new LineLayer(layerName, sourceName); - lineLayer.setProperties(properties); style.addLayer(lineLayer); + featureLayerIdentifiers.add(layerName); } private void addFillLayer(String layerName, @@ -423,10 +427,10 @@ private void addFillLayer(String layerName, PropertyValue[] properties, Expression filter) { FillLayer fillLayer = new FillLayer(layerName, sourceName); - fillLayer.setProperties(properties); style.addLayer(fillLayer); + featureLayerIdentifiers.add(layerName); } private void addCircleLayer(String layerName, @@ -434,9 +438,9 @@ private void addCircleLayer(String layerName, PropertyValue[] properties, Expression filter) { CircleLayer circleLayer = new CircleLayer(layerName, sourceName); - circleLayer.setProperties(properties); + featureLayerIdentifiers.add(layerName); style.addLayer(circleLayer); } @@ -1076,7 +1080,10 @@ public void onFailure(@NonNull Exception exception) { if (style == null) { result.error("STYLE IS NULL", "The style is null. Has onStyleLoaded() already been invoked?", null); } - style.removeLayer((String) call.argument("imageLayerId")); + String layerId = call.argument("layerId"); + style.removeLayer((String) call.argument("layerId")); + featureLayerIdentifiers.remove(layerId); + result.success(null); break; } @@ -1187,12 +1194,25 @@ public void onFillTapped(Fill fill) { @Override public boolean onMapClick(@NonNull LatLng point) { PointF pointf = mapboxMap.getProjection().toScreenLocation(point); - final Map arguments = new HashMap<>(5); - arguments.put("x", pointf.x); - arguments.put("y", pointf.y); - arguments.put("lng", point.getLongitude()); - arguments.put("lat", point.getLatitude()); - methodChannel.invokeMethod("map#onMapClick", arguments); + RectF rectF = new RectF( + pointf.x - 10, + pointf.y - 10, + pointf.x + 10, + pointf.y + 10 + ); + List featureList = mapboxMap.queryRenderedFeatures(rectF, featureLayerIdentifiers.toArray(new String[0])); + if(!featureList.isEmpty()){ + final Map arguments = new HashMap<>(1); + arguments.put("featureId", featureList.get(featureList.size() - 1).id()); + methodChannel.invokeMethod("feature#onTap", arguments); + } else { + final Map arguments = new HashMap<>(5); + arguments.put("x", pointf.x); + arguments.put("y", pointf.y); + arguments.put("lng", point.getLongitude()); + arguments.put("lat", point.getLatitude()); + methodChannel.invokeMethod("map#onMapClick", arguments); + } return true; } diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 1dea6539b..483bb758c 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -22,30 +22,35 @@ class LayerState extends State { @override Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Center( - child: SizedBox( - width: 300.0, - height: 500.0, - child: MapboxMap( - accessToken: MapsDemo.ACCESS_TOKEN, - onMapCreated: _onMapCreated, - onStyleLoadedCallback: _onStyleLoadedCallback, - initialCameraPosition: CameraPosition( - target: center, - zoom: 11.0, - ), - ), - ), - ), - ]); + return MapboxMap( + accessToken: MapsDemo.ACCESS_TOKEN, + onMapCreated: _onMapCreated, + onMapClick: (point, latLong) => + print(point.toString() + latLong.toString()), + onStyleLoadedCallback: _onStyleLoadedCallback, + initialCameraPosition: CameraPosition( + target: center, + zoom: 11.0, + ), + ); } void _onMapCreated(MapboxMapController controller) { this.controller = controller; + + controller.onFeatureTapped.add(onFeatureTap); + } + + void onFeatureTap(dynamic featureId) { + final snackBar = SnackBar( + content: Text( + 'Tapped feature with id $featureId', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + backgroundColor: Theme.of(context).primaryColor, + ); + ScaffoldMessenger.of(context).clearSnackBars(); + ScaffoldMessenger.of(context).showSnackBar(snackBar); } void _onStyleLoadedCallback() { @@ -101,12 +106,13 @@ class LayerState extends State { } } -const _fills = { +final _fills = { "type": "FeatureCollection", "features": [ { "type": "Feature", - "properties": {}, + "id": 0, // web currently only supports number ids + "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ @@ -130,7 +136,8 @@ const _fills = { }, { "type": "Feature", - "properties": {}, + "id": 1, + "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ @@ -152,6 +159,7 @@ const _points = { "features": [ { "type": "Feature", + "id": 2, "properties": { "type": "restaurant", }, @@ -162,6 +170,7 @@ const _points = { }, { "type": "Feature", + "id": 3, "properties": { "type": "airport", }, @@ -172,6 +181,7 @@ const _points = { }, { "type": "Feature", + "id": 4, "properties": { "type": "bakery", }, @@ -182,6 +192,7 @@ const _points = { }, { "type": "Feature", + "id": 5, "properties": { "type": "college", }, diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index 021b6b133..dd1a10042 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -25,6 +25,8 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma private var annotationOrder = [String]() private var annotationConsumeTapEvents = [String]() + private var featureLayerIdentifiers = Set() + func view() -> UIView { return mapView } @@ -728,28 +730,30 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma let layer = MGLRasterStyleLayer(identifier: imageLayerId, source: source) self.mapView.style?.insertLayer(layer, below: belowLayer) result(nil) + case "style#removeLayer": guard let arguments = methodCall.arguments as? [String: Any] else { return } - guard let imageLayerId = arguments["imageLayerId"] as? String else { return } - guard let layer = self.mapView.style?.layer(withIdentifier: imageLayerId) else { return } + guard let layerId = arguments["layerId"] as? String else { return } + guard let layer = self.mapView.style?.layer(withIdentifier: layerId) else { return } + featureLayerIdentifiers.remove(layerId) self.mapView.style?.removeLayer(layer) + result(nil) + case "source#addGeoJson": guard let arguments = methodCall.arguments as? [String: Any] else { return } guard let sourceId = arguments["sourceId"] as? String else { return } guard let geojson = arguments["geojson"] as? String else { return } - addSource(sourceId: sourceId, geojson: geojson) - result(nil) + case "lineLayer#add": guard let arguments = methodCall.arguments as? [String: Any] else { return } guard let sourceId = arguments["sourceId"] as? String else { return } guard let layerId = arguments["layerId"] as? String else { return } guard let properties = arguments["properties"] as? [String: String] else { return } - addLineLayer(sourceId: sourceId, layerId: layerId, properties: properties) - result(nil) + default: result(FlutterMethodNotImplemented) } @@ -805,12 +809,21 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma // Get the CGPoint where the user tapped. let point = sender.location(in: mapView) let coordinate = mapView.convert(point, toCoordinateFrom: mapView) - channel?.invokeMethod("map#onMapClick", arguments: [ - "x": point.x, - "y": point.y, - "lng": coordinate.longitude, - "lat": coordinate.latitude, - ]) + + let features = mapView.visibleFeatures(at: point, styleLayerIdentifiers: featureLayerIdentifiers) + + if let feature = features.last, let id = feature.identifier { + channel?.invokeMethod("feature#onTap", arguments: [ + "featureId": id + ]) + } else { + channel?.invokeMethod("map#onMapClick", arguments: [ + "x": point.x, + "y": point.y, + "lng": coordinate.longitude, + "lat": coordinate.latitude, + ]) + } } /* @@ -1011,6 +1024,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma let layer = MGLSymbolStyleLayer(identifier: layerId, source: source) LayerPropertyConverter.addSymbolProperties(symbolLayer: layer, properties: properties) style.addLayer(layer) + featureLayerIdentifiers.insert(layerId) } } } @@ -1021,6 +1035,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma let layer = MGLLineStyleLayer(identifier: layerId, source: source) LayerPropertyConverter.addLineProperties(lineLayer: layer, properties: properties) style.addLayer(layer) + featureLayerIdentifiers.insert(layerId) } } } @@ -1031,6 +1046,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma let layer = MGLFillStyleLayer(identifier: layerId, source: source) LayerPropertyConverter.addFillProperties(fillLayer: layer, properties: properties) style.addLayer(layer) + featureLayerIdentifiers.insert(layerId) } } } @@ -1041,6 +1057,7 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma let layer = MGLCircleStyleLayer(identifier: layerId, source: source) LayerPropertyConverter.addCircleProperties(circleLayer: layer, properties: properties) style.addLayer(layer) + featureLayerIdentifiers.insert(layerId) } } } diff --git a/lib/src/controller.dart b/lib/src/controller.dart index f61eaf3c5..f3a158d69 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -86,6 +86,10 @@ class MapboxMapController extends ChangeNotifier { } }); + _mapboxGlPlatform.onFeatureTappedPlatform.add((featureId) { + onFeatureTapped(featureId); + }); + _mapboxGlPlatform.onCameraMoveStartedPlatform.add((_) { _isCameraMoving = true; notifyListeners(); @@ -177,6 +181,10 @@ class MapboxMapController extends ChangeNotifier { /// Callbacks to receive tap events for fills placed on this map. final ArgumentCallbacks onFillTapped = ArgumentCallbacks(); + /// Callbacks to receive tap events for features (geojson layer) placed on this map. + final ArgumentCallbacks onFeatureTapped = + ArgumentCallbacks(); + /// Callbacks to receive tap events for info windows on symbols final ArgumentCallbacks onInfoWindowTapped = ArgumentCallbacks(); @@ -261,31 +269,31 @@ class MapboxMapController extends ChangeNotifier { Future addGeoJsonSource( String sourceId, Map geojson) async { - await MapboxGlPlatform.getInstance(_id).addGeoJsonSource(sourceId, geojson); + await _mapboxGlPlatform.addGeoJsonSource(sourceId, geojson); } Future addSymbolLayer( String sourceId, String layerId, SymbolLayerProperties properties) async { - await MapboxGlPlatform.getInstance(_id) - .addSymbolLayer(sourceId, layerId, properties.toJson()); + await _mapboxGlPlatform.addSymbolLayer( + sourceId, layerId, properties.toJson()); } Future addLineLayer( String sourceId, String layerId, LineLayerProperties properties) async { - await MapboxGlPlatform.getInstance(_id) - .addLineLayer(sourceId, layerId, properties.toJson()); + await _mapboxGlPlatform.addLineLayer( + sourceId, layerId, properties.toJson()); } Future addFillLayer( String sourceId, String layerId, FillLayerProperties properties) async { - await MapboxGlPlatform.getInstance(_id) - .addFillLayer(sourceId, layerId, properties.toJson()); + await _mapboxGlPlatform.addFillLayer( + sourceId, layerId, properties.toJson()); } Future addCircleLayer( String sourceId, String layerId, CircleLayerProperties properties) async { - await MapboxGlPlatform.getInstance(_id) - .addCircleLayer(sourceId, layerId, properties.toJson()); + await _mapboxGlPlatform.addCircleLayer( + sourceId, layerId, properties.toJson()); } /// Updates user location tracking mode. @@ -843,20 +851,19 @@ class MapboxMapController extends ChangeNotifier { } /// Adds a Mapbox style layer to the map's style at render time. - Future addLayer(String imageLayerId, String imageSourceId) { - return _mapboxGlPlatform.addLayer(imageLayerId, imageSourceId); + Future addLayer(String layerId, String sourceId) { + return _mapboxGlPlatform.addLayer(layerId, sourceId); } /// Adds a Mapbox style layer below the layer provided with belowLayerId to the map's style at render time, Future addLayerBelow( - String imageLayerId, String imageSourceId, String belowLayerId) { - return _mapboxGlPlatform.addLayerBelow( - imageLayerId, imageSourceId, belowLayerId); + String layerId, String sourceId, String belowLayerId) { + return _mapboxGlPlatform.addLayerBelow(layerId, sourceId, belowLayerId); } /// Removes a Mapbox style layer - Future removeLayer(String imageLayerId) { - return _mapboxGlPlatform.removeLayer(imageLayerId); + Future removeLayer(String layerId) { + return _mapboxGlPlatform.removeLayer(layerId); } /// Returns the point on the screen that corresponds to a geographical coordinate ([latLng]). The screen location is in screen pixels (not display pixels) relative to the top left of the map (not of the whole screen) diff --git a/lib/src/layer_properties.dart b/lib/src/layer_properties.dart index 3c52a7346..199ecedae 100644 --- a/lib/src/layer_properties.dart +++ b/lib/src/layer_properties.dart @@ -3,76 +3,80 @@ part of mapbox_gl; -class SymbolLayerProperties { +abstract class LayerProperties { + Map toJson(); +} + +class SymbolLayerProperties implements LayerProperties { // Paint Properties /// The opacity at which the icon will be drawn. - /// + /// /// Type: number /// default: 1 /// minimum: 0 /// maximum: 1 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic iconOpacity; - + /// The color of the icon. This can only be used with sdf icons. - /// + /// /// Type: color /// default: #000000 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic iconColor; - + /// The color of the icon's halo. Icon halos can only be used with SDF /// icons. - /// + /// /// Type: color /// default: rgba(0, 0, 0, 0) - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic iconHaloColor; - + /// Distance of halo to the icon outline. - /// + /// /// Type: number /// default: 0 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic iconHaloWidth; - + /// Fade out the halo towards the outside. - /// + /// /// Type: number /// default: 0 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic 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. - /// + /// /// Type: array /// default: [0, 0] - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconTranslate; - + /// Controls the frame of reference for `icon-translate`. - /// + /// /// Type: enum /// default: map /// Options: @@ -80,80 +84,80 @@ class SymbolLayerProperties { /// Icons are translated relative to the map. /// "viewport" /// Icons are translated relative to the viewport. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconTranslateAnchor; - + /// The opacity at which the text will be drawn. - /// + /// /// Type: number /// default: 1 /// minimum: 0 /// maximum: 1 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textOpacity; - + /// The color with which the text will be drawn. - /// + /// /// Type: color /// default: #000000 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textColor; - + /// The color of the text's halo, which helps it stand out from /// backgrounds. - /// + /// /// Type: color /// default: rgba(0, 0, 0, 0) - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textHaloColor; - + /// Distance of halo to the font outline. Max text halo width is 1/4 of /// the font-size. - /// + /// /// Type: number /// default: 0 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textHaloWidth; - + /// The halo's fadeout distance towards the outside. - /// + /// /// Type: number /// default: 0 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic 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. - /// + /// /// Type: array /// default: [0, 0] - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textTranslate; - + /// Controls the frame of reference for `text-translate`. - /// + /// /// Type: enum /// default: map /// Options: @@ -161,14 +165,14 @@ class SymbolLayerProperties { /// The text is translated relative to the map. /// "viewport" /// The text is translated relative to the viewport. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textTranslateAnchor; - + // Layout Properties /// Label placement relative to its geometry. - /// + /// /// Type: enum /// default: point /// Options: @@ -182,17 +186,17 @@ class SymbolLayerProperties { /// Can only be used on `LineString` and `Polygon` geometries. Note /// that a single feature in a vector tile may contain multiple line /// geometries. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic symbolPlacement; /// Distance between two symbol anchors. - /// + /// /// Type: number /// default: 250 /// minimum: 1 - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic symbolSpacing; @@ -204,10 +208,10 @@ class SymbolLayerProperties { /// supports global collision detection, like Mapbox GL JS version 0.42.0 /// or greater, enabling this property is not needed to prevent clipped /// labels at tile boundaries. - /// + /// /// Type: boolean /// default: false - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic symbolAvoidEdges; @@ -218,9 +222,9 @@ class SymbolLayerProperties { /// will have priority during placement. When `icon-allow-overlap` or /// `text-allow-overlap` is set to `true`, features with a higher sort key /// will overlap over features with a lower sort key. - /// + /// /// Type: number - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos @@ -228,7 +232,7 @@ class SymbolLayerProperties { /// Controls the order in which overlapping symbols in the same layer are /// rendered - /// + /// /// Type: enum /// default: auto /// Options: @@ -241,44 +245,44 @@ class SymbolLayerProperties { /// "source" /// Symbols will be rendered in the same order as the source data /// with no sorting applied. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic symbolZOrder; /// If true, the icon will be visible even if it collides with other /// previously drawn symbols. - /// + /// /// Type: boolean /// default: false - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconAllowOverlap; /// If true, other symbols can be visible even if they collide with the /// icon. - /// + /// /// Type: boolean /// default: false - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconIgnorePlacement; /// If true, text will display without their corresponding icons when the /// icon collides with other symbols and the text does not. - /// + /// /// Type: boolean /// default: false - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconOptional; /// In combination with `symbol-placement`, determines the rotation /// behavior of icons. - /// + /// /// Type: enum /// default: auto /// Options: @@ -293,7 +297,7 @@ class SymbolLayerProperties { /// When `symbol-placement` is set to `point`, this is equivalent to /// `viewport`. When `symbol-placement` is set to `line` or /// `line-center`, this is equivalent to `map`. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconRotationAlignment; @@ -301,18 +305,18 @@ class SymbolLayerProperties { /// Scales the original size of the icon by the provided factor. The new /// pixel size of the image will be the original pixel size multiplied by /// `icon-size`. 1 is the original size; 3 triples the size of the image. - /// + /// /// Type: number /// default: 1 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic iconSize; /// Scales the icon to fit around the associated text. - /// + /// /// Type: enum /// default: none /// Options: @@ -326,35 +330,35 @@ class SymbolLayerProperties { /// text. /// "both" /// The icon is scaled in both x- and y-dimensions. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconTextFit; /// Size of the additional area added to dimensions determined by /// `icon-text-fit`, in clockwise order: top, right, bottom, left. - /// + /// /// Type: array /// default: [0, 0, 0, 0] - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconTextFitPadding; /// Name of image in sprite to use for drawing an image background. - /// + /// /// Type: resolvedImage - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic iconImage; /// Rotates the icon clockwise. - /// + /// /// Type: number /// default: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos @@ -362,21 +366,21 @@ class SymbolLayerProperties { /// Size of the additional area around the icon bounding box used for /// detecting symbol collisions. - /// + /// /// Type: number /// default: 2 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconPadding; /// If true, the icon may be flipped to prevent it from being rendered /// upside-down. - /// + /// /// Type: boolean /// default: false - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconKeepUpright; @@ -386,17 +390,17 @@ class SymbolLayerProperties { /// component is multiplied by the value of `icon-size` to obtain the /// final offset in pixels. When combined with `icon-rotate` the offset /// will be as if the rotated direction was up. - /// + /// /// Type: array /// default: [0, 0] - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic iconOffset; /// Part of the icon placed closest to the anchor. - /// + /// /// Type: enum /// default: center /// Options: @@ -420,14 +424,14 @@ class SymbolLayerProperties { /// "bottom-right" /// The bottom right corner of the icon is placed closest to the /// anchor. - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic iconAnchor; /// Orientation of icon when map is pitched. - /// + /// /// Type: enum /// default: auto /// Options: @@ -437,13 +441,13 @@ class SymbolLayerProperties { /// The icon is aligned to the plane of the viewport. /// "auto" /// Automatically matches the value of `icon-rotation-alignment`. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic iconPitchAlignment; /// Orientation of text when map is pitched. - /// + /// /// Type: enum /// default: auto /// Options: @@ -453,14 +457,14 @@ class SymbolLayerProperties { /// The text is aligned to the plane of the viewport. /// "auto" /// Automatically matches the value of `text-rotation-alignment`. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textPitchAlignment; /// In combination with `symbol-placement`, determines the rotation /// behavior of the individual glyphs forming the text. - /// + /// /// Type: enum /// default: auto /// Options: @@ -475,7 +479,7 @@ class SymbolLayerProperties { /// When `symbol-placement` is set to `point`, this is equivalent to /// `viewport`. When `symbol-placement` is set to `line` or /// `line-center`, this is equivalent to `map`. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textRotationAlignment; @@ -483,68 +487,68 @@ class SymbolLayerProperties { /// Value to use for a text label. If a plain `string` is provided, it /// will be treated as a `formatted` with default/inherited formatting /// options. - /// + /// /// Type: formatted - /// default: - /// + /// default: + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textField; /// Font stack to use for displaying text. - /// + /// /// Type: array /// default: [Open Sans Regular, Arial Unicode MS Regular] - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textFont; /// Font size. - /// + /// /// Type: number /// default: 16 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textSize; /// The maximum line width for text wrapping. - /// + /// /// Type: number /// default: 10 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textMaxWidth; /// Text leading value for multi-line text. - /// + /// /// Type: number /// default: 1.2 - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textLineHeight; /// Text tracking amount. - /// + /// /// Type: number /// default: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textLetterSpacing; /// Text justification options. - /// + /// /// Type: enum /// default: center /// Options: @@ -556,7 +560,7 @@ class SymbolLayerProperties { /// The text is centered. /// "right" /// The text is aligned to the right. - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos @@ -565,10 +569,10 @@ class SymbolLayerProperties { /// Radial offset of text, in the direction of the symbol's anchor. Useful /// in combination with `text-variable-anchor`, which defaults to using /// the two-dimensional `text-offset` if present. - /// + /// /// Type: number /// default: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos @@ -580,7 +584,7 @@ class SymbolLayerProperties { /// onto the next label. Use `text-justify: auto` to choose justification /// based on anchor position. To apply an offset, use the /// `text-radial-offset` or the two-dimensional `text-offset`. - /// + /// /// Type: array /// Options: /// "center" @@ -603,13 +607,13 @@ class SymbolLayerProperties { /// "bottom-right" /// The bottom right corner of the text is placed closest to the /// anchor. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textVariableAnchor; /// Part of the text placed closest to the anchor. - /// + /// /// Type: enum /// default: center /// Options: @@ -633,17 +637,17 @@ class SymbolLayerProperties { /// "bottom-right" /// The bottom right corner of the text is placed closest to the /// anchor. - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic textAnchor; /// Maximum angle change between adjacent characters. - /// + /// /// Type: number /// default: 45 - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textMaxAngle; @@ -655,7 +659,7 @@ class SymbolLayerProperties { /// horizontally even if array value contains single 'vertical' enum /// value. The order of elements in an array define priority order for the /// placement of an orientation variant. - /// + /// /// Type: array /// Options: /// "horizontal" @@ -664,16 +668,16 @@ class SymbolLayerProperties { /// "vertical" /// If a text's language supports vertical writing mode, symbols with /// point placement would be laid out vertically. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textWritingMode; /// Rotates the text clockwise. - /// + /// /// Type: number /// default: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos @@ -681,28 +685,28 @@ class SymbolLayerProperties { /// Size of the additional area around the text bounding box used for /// detecting symbol collisions. - /// + /// /// Type: number /// default: 2 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textPadding; /// If true, the text may be flipped vertically to prevent it from being /// rendered upside-down. - /// + /// /// Type: boolean /// default: true - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textKeepUpright; /// Specifies how to capitalize text, similar to the CSS `text-transform` /// property. - /// + /// /// Type: enum /// default: none /// Options: @@ -712,7 +716,7 @@ class SymbolLayerProperties { /// Forces all letters to be displayed in uppercase. /// "lowercase" /// Forces all letters to be displayed in lowercase. - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos @@ -723,10 +727,10 @@ class SymbolLayerProperties { /// with text-variable-anchor, input values will be taken as absolute /// values. Offsets along the x- and y-axis will be applied automatically /// based on the anchor position. - /// + /// /// Type: array /// default: [0, 0] - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos @@ -734,36 +738,36 @@ class SymbolLayerProperties { /// If true, the text will be visible even if it collides with other /// previously drawn symbols. - /// + /// /// Type: boolean /// default: false - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textAllowOverlap; /// If true, other symbols can be visible even if they collide with the /// text. - /// + /// /// Type: boolean /// default: false - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textIgnorePlacement; /// If true, icons will display without their corresponding text when the /// text collides with other symbols and the icon does not. - /// + /// /// Type: boolean /// default: false - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic textOptional; /// Whether this layer is displayed. - /// + /// /// Type: enum /// default: visible /// Options: @@ -771,7 +775,7 @@ class SymbolLayerProperties { /// The layer is shown. /// "none" /// The layer is not shown. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic visibility; @@ -859,7 +863,8 @@ class SymbolLayerProperties { iconAllowOverlap: changes.iconAllowOverlap ?? iconAllowOverlap, iconIgnorePlacement: changes.iconIgnorePlacement ?? iconIgnorePlacement, iconOptional: changes.iconOptional ?? iconOptional, - iconRotationAlignment: changes.iconRotationAlignment ?? iconRotationAlignment, + iconRotationAlignment: + changes.iconRotationAlignment ?? iconRotationAlignment, iconSize: changes.iconSize ?? iconSize, iconTextFit: changes.iconTextFit ?? iconTextFit, iconTextFitPadding: changes.iconTextFitPadding ?? iconTextFitPadding, @@ -871,7 +876,8 @@ class SymbolLayerProperties { iconAnchor: changes.iconAnchor ?? iconAnchor, iconPitchAlignment: changes.iconPitchAlignment ?? iconPitchAlignment, textPitchAlignment: changes.textPitchAlignment ?? textPitchAlignment, - textRotationAlignment: changes.textRotationAlignment ?? textRotationAlignment, + textRotationAlignment: + changes.textRotationAlignment ?? textRotationAlignment, textField: changes.textField ?? textField, textFont: changes.textFont ?? textFont, textSize: changes.textSize ?? textSize, @@ -1024,67 +1030,66 @@ class SymbolLayerProperties { visibility: json['visibility'], ); } - } -class CircleLayerProperties { +class CircleLayerProperties implements LayerProperties { // Paint Properties /// Circle radius. - /// + /// /// Type: number /// default: 5 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic circleRadius; - + /// The fill color of the circle. - /// + /// /// Type: color /// default: #000000 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic circleColor; - + /// Amount to blur the circle. 1 blurs the circle such that only the /// centerpoint is full opacity. - /// + /// /// Type: number /// default: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic circleBlur; - + /// The opacity at which the circle will be drawn. - /// + /// /// Type: number /// default: 1 /// minimum: 0 /// maximum: 1 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic circleOpacity; - + /// The geometry's offset. Values are [x, y] where negatives indicate left /// and up, respectively. - /// + /// /// Type: array /// default: [0, 0] - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic circleTranslate; - + /// Controls the frame of reference for `circle-translate`. - /// + /// /// Type: enum /// default: map /// Options: @@ -1092,13 +1097,13 @@ class CircleLayerProperties { /// The circle is translated relative to the map. /// "viewport" /// The circle is translated relative to the viewport. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic circleTranslateAnchor; - + /// Controls the scaling behavior of the circle when the map is pitched. - /// + /// /// Type: enum /// default: map /// Options: @@ -1107,13 +1112,13 @@ class CircleLayerProperties { /// camera. /// "viewport" /// Circles are not scaled. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic circlePitchScale; - + /// Orientation of circle when map is pitched. - /// + /// /// Type: enum /// default: viewport /// Options: @@ -1121,58 +1126,58 @@ class CircleLayerProperties { /// The circle is aligned to the plane of the map. /// "viewport" /// The circle is aligned to the plane of the viewport. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic circlePitchAlignment; - + /// The width of the circle's stroke. Strokes are placed outside of the /// `circle-radius`. - /// + /// /// Type: number /// default: 0 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic circleStrokeWidth; - + /// The stroke color of the circle. - /// + /// /// Type: color /// default: #000000 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic circleStrokeColor; - + /// The opacity of the circle's stroke. - /// + /// /// Type: number /// default: 1 /// minimum: 0 /// maximum: 1 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic circleStrokeOpacity; - + // Layout Properties /// Sorts features in ascending order based on this value. Features with a /// higher sort key will appear above features with a lower sort key. - /// + /// /// Type: number - /// + /// /// Sdk Support /// basic functionality with js /// data-driven styling with js final dynamic circleSortKey; /// Whether this layer is displayed. - /// + /// /// Type: enum /// default: visible /// Options: @@ -1180,7 +1185,7 @@ class CircleLayerProperties { /// The layer is shown. /// "none" /// The layer is not shown. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic visibility; @@ -1208,9 +1213,11 @@ class CircleLayerProperties { circleBlur: changes.circleBlur ?? circleBlur, circleOpacity: changes.circleOpacity ?? circleOpacity, circleTranslate: changes.circleTranslate ?? circleTranslate, - circleTranslateAnchor: changes.circleTranslateAnchor ?? circleTranslateAnchor, + circleTranslateAnchor: + changes.circleTranslateAnchor ?? circleTranslateAnchor, circlePitchScale: changes.circlePitchScale ?? circlePitchScale, - circlePitchAlignment: changes.circlePitchAlignment ?? circlePitchAlignment, + circlePitchAlignment: + changes.circlePitchAlignment ?? circlePitchAlignment, circleStrokeWidth: changes.circleStrokeWidth ?? circleStrokeWidth, circleStrokeColor: changes.circleStrokeColor ?? circleStrokeColor, circleStrokeOpacity: changes.circleStrokeOpacity ?? circleStrokeOpacity, @@ -1261,45 +1268,44 @@ class CircleLayerProperties { visibility: json['visibility'], ); } - } -class LineLayerProperties { +class LineLayerProperties implements LayerProperties { // Paint Properties /// The opacity at which the line will be drawn. - /// + /// /// Type: number /// default: 1 /// minimum: 0 /// maximum: 1 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic lineOpacity; - + /// The color with which the line will be drawn. - /// + /// /// Type: color /// default: #000000 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic lineColor; - + /// The geometry's offset. Values are [x, y] where negatives indicate left /// and up, respectively. - /// + /// /// Type: array /// default: [0, 0] - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic lineTranslate; - + /// Controls the frame of reference for `line-translate`. - /// + /// /// Type: enum /// default: map /// Options: @@ -1307,58 +1313,58 @@ class LineLayerProperties { /// The line is translated relative to the map. /// "viewport" /// The line is translated relative to the viewport. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic lineTranslateAnchor; - + /// Stroke thickness. - /// + /// /// Type: number /// default: 1 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic lineWidth; - + /// Draws a line casing outside of a line's actual path. Value indicates /// the width of the inner gap. - /// + /// /// Type: number /// default: 0 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic lineGapWidth; - + /// The line's offset. For linear features, a positive value offsets the /// line to the right, relative to the direction of the line, and a /// negative value to the left. For polygon features, a positive value /// results in an inset, and a negative value results in an outset. - /// + /// /// Type: number /// default: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic lineOffset; - + /// Blur applied to the line, in pixels. - /// + /// /// Type: number /// default: 0 /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic 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 @@ -1366,38 +1372,38 @@ class LineLayerProperties { /// specified won't render dashed lines to the expected scale. Also note /// that zoom-dependent expressions will be evaluated only at integer zoom /// levels. - /// + /// /// Type: array /// minimum: 0 - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic 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). /// Note that zoom-dependent expressions will be evaluated only at integer /// zoom levels. - /// + /// /// Type: resolvedImage - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android macos ios final dynamic linePattern; - + /// Defines a gradient with which to color a line feature. Can only be /// used with GeoJSON sources that specify `"lineMetrics": true`. - /// + /// /// Type: color - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic lineGradient; - + // Layout Properties /// The display of line endings. - /// + /// /// Type: enum /// default: butt /// Options: @@ -1411,13 +1417,13 @@ class LineLayerProperties { /// "square" /// A cap with a squared-off end which is drawn beyond the endpoint /// of the line at a distance of one-half of the line's width. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic lineCap; /// The display of lines when joining. - /// + /// /// Type: enum /// default: miter /// Options: @@ -1431,7 +1437,7 @@ class LineLayerProperties { /// "miter" /// A join with a sharp, angled corner which is drawn with the outer /// sides beyond the endpoint of the path until they meet. - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos @@ -1439,36 +1445,36 @@ class LineLayerProperties { /// Used to automatically convert miter joins to bevel joins for sharp /// angles. - /// + /// /// Type: number /// default: 2 - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic lineMiterLimit; /// Used to automatically convert round joins to miter joins for shallow /// angles. - /// + /// /// Type: number /// default: 1.05 - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic lineRoundLimit; /// Sorts features in ascending order based on this value. Features with a /// higher sort key will appear above features with a lower sort key. - /// + /// /// Type: number - /// + /// /// Sdk Support /// basic functionality with js /// data-driven styling with js final dynamic lineSortKey; /// Whether this layer is displayed. - /// + /// /// Type: enum /// default: visible /// Options: @@ -1476,7 +1482,7 @@ class LineLayerProperties { /// The layer is shown. /// "none" /// The layer is not shown. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic visibility; @@ -1573,68 +1579,67 @@ class LineLayerProperties { visibility: json['visibility'], ); } - } -class FillLayerProperties { +class FillLayerProperties implements LayerProperties { // Paint Properties /// Whether or not the fill should be antialiased. - /// + /// /// Type: boolean /// default: true - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic 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. - /// + /// /// Type: number /// default: 1 /// minimum: 0 /// maximum: 1 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic 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. - /// + /// /// Type: color /// default: #000000 - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic fillColor; - + /// The outline color of the fill. Matches the value of `fill-color` if /// unspecified. - /// + /// /// Type: color - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android ios macos final dynamic fillOutlineColor; - + /// The geometry's offset. Values are [x, y] where negatives indicate left /// and up, respectively. - /// + /// /// Type: array /// default: [0, 0] - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic fillTranslate; - + /// Controls the frame of reference for `fill-translate`. - /// + /// /// Type: enum /// default: map /// Options: @@ -1642,36 +1647,36 @@ class FillLayerProperties { /// The fill is translated relative to the map. /// "viewport" /// The fill is translated relative to the viewport. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic 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). Note that zoom-dependent expressions will be evaluated only /// at integer zoom levels. - /// + /// /// Type: resolvedImage - /// + /// /// Sdk Support /// basic functionality with js android ios macos /// data-driven styling with js android macos ios final dynamic fillPattern; - + // Layout Properties /// Sorts features in ascending order based on this value. Features with a /// higher sort key will appear above features with a lower sort key. - /// + /// /// Type: number - /// + /// /// Sdk Support /// basic functionality with js /// data-driven styling with js final dynamic fillSortKey; /// Whether this layer is displayed. - /// + /// /// Type: enum /// default: visible /// Options: @@ -1679,7 +1684,7 @@ class FillLayerProperties { /// The layer is shown. /// "none" /// The layer is not shown. - /// + /// /// Sdk Support /// basic functionality with js android ios macos final dynamic visibility; @@ -1744,7 +1749,4 @@ class FillLayerProperties { visibility: json['visibility'], ); } - } - - diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index adba5a4b4..92642619e 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -24,6 +24,8 @@ abstract class MapboxGlPlatform { final onFillTappedPlatform = ArgumentCallbacks(); + final onFeatureTappedPlatform = ArgumentCallbacks(); + final onCameraMoveStartedPlatform = ArgumentCallbacks(); final onCameraMovePlatform = ArgumentCallbacks(); diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index 0f0771d51..68d5dec2e 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -35,6 +35,12 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { onFillTappedPlatform(fillId); } break; + case 'feature#onTap': + final featureId = call.arguments['featureId']; + if (featureId != null) { + onFeatureTappedPlatform(featureId); + } + break; case 'camera#onMoveStarted': onCameraMoveStartedPlatform(null); break; @@ -684,10 +690,10 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { } @override - Future removeLayer(String imageLayerId) async { + Future removeLayer(String layerId) async { try { return await _channel.invokeMethod( - 'style#removeLayer', {'imageLayerId': imageLayerId}); + 'style#removeLayer', {'imageLayerId': layerId}); } on PlatformException catch (e) { return new Future.error(e); } @@ -720,14 +726,6 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { } } - @override - Future addSource(String sourceId, String source) async { - await _channel.invokeMethod('source#add', { - 'sourceId': sourceId, - 'geojson': source, - }); - } - @override Future addGeoJsonSource( String sourceId, Map geojson) async { diff --git a/mapbox_gl_web/lib/src/mapbox_map_controller.dart b/mapbox_gl_web/lib/src/mapbox_map_controller.dart index 86356027c..5ee3fd077 100644 --- a/mapbox_gl_web/lib/src/mapbox_map_controller.dart +++ b/mapbox_gl_web/lib/src/mapbox_map_controller.dart @@ -11,6 +11,7 @@ class MapboxMapController extends MapboxGlPlatform late MapboxMap _map; List annotationOrder = []; + final _featureLayerIdentifiers = Set(); late SymbolManager symbolManager; late LineManager lineManager; late CircleManager circleManager; @@ -447,11 +448,17 @@ class MapboxMapController extends MapboxGlPlatform }); } - void _onMapClick(e) { - onMapClickPlatform({ - 'point': Point(e.point.x, e.point.y), - 'latLng': LatLng(e.lngLat.lat, e.lngLat.lng), - }); + void _onMapClick(Event e) { + final features = _map.queryRenderedFeatures( + [e.point.x, e.point.y], {"layers": _featureLayerIdentifiers.toList()}); + if (features.isNotEmpty) { + onFeatureTappedPlatform(features.first.id); + } else { + onMapClickPlatform({ + 'point': Point(e.point.x.toDouble(), e.point.y.toDouble()), + 'latLng': LatLng(e.lngLat.lat.toDouble(), e.lngLat.lng.toDouble()), + }); + } } void _onMapLongClick(e) { @@ -767,6 +774,12 @@ class MapboxMapController extends MapboxGlPlatform return circumference * cos(latitude * (pi / 180)) / pow(2, zoom + 9); } + @override + Future removeLayer(String layerId) async { + _featureLayerIdentifiers.remove(layerId); + _map.removeLayer(layerId); + } + Future addGeoJsonSource( String sourceId, Map geojson) async { _map.addSource(sourceId, {"type": 'geojson', "data": geojson}); @@ -799,6 +812,7 @@ class MapboxMapController extends MapboxGlPlatform final paint = Map.fromEntries( properties.entries.where((entry) => !isLayoutProperty(entry.key))); + _featureLayerIdentifiers.add(layerId); _map.addLayer({ 'id': layerId, 'type': layerType, diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index f2edd9676..b5d2a4c81 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -1,6 +1,5 @@ import 'dart:io'; import 'dart:convert'; -import 'dart:math'; import 'package:mustache_template/mustache_template.dart'; import 'package:recase/recase.dart'; diff --git a/scripts/templates/layer_properties.dart.template b/scripts/templates/layer_properties.dart.template index 7b500ccda..1ae6e1b30 100644 --- a/scripts/templates/layer_properties.dart.template +++ b/scripts/templates/layer_properties.dart.template @@ -2,9 +2,13 @@ // ./scripts/lib/generate.dart part of mapbox_gl; + +abstract class LayerProperties { + Map toJson(); +} {{#layerTypes}} -class {{typePascal}}LayerProperties { +class {{typePascal}}LayerProperties implements LayerProperties { // Paint Properties {{#paint_properties}} {{#docSplit}} From b3d016c68012b04164726c49590aa3b4d4de0052 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Mon, 25 Oct 2021 20:59:49 +0200 Subject: [PATCH 19/33] getting access_token from env minor cleanup --- .../java/com/mapbox/mapboxgl/Convert.java | 11 ---- example/lib/main.dart | 57 ++++++++++++++++--- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/android/src/main/java/com/mapbox/mapboxgl/Convert.java b/android/src/main/java/com/mapbox/mapboxgl/Convert.java index 3a52faf0e..d135a85b0 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/Convert.java +++ b/android/src/main/java/com/mapbox/mapboxgl/Convert.java @@ -13,25 +13,14 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.log.Logger; import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.style.expressions.Expression; -import com.mapbox.mapboxsdk.style.layers.PropertyFactory; -import com.mapbox.mapboxsdk.style.layers.PropertyValue; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; -import io.flutter.plugin.common.JSONUtil; - /** * Conversions between JSON-like values and MapboxMaps data types. */ diff --git a/example/lib/main.dart b/example/lib/main.dart index 3983e85d7..fc240abcc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:io'; + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:location/location.dart'; @@ -45,9 +47,7 @@ final List _allPages = [ ]; class MapsDemo extends StatelessWidget { - //FIXME: Add your Mapbox access token here - static const String ACCESS_TOKEN = - "pk.eyJ1Ijoib2NlbGwiLCJhIjoiY2pvdTE5bnhoMTc1cDNrcWlha2todGFkYiJ9.hW9Q853ix58dukevFHX1pw"; + static const String ACCESS_TOKEN = String.fromEnvironment("ACCESS_TOKEN"); void _pushPage(BuildContext context, ExamplePage page) async { if (!kIsWeb) { @@ -68,12 +68,51 @@ class MapsDemo extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('MapboxMaps examples')), - body: ListView.builder( - itemCount: _allPages.length, - itemBuilder: (_, int index) => ListTile( - leading: _allPages[index].leading, - title: Text(_allPages[index].title), - onTap: () => _pushPage(context, _allPages[index]), + body: ACCESS_TOKEN.isEmpty + ? buildAccessTokenWarning() + : ListView.builder( + itemCount: _allPages.length, + itemBuilder: (_, int index) => ListTile( + leading: _allPages[index].leading, + title: Text(_allPages[index].title), + onTap: () => _pushPage(context, _allPages[index]), + ), + ), + ); + } + + Widget buildAccessTokenWarning() { + return Container( + color: Colors.red[900], + child: SizedBox.expand( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text("Please pass in your access token with", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.white)), + Text("--dart-define=ACCESS_TOKEN=YOUR_TOKEN", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.white)), + Text( + "passed into flutter run or add it to args in vscode's launch.json", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.white)), + ] + .map((w) => Padding( + padding: EdgeInsets.all(8), + child: w, + )) + .toList(), ), ), ); From 0f4794ecd9081f2f609765fc87252bc70e4dca92 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Mon, 25 Oct 2021 21:32:04 +0200 Subject: [PATCH 20/33] fixed lint issues --- example/lib/main.dart | 2 -- mapbox_gl_web/lib/mapbox_gl_web.dart | 1 - 2 files changed, 3 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index fc240abcc..bcd174528 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:location/location.dart'; diff --git a/mapbox_gl_web/lib/mapbox_gl_web.dart b/mapbox_gl_web/lib/mapbox_gl_web.dart index d4c81a458..8aada7d83 100644 --- a/mapbox_gl_web/lib/mapbox_gl_web.dart +++ b/mapbox_gl_web/lib/mapbox_gl_web.dart @@ -1,7 +1,6 @@ library mapbox_gl_web; import 'dart:async'; -import 'dart:convert'; // FIXED HERE: https://github.com/dart-lang/linter/pull/1985 // ignore_for_file: avoid_web_libraries_in_flutter import 'dart:html'; From 6c544e0ef55ab658d4a6cdcf311a57aa4aef7a17 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Tue, 26 Oct 2021 17:15:11 +0200 Subject: [PATCH 21/33] removed access token changes --- example/lib/main.dart | 54 +++++++------------------------------------ 1 file changed, 8 insertions(+), 46 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index bcd174528..7ab20be1a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -45,7 +45,8 @@ final List _allPages = [ ]; class MapsDemo extends StatelessWidget { - static const String ACCESS_TOKEN = String.fromEnvironment("ACCESS_TOKEN"); + //FIXME: Add your Mapbox access token here + static const String ACCESS_TOKEN = "YOUR_TOKEN_HERE"; void _pushPage(BuildContext context, ExamplePage page) async { if (!kIsWeb) { @@ -66,51 +67,12 @@ class MapsDemo extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('MapboxMaps examples')), - body: ACCESS_TOKEN.isEmpty - ? buildAccessTokenWarning() - : ListView.builder( - itemCount: _allPages.length, - itemBuilder: (_, int index) => ListTile( - leading: _allPages[index].leading, - title: Text(_allPages[index].title), - onTap: () => _pushPage(context, _allPages[index]), - ), - ), - ); - } - - Widget buildAccessTokenWarning() { - return Container( - color: Colors.red[900], - child: SizedBox.expand( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text("Please pass in your access token with", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.white)), - Text("--dart-define=ACCESS_TOKEN=YOUR_TOKEN", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.white)), - Text( - "passed into flutter run or add it to args in vscode's launch.json", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.white)), - ] - .map((w) => Padding( - padding: EdgeInsets.all(8), - child: w, - )) - .toList(), + body: ListView.builder( + itemCount: _allPages.length, + itemBuilder: (_, int index) => ListTile( + leading: _allPages[index].leading, + title: Text(_allPages[index].title), + onTap: () => _pushPage(context, _allPages[index]), ), ), ); From dc2c01c0addb49fc86d8ec11be93018230968159 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Tue, 26 Oct 2021 17:58:41 +0200 Subject: [PATCH 22/33] removed package config --- scripts/.dart_tool/package_config.json | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 scripts/.dart_tool/package_config.json diff --git a/scripts/.dart_tool/package_config.json b/scripts/.dart_tool/package_config.json deleted file mode 100644 index 653ae73da..000000000 --- a/scripts/.dart_tool/package_config.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "configVersion": 2, - "packages": [ - { - "name": "mustache_template", - "rootUri": "file:///Users/ocell/.pub-cache/hosted/pub.dartlang.org/mustache_template-2.0.0", - "packageUri": "lib/", - "languageVersion": "2.12" - }, - { - "name": "recase", - "rootUri": "file:///Users/ocell/.pub-cache/hosted/pub.dartlang.org/recase-4.0.0", - "packageUri": "lib/", - "languageVersion": "2.12" - }, - { - "name": "mapbox_code_gen", - "rootUri": "../", - "packageUri": "lib/", - "languageVersion": "2.12" - } - ], - "generated": "2021-10-15T22:47:11.982253Z", - "generator": "pub", - "generatorVersion": "2.14.3" -} From 13d892014f31abc2af3725c4b612dc118a9414ba Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Tue, 26 Oct 2021 18:21:04 +0200 Subject: [PATCH 23/33] code review changes --- example/ios/Podfile | 2 +- ios/mapbox_gl.podspec | 2 +- .../lib/src/mapbox_gl_platform_interface.dart | 3 +-- scripts/lib/generate.dart | 5 ++--- scripts/pubspec.yaml | 3 ++- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/example/ios/Podfile b/example/ios/Podfile index e8dcdf52f..4e9b84d6a 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '10.0' +platform :ios, '9.0' use_frameworks! # CocoaPods analytics sends network stats synchronously affecting flutter build latency. diff --git a/ios/mapbox_gl.podspec b/ios/mapbox_gl.podspec index c64e3879e..c4f46d333 100644 --- a/ios/mapbox_gl.podspec +++ b/ios/mapbox_gl.podspec @@ -18,6 +18,6 @@ A new Flutter plugin. s.dependency 'MapboxAnnotationExtension', '~> 0.0.1-beta.1' s.dependency 'Mapbox-iOS-SDK', '~> 6.3.0' s.swift_version = '4.2' - s.ios.deployment_target = '12.0' + s.ios.deployment_target = '9.0' end diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index 92642619e..ffaa693ea 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -283,8 +283,7 @@ abstract class MapboxGlPlatform { Future addGeoJsonSource( String sourceId, Map geojson) async { - throw UnimplementedError( - 'setSymbolTextIgnorePlacement() has not been implemented.'); + throw UnimplementedError('addGeoJsonSource() has not been implemented.'); } Future addSymbolLayer( diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index b5d2a4c81..17bd13843 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -5,9 +5,8 @@ import 'package:mustache_template/mustache_template.dart'; import 'package:recase/recase.dart'; main() async { - var styleJson = jsonDecode(await new File( - '/Users/ocell/code/flutter-mapbox-gl/scripts/input/style.json') - .readAsString()); + var styleJson = + jsonDecode(await new File('scripts/input/style.json').readAsString()); final layerTypes = ["symbol", "circle", "line", "fill"]; diff --git a/scripts/pubspec.yaml b/scripts/pubspec.yaml index a49569e18..f25e07ce1 100644 --- a/scripts/pubspec.yaml +++ b/scripts/pubspec.yaml @@ -1,5 +1,6 @@ name: mapbox_code_gen -description: Just a place to practice +description: code generation for flutter-mapbox-gl + version: 0.0.1 environment: From 26e2dc08dc134b833ef39e808eac6b228e0a9726 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Tue, 26 Oct 2021 18:46:07 +0200 Subject: [PATCH 24/33] more code review changes --- .../mapbox/mapboxgl/MapboxMapController.java | 2 +- lib/src/controller.dart | 12 +- lib/src/layer_expressions.dart | 1300 ++++++++--------- lib/src/layer_properties.dart | 276 ++-- scripts/lib/generate.dart | 4 +- .../templates/layer_expressions.dart.template | 12 +- 6 files changed, 803 insertions(+), 803 deletions(-) diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index acdefd014..2fe40ea1e 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -1081,7 +1081,7 @@ public void onFailure(@NonNull Exception exception) { result.error("STYLE IS NULL", "The style is null. Has onStyleLoaded() already been invoked?", null); } String layerId = call.argument("layerId"); - style.removeLayer((String) call.argument("layerId")); + style.removeLayer(layerId); featureLayerIdentifiers.remove(layerId); result.success(null); diff --git a/lib/src/controller.dart b/lib/src/controller.dart index f3a158d69..9645ca6d1 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -850,15 +850,15 @@ class MapboxMapController extends ChangeNotifier { return _mapboxGlPlatform.removeImageSource(imageSourceId); } - /// Adds a Mapbox style layer to the map's style at render time. - Future addLayer(String layerId, String sourceId) { - return _mapboxGlPlatform.addLayer(layerId, sourceId); + /// Adds a Mapbox image layer to the map's style at render time. Only works for image sources! + Future addLayer(String layerId, String imageSourceId) { + return _mapboxGlPlatform.addLayer(layerId, imageSourceId); } - /// Adds a Mapbox style layer below the layer provided with belowLayerId to the map's style at render time, + /// Adds a Mapbox image layer below the layer provided with belowLayerId to the map's style at render time. Only works for image sources! Future addLayerBelow( - String layerId, String sourceId, String belowLayerId) { - return _mapboxGlPlatform.addLayerBelow(layerId, sourceId, belowLayerId); + String layerId, String sourceId, String imageSourceId) { + return _mapboxGlPlatform.addLayerBelow(layerId, sourceId, imageSourceId); } /// Removes a Mapbox style layer diff --git a/lib/src/layer_expressions.dart b/lib/src/layer_expressions.dart index 91451361f..4d612e1ad 100644 --- a/lib/src/layer_expressions.dart +++ b/lib/src/layer_expressions.dart @@ -4,655 +4,655 @@ part of mapbox_gl; class Expressions{ - /// Binds expressions to named variables, which can then be referenced in - /// the result expression using ["var", "variable_name"]. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const let = "let"; - - /// References variable bound using "let". - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const varExpression = "var"; - - /// Provides a literal array or object value. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const literal = "literal"; - - /// Asserts that the input is an array (optionally with a specific item - /// type and length). If, when the input expression is evaluated, it is - /// not of the asserted type, then this assertion will cause the whole - /// expression to be aborted. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const array = "array"; - - /// Retrieves an item from an array. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const at = "at"; - - /// Determines whether an item exists in an array or a substring exists in - /// a string. - /// - /// Sdk Support - /// basic functionality with js - static const inExpression = "in"; - - /// Selects the first output whose corresponding test condition evaluates - /// to true, or the fallback value otherwise. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const caseExpression = "case"; - - /// Selects the output whose label value matches the input value, or the - /// fallback value if no match is found. The input can be any expression - /// (e.g. `["get", "building_type"]`). Each label must be either: - /// * a single literal value; or - /// * an array of literal values, whose values must be all strings or all - /// numbers (e.g. `[100, 101]` or `["c", "b"]`). The input matches if any - /// of the values in the array matches, similar to the `"in"` - /// operator.Each label must be unique. If the input type does not match - /// the type of the labels, the result will be the fallback value. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const match = "match"; - - /// Evaluates each expression in turn until the first non-null value is - /// obtained, and returns that value. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const coalesce = "coalesce"; - - /// Produces discrete, stepped results by evaluating a piecewise-constant - /// function defined by pairs of input and output values ("stops"). The - /// `input` may be any numeric expression (e.g., `["get", "population"]`). - /// Stop inputs must be numeric literals in strictly ascending order. - /// Returns the output value of the stop just less than the input, or the - /// first output if the input is less than the first stop. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const step = "step"; - - /// Produces continuous, smooth results by interpolating between pairs of - /// input and output values ("stops"). The `input` may be any numeric - /// expression (e.g., `["get", "population"]`). Stop inputs must be - /// numeric literals in strictly ascending order. The output type must be - /// `number`, `array`, or `color`.Interpolation types:- - /// `["linear"]`: interpolates linearly between the pair of stops just - /// less than and just greater than the input.- `["exponential", base]`: - /// interpolates exponentially between the stops just less than and just - /// greater than the input. `base` controls the rate at which the output - /// increases: higher values make the output increase more towards the - /// high end of the range. With values close to 1 the output increases - /// linearly.- `["cubic-bezier", x1, y1, x2, y2]`: interpolates using the - /// cubic bezier curve defined by the given control points. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const interpolate = "interpolate"; - - /// Produces continuous, smooth results by interpolating between pairs of - /// input and output values ("stops"). Works like `interpolate`, but the - /// output type must be `color`, and the interpolation is performed in the - /// Hue-Chroma-Luminance color space. - /// - /// Sdk Support - /// basic functionality with js - static const interpolateHcl = "interpolate-hcl"; - - /// Produces continuous, smooth results by interpolating between pairs of - /// input and output values ("stops"). Works like `interpolate`, but the - /// output type must be `color`, and the interpolation is performed in the - /// CIELAB color space. - /// - /// Sdk Support - /// basic functionality with js - static const interpolateLab = "interpolate-lab"; - - /// Returns mathematical constant ln(2). - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const ln2 = "ln2"; - - /// Returns the mathematical constant pi. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const pi = "pi"; - - /// Returns the mathematical constant e. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const e = "e"; - - /// Returns a string describing the type of the given value. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const typeof = "typeof"; - - /// Asserts that the input value is a string. If multiple values are - /// provided, each one is evaluated in order until a string is obtained. - /// If none of the inputs are strings, the expression is an error. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const string = "string"; - - /// Asserts that the input value is a number. If multiple values are - /// provided, each one is evaluated in order until a number is obtained. - /// If none of the inputs are numbers, the expression is an error. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const number = "number"; - - /// Asserts that the input value is a boolean. If multiple values are - /// provided, each one is evaluated in order until a boolean is obtained. - /// If none of the inputs are booleans, the expression is an error. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const boolean = "boolean"; - - /// Asserts that the input value is an object. If multiple values are - /// provided, each one is evaluated in order until an object is obtained. - /// If none of the inputs are objects, the expression is an error. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const object = "object"; - - /// Returns a `collator` for use in locale-dependent comparison - /// operations. The `case-sensitive` and `diacritic-sensitive` options - /// default to `false`. The `locale` argument specifies the IETF language - /// tag of the locale to use. If none is provided, the default locale is - /// used. If the requested locale is not available, the `collator` will - /// use a system-defined fallback locale. Use `resolved-locale` to test - /// the results of locale fallback behavior. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const collator = "collator"; - - /// Returns `formatted` text containing annotations for use in - /// mixed-format `text-field` entries. For a `text-field` entries of a - /// string type, following option object's properties are supported: If - /// set, the `text-font` value overrides the font specified by the root - /// layout properties. If set, the `font-scale` value specifies a scaling - /// factor relative to the `text-size` specified in the root layout - /// properties. If set, the `text-color` value overrides the color - /// specified by the root paint properties for this layer. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const format = "format"; - - /// Returns an `image` type for use in `icon-image`, `*-pattern` entries - /// and as a section in the `format` expression. If set, the `image` - /// argument will check that the requested image exists in the style and - /// will return either the resolved image name or `null`, depending on - /// whether or not the image is currently in the style. This validation - /// process is synchronous and requires the image to have been added to - /// the style before requesting it in the `image` argument. - /// - /// Sdk Support - /// basic functionality with js android ios - static const image = "image"; - - /// Converts the input number into a string representation using the - /// providing formatting rules. If set, the `locale` argument specifies - /// the locale to use, as a BCP 47 language tag. If set, the `currency` - /// argument specifies an ISO 4217 code to use for currency-style - /// formatting. If set, the `min-fraction-digits` and - /// `max-fraction-digits` arguments specify the minimum and maximum number - /// of fractional digits to include. - /// - /// Sdk Support - /// basic functionality with js - static const numberFormat = "number-format"; - - /// Converts the input value to a string. If the input is `null`, the - /// result is `""`. If the input is a boolean, the result is `"true"` or - /// `"false"`. If the input is a number, it is converted to a string as - /// specified by the ["NumberToString" - /// algorithm](https://tc39.github.io/ecma262/#sec-tostring-applied-to-the-number-type) - /// of the ECMAScript Language Specification. If the input is a color, it - /// is converted to a string of the form `"rgba(r,g,b,a)"`, where `r`, - /// `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from 0 - /// to 1. Otherwise, the input is converted to a string in the format - /// specified by the - /// [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) - /// function of the ECMAScript Language Specification. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const toStringExpression = "to-string"; - - /// Converts the input value to a number, if possible. If the input is - /// `null` or `false`, the result is 0. If the input is `true`, the result - /// is 1. If the input is a string, it is converted to a number as - /// specified by the ["ToNumber Applied to the String Type" - /// algorithm](https://tc39.github.io/ecma262/#sec-tonumber-applied-to-the-string-type) - /// of the ECMAScript Language Specification. If multiple values are - /// provided, each one is evaluated in order until the first successful - /// conversion is obtained. If none of the inputs can be converted, the - /// expression is an error. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const toNumber = "to-number"; - - /// Converts the input value to a boolean. The result is `false` when then - /// input is an empty string, 0, `false`, `null`, or `NaN`; otherwise it - /// is `true`. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const toBoolean = "to-boolean"; - - /// Returns a four-element array containing the input color's red, green, - /// blue, and alpha components, in that order. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const toRgba = "to-rgba"; - - /// Converts the input value to a color. If multiple values are provided, - /// each one is evaluated in order until the first successful conversion - /// is obtained. If none of the inputs can be converted, the expression is - /// an error. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const toColor = "to-color"; - - /// Creates a color value from red, green, and blue components, which must - /// range between 0 and 255, and an alpha component of 1. If any component - /// is out of range, the expression is an error. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const rgb = "rgb"; - - /// Creates a color value from red, green, blue components, which must - /// range between 0 and 255, and an alpha component which must range - /// between 0 and 1. If any component is out of range, the expression is - /// an error. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const rgba = "rgba"; - - /// Retrieves a property value from the current feature's properties, or - /// from another object if a second argument is provided. Returns null if - /// the requested property is missing. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const get = "get"; - - /// Tests for the presence of an property value in the current feature's - /// properties, or from another object if a second argument is provided. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const has = "has"; - - /// Gets the length of an array or string. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const length = "length"; - - /// Gets the feature properties object. Note that in some cases, it may - /// be more efficient to use ["get", "property_name"] directly. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const properties = "properties"; - - /// Retrieves a property value from the current feature's state. Returns - /// null if the requested property is not present on the feature's state. - /// A feature's state is not part of the GeoJSON or vector tile data, and - /// must be set programmatically on each feature. Features are identified - /// by their `id` attribute, which must be an integer or a string that can - /// be cast to an integer. Note that ["feature-state"] can only be used - /// with paint properties that support data-driven styling. - /// - /// Sdk Support - /// basic functionality with js - static const featureState = "feature-state"; - - /// Gets the feature's geometry type: Point, MultiPoint, LineString, - /// MultiLineString, Polygon, MultiPolygon. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const geometryType = "geometry-type"; - - /// Gets the feature's id, if it has one. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const id = "id"; - - /// Gets the current zoom level. Note that in style layout and paint - /// properties, ["zoom"] may only appear as the input to a top-level - /// "step" or "interpolate" expression. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const zoom = "zoom"; - - /// Gets the kernel density estimation of a pixel in a heatmap layer, - /// which is a relative measure of how many data points are crowded around - /// a particular pixel. Can only be used in the `heatmap-color` property. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const heatmapDensity = "heatmap-density"; - - /// Gets the progress along a gradient line. Can only be used in the - /// `line-gradient` property. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const lineProgress = "line-progress"; - - /// Gets the value of a cluster property accumulated so far. Can only be - /// used in the `clusterProperties` option of a clustered GeoJSON source. - /// - /// Sdk Support - /// basic functionality with js - static const accumulated = "accumulated"; - - /// Returns the sum of the inputs. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const plus = "+"; - - /// Returns the product of the inputs. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const multiply = "*"; - - /// For two inputs, returns the result of subtracting the second input - /// from the first. For a single input, returns the result of subtracting - /// it from 0. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const minus = "-"; - - /// Returns the result of floating point division of the first input by - /// the second. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const divide = "/"; - - /// Returns the remainder after integer division of the first input by the - /// second. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const precent = "%"; - - /// Returns the result of raising the first input to the power specified - /// by the second. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const xor = "^"; - - /// Returns the square root of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const sqrt = "sqrt"; - - /// Returns the base-ten logarithm of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const log10 = "log10"; - - /// Returns the natural logarithm of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const ln = "ln"; - - /// Returns the base-two logarithm of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const log2 = "log2"; - - /// Returns the sine of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const sin = "sin"; - - /// Returns the cosine of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const cos = "cos"; - - /// Returns the tangent of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const tan = "tan"; - - /// Returns the arcsine of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const asin = "asin"; - - /// Returns the arccosine of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const acos = "acos"; - - /// Returns the arctangent of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const atan = "atan"; - - /// Returns the minimum value of the inputs. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const min = "min"; - - /// Returns the maximum value of the inputs. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const max = "max"; - - /// Rounds the input to the nearest integer. Halfway values are rounded - /// away from zero. For example, `["round", -1.5]` evaluates to -2. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const round = "round"; - - /// Returns the absolute value of the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const abs = "abs"; - - /// Returns the smallest integer that is greater than or equal to the - /// input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const ceil = "ceil"; - - /// Returns the largest integer that is less than or equal to the input. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const floor = "floor"; - - /// Returns `true` if the input values are equal, `false` otherwise. The - /// comparison is strictly typed: values of different runtime types are - /// always considered unequal. Cases where the types are known to be - /// different at parse time are considered invalid and will produce a - /// parse error. Accepts an optional `collator` argument to control - /// locale-dependent string comparisons. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const equal = "=="; - - /// Returns `true` if the input values are not equal, `false` otherwise. - /// The comparison is strictly typed: values of different runtime types - /// are always considered unequal. Cases where the types are known to be - /// different at parse time are considered invalid and will produce a - /// parse error. Accepts an optional `collator` argument to control - /// locale-dependent string comparisons. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const notEqual = "!="; - - /// Returns `true` if the first input is strictly greater than the second, - /// `false` otherwise. The arguments are required to be either both - /// strings or both numbers; if during evaluation they are not, expression - /// evaluation produces an error. Cases where this constraint is known not - /// to hold at parse time are considered in valid and will produce a parse - /// error. Accepts an optional `collator` argument to control - /// locale-dependent string comparisons. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const larger = ">"; - - /// Returns `true` if the first input is strictly less than the second, - /// `false` otherwise. The arguments are required to be either both - /// strings or both numbers; if during evaluation they are not, expression - /// evaluation produces an error. Cases where this constraint is known not - /// to hold at parse time are considered in valid and will produce a parse - /// error. Accepts an optional `collator` argument to control - /// locale-dependent string comparisons. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const smaller = "<"; - - /// Returns `true` if the first input is greater than or equal to the - /// second, `false` otherwise. The arguments are required to be either - /// both strings or both numbers; if during evaluation they are not, - /// expression evaluation produces an error. Cases where this constraint - /// is known not to hold at parse time are considered in valid and will - /// produce a parse error. Accepts an optional `collator` argument to - /// control locale-dependent string comparisons. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const largerOrEqual = ">="; - - /// Returns `true` if the first input is less than or equal to the second, - /// `false` otherwise. The arguments are required to be either both - /// strings or both numbers; if during evaluation they are not, expression - /// evaluation produces an error. Cases where this constraint is known not - /// to hold at parse time are considered in valid and will produce a parse - /// error. Accepts an optional `collator` argument to control - /// locale-dependent string comparisons. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const smallerOrEqual = "<="; - - /// Returns `true` if all the inputs are `true`, `false` otherwise. The - /// inputs are evaluated in order, and evaluation is short-circuiting: - /// once an input expression evaluates to `false`, the result is `false` - /// and no further input expressions are evaluated. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const all = "all"; - - /// Returns `true` if any of the inputs are `true`, `false` otherwise. The - /// inputs are evaluated in order, and evaluation is short-circuiting: - /// once an input expression evaluates to `true`, the result is `true` and - /// no further input expressions are evaluated. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const any = "any"; - - /// Logical negation. Returns `true` if the input is `false`, and `false` - /// if the input is `true`. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const not = "!"; - - /// Returns `true` if the input string is expected to render legibly. - /// Returns `false` if the input string contains sections that cannot be - /// rendered without potential loss of meaning (e.g. Indic scripts that - /// require complex text shaping, or right-to-left scripts if the the - /// `mapbox-gl-rtl-text` plugin is not in use in Mapbox GL JS). - /// - /// Sdk Support - /// basic functionality with js android - static const isSupportedScript = "is-supported-script"; - - /// Returns the input string converted to uppercase. Follows the Unicode - /// Default Case Conversion algorithm and the locale-insensitive case - /// mappings in the Unicode Character Database. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const upcase = "upcase"; - - /// Returns the input string converted to lowercase. Follows the Unicode - /// Default Case Conversion algorithm and the locale-insensitive case - /// mappings in the Unicode Character Database. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const downcase = "downcase"; - - /// Returns a `string` consisting of the concatenation of the inputs. Each - /// input is converted to a string as if by `to-string`. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const concat = "concat"; - - /// Returns the IETF language tag of the locale being used by the provided - /// `collator`. This can be used to determine the default system locale, - /// or to determine if a requested locale was successfully loaded. - /// - /// Sdk Support - /// basic functionality with js android ios macos - static const resolvedLocale = "resolved-locale"; + /// Binds expressions to named variables, which can then be referenced in + /// the result expression using ["var", "variable_name"]. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const let = "let"; + + /// References variable bound using "let". + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const varExpression = "var"; + + /// Provides a literal array or object value. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const literal = "literal"; + + /// Asserts that the input is an array (optionally with a specific item + /// type and length). If, when the input expression is evaluated, it is + /// not of the asserted type, then this assertion will cause the whole + /// expression to be aborted. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const array = "array"; + + /// Retrieves an item from an array. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const at = "at"; + + /// Determines whether an item exists in an array or a substring exists in + /// a string. + /// + /// Sdk Support + /// basic functionality with js + static const inExpression = "in"; + + /// Selects the first output whose corresponding test condition evaluates + /// to true, or the fallback value otherwise. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const caseExpression = "case"; + + /// Selects the output whose label value matches the input value, or the + /// fallback value if no match is found. The input can be any expression + /// (e.g. `["get", "building_type"]`). Each label must be either: + /// * a single literal value; or + /// * an array of literal values, whose values must be all strings or all + /// numbers (e.g. `[100, 101]` or `["c", "b"]`). The input matches if any + /// of the values in the array matches, similar to the `"in"` + /// operator.Each label must be unique. If the input type does not match + /// the type of the labels, the result will be the fallback value. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const match = "match"; + + /// Evaluates each expression in turn until the first non-null value is + /// obtained, and returns that value. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const coalesce = "coalesce"; + + /// Produces discrete, stepped results by evaluating a piecewise-constant + /// function defined by pairs of input and output values ("stops"). The + /// `input` may be any numeric expression (e.g., `["get", "population"]`). + /// Stop inputs must be numeric literals in strictly ascending order. + /// Returns the output value of the stop just less than the input, or the + /// first output if the input is less than the first stop. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const step = "step"; + + /// Produces continuous, smooth results by interpolating between pairs of + /// input and output values ("stops"). The `input` may be any numeric + /// expression (e.g., `["get", "population"]`). Stop inputs must be + /// numeric literals in strictly ascending order. The output type must be + /// `number`, `array`, or `color`.Interpolation types:- + /// `["linear"]`: interpolates linearly between the pair of stops just + /// less than and just greater than the input.- `["exponential", base]`: + /// interpolates exponentially between the stops just less than and just + /// greater than the input. `base` controls the rate at which the output + /// increases: higher values make the output increase more towards the + /// high end of the range. With values close to 1 the output increases + /// linearly.- `["cubic-bezier", x1, y1, x2, y2]`: interpolates using the + /// cubic bezier curve defined by the given control points. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const interpolate = "interpolate"; + + /// Produces continuous, smooth results by interpolating between pairs of + /// input and output values ("stops"). Works like `interpolate`, but the + /// output type must be `color`, and the interpolation is performed in the + /// Hue-Chroma-Luminance color space. + /// + /// Sdk Support + /// basic functionality with js + static const interpolateHcl = "interpolate-hcl"; + + /// Produces continuous, smooth results by interpolating between pairs of + /// input and output values ("stops"). Works like `interpolate`, but the + /// output type must be `color`, and the interpolation is performed in the + /// CIELAB color space. + /// + /// Sdk Support + /// basic functionality with js + static const interpolateLab = "interpolate-lab"; + + /// Returns mathematical constant ln(2). + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const ln2 = "ln2"; + + /// Returns the mathematical constant pi. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const pi = "pi"; + + /// Returns the mathematical constant e. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const e = "e"; + + /// Returns a string describing the type of the given value. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const typeof = "typeof"; + + /// Asserts that the input value is a string. If multiple values are + /// provided, each one is evaluated in order until a string is obtained. + /// If none of the inputs are strings, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const string = "string"; + + /// Asserts that the input value is a number. If multiple values are + /// provided, each one is evaluated in order until a number is obtained. + /// If none of the inputs are numbers, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const number = "number"; + + /// Asserts that the input value is a boolean. If multiple values are + /// provided, each one is evaluated in order until a boolean is obtained. + /// If none of the inputs are booleans, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const boolean = "boolean"; + + /// Asserts that the input value is an object. If multiple values are + /// provided, each one is evaluated in order until an object is obtained. + /// If none of the inputs are objects, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const object = "object"; + + /// Returns a `collator` for use in locale-dependent comparison + /// operations. The `case-sensitive` and `diacritic-sensitive` options + /// default to `false`. The `locale` argument specifies the IETF language + /// tag of the locale to use. If none is provided, the default locale is + /// used. If the requested locale is not available, the `collator` will + /// use a system-defined fallback locale. Use `resolved-locale` to test + /// the results of locale fallback behavior. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const collator = "collator"; + + /// Returns `formatted` text containing annotations for use in + /// mixed-format `text-field` entries. For a `text-field` entries of a + /// string type, following option object's properties are supported: If + /// set, the `text-font` value overrides the font specified by the root + /// layout properties. If set, the `font-scale` value specifies a scaling + /// factor relative to the `text-size` specified in the root layout + /// properties. If set, the `text-color` value overrides the color + /// specified by the root paint properties for this layer. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const format = "format"; + + /// Returns an `image` type for use in `icon-image`, `*-pattern` entries + /// and as a section in the `format` expression. If set, the `image` + /// argument will check that the requested image exists in the style and + /// will return either the resolved image name or `null`, depending on + /// whether or not the image is currently in the style. This validation + /// process is synchronous and requires the image to have been added to + /// the style before requesting it in the `image` argument. + /// + /// Sdk Support + /// basic functionality with js, android, ios + static const image = "image"; + + /// Converts the input number into a string representation using the + /// providing formatting rules. If set, the `locale` argument specifies + /// the locale to use, as a BCP 47 language tag. If set, the `currency` + /// argument specifies an ISO 4217 code to use for currency-style + /// formatting. If set, the `min-fraction-digits` and + /// `max-fraction-digits` arguments specify the minimum and maximum number + /// of fractional digits to include. + /// + /// Sdk Support + /// basic functionality with js + static const numberFormat = "number-format"; + + /// Converts the input value to a string. If the input is `null`, the + /// result is `""`. If the input is a boolean, the result is `"true"` or + /// `"false"`. If the input is a number, it is converted to a string as + /// specified by the ["NumberToString" + /// algorithm](https://tc39.github.io/ecma262/#sec-tostring-applied-to-the-number-type) + /// of the ECMAScript Language Specification. If the input is a color, it + /// is converted to a string of the form `"rgba(r,g,b,a)"`, where `r`, + /// `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from 0 + /// to 1. Otherwise, the input is converted to a string in the format + /// specified by the + /// [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) + /// function of the ECMAScript Language Specification. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const toStringExpression = "to-string"; + + /// Converts the input value to a number, if possible. If the input is + /// `null` or `false`, the result is 0. If the input is `true`, the result + /// is 1. If the input is a string, it is converted to a number as + /// specified by the ["ToNumber Applied to the String Type" + /// algorithm](https://tc39.github.io/ecma262/#sec-tonumber-applied-to-the-string-type) + /// of the ECMAScript Language Specification. If multiple values are + /// provided, each one is evaluated in order until the first successful + /// conversion is obtained. If none of the inputs can be converted, the + /// expression is an error. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const toNumber = "to-number"; + + /// Converts the input value to a boolean. The result is `false` when then + /// input is an empty string, 0, `false`, `null`, or `NaN`; otherwise it + /// is `true`. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const toBoolean = "to-boolean"; + + /// Returns a four-element array containing the input color's red, green, + /// blue, and alpha components, in that order. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const toRgba = "to-rgba"; + + /// Converts the input value to a color. If multiple values are provided, + /// each one is evaluated in order until the first successful conversion + /// is obtained. If none of the inputs can be converted, the expression is + /// an error. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const toColor = "to-color"; + + /// Creates a color value from red, green, and blue components, which must + /// range between 0 and 255, and an alpha component of 1. If any component + /// is out of range, the expression is an error. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const rgb = "rgb"; + + /// Creates a color value from red, green, blue components, which must + /// range between 0 and 255, and an alpha component which must range + /// between 0 and 1. If any component is out of range, the expression is + /// an error. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const rgba = "rgba"; + + /// Retrieves a property value from the current feature's properties, or + /// from another object if a second argument is provided. Returns null if + /// the requested property is missing. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const get = "get"; + + /// Tests for the presence of an property value in the current feature's + /// properties, or from another object if a second argument is provided. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const has = "has"; + + /// Gets the length of an array or string. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const length = "length"; + + /// Gets the feature properties object. Note that in some cases, it may + /// be more efficient to use ["get", "property_name"] directly. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const properties = "properties"; + + /// Retrieves a property value from the current feature's state. Returns + /// null if the requested property is not present on the feature's state. + /// A feature's state is not part of the GeoJSON or vector tile data, and + /// must be set programmatically on each feature. Features are identified + /// by their `id` attribute, which must be an integer or a string that can + /// be cast to an integer. Note that ["feature-state"] can only be used + /// with paint properties that support data-driven styling. + /// + /// Sdk Support + /// basic functionality with js + static const featureState = "feature-state"; + + /// Gets the feature's geometry type: Point, MultiPoint, LineString, + /// MultiLineString, Polygon, MultiPolygon. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const geometryType = "geometry-type"; + + /// Gets the feature's id, if it has one. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const id = "id"; + + /// Gets the current zoom level. Note that in style layout and paint + /// properties, ["zoom"] may only appear as the input to a top-level + /// "step" or "interpolate" expression. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const zoom = "zoom"; + + /// Gets the kernel density estimation of a pixel in a heatmap layer, + /// which is a relative measure of how many data points are crowded around + /// a particular pixel. Can only be used in the `heatmap-color` property. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const heatmapDensity = "heatmap-density"; + + /// Gets the progress along a gradient line. Can only be used in the + /// `line-gradient` property. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const lineProgress = "line-progress"; + + /// Gets the value of a cluster property accumulated so far. Can only be + /// used in the `clusterProperties` option of a clustered GeoJSON source. + /// + /// Sdk Support + /// basic functionality with js + static const accumulated = "accumulated"; + + /// Returns the sum of the inputs. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const plus = "+"; + + /// Returns the product of the inputs. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const multiply = "*"; + + /// For two inputs, returns the result of subtracting the second input + /// from the first. For a single input, returns the result of subtracting + /// it from 0. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const minus = "-"; + + /// Returns the result of floating point division of the first input by + /// the second. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const divide = "/"; + + /// Returns the remainder after integer division of the first input by the + /// second. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const precent = "%"; + + /// Returns the result of raising the first input to the power specified + /// by the second. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const xor = "^"; + + /// Returns the square root of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const sqrt = "sqrt"; + + /// Returns the base-ten logarithm of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const log10 = "log10"; + + /// Returns the natural logarithm of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const ln = "ln"; + + /// Returns the base-two logarithm of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const log2 = "log2"; + + /// Returns the sine of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const sin = "sin"; + + /// Returns the cosine of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const cos = "cos"; + + /// Returns the tangent of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const tan = "tan"; + + /// Returns the arcsine of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const asin = "asin"; + + /// Returns the arccosine of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const acos = "acos"; + + /// Returns the arctangent of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const atan = "atan"; + + /// Returns the minimum value of the inputs. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const min = "min"; + + /// Returns the maximum value of the inputs. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const max = "max"; + + /// Rounds the input to the nearest integer. Halfway values are rounded + /// away from zero. For example, `["round", -1.5]` evaluates to -2. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const round = "round"; + + /// Returns the absolute value of the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const abs = "abs"; + + /// Returns the smallest integer that is greater than or equal to the + /// input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const ceil = "ceil"; + + /// Returns the largest integer that is less than or equal to the input. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const floor = "floor"; + + /// Returns `true` if the input values are equal, `false` otherwise. The + /// comparison is strictly typed: values of different runtime types are + /// always considered unequal. Cases where the types are known to be + /// different at parse time are considered invalid and will produce a + /// parse error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const equal = "=="; + + /// Returns `true` if the input values are not equal, `false` otherwise. + /// The comparison is strictly typed: values of different runtime types + /// are always considered unequal. Cases where the types are known to be + /// different at parse time are considered invalid and will produce a + /// parse error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const notEqual = "!="; + + /// Returns `true` if the first input is strictly greater than the second, + /// `false` otherwise. The arguments are required to be either both + /// strings or both numbers; if during evaluation they are not, expression + /// evaluation produces an error. Cases where this constraint is known not + /// to hold at parse time are considered in valid and will produce a parse + /// error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const larger = ">"; + + /// Returns `true` if the first input is strictly less than the second, + /// `false` otherwise. The arguments are required to be either both + /// strings or both numbers; if during evaluation they are not, expression + /// evaluation produces an error. Cases where this constraint is known not + /// to hold at parse time are considered in valid and will produce a parse + /// error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const smaller = "<"; + + /// Returns `true` if the first input is greater than or equal to the + /// second, `false` otherwise. The arguments are required to be either + /// both strings or both numbers; if during evaluation they are not, + /// expression evaluation produces an error. Cases where this constraint + /// is known not to hold at parse time are considered in valid and will + /// produce a parse error. Accepts an optional `collator` argument to + /// control locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const largerOrEqual = ">="; + + /// Returns `true` if the first input is less than or equal to the second, + /// `false` otherwise. The arguments are required to be either both + /// strings or both numbers; if during evaluation they are not, expression + /// evaluation produces an error. Cases where this constraint is known not + /// to hold at parse time are considered in valid and will produce a parse + /// error. Accepts an optional `collator` argument to control + /// locale-dependent string comparisons. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const smallerOrEqual = "<="; + + /// Returns `true` if all the inputs are `true`, `false` otherwise. The + /// inputs are evaluated in order, and evaluation is short-circuiting: + /// once an input expression evaluates to `false`, the result is `false` + /// and no further input expressions are evaluated. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const all = "all"; + + /// Returns `true` if any of the inputs are `true`, `false` otherwise. The + /// inputs are evaluated in order, and evaluation is short-circuiting: + /// once an input expression evaluates to `true`, the result is `true` and + /// no further input expressions are evaluated. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const any = "any"; + + /// Logical negation. Returns `true` if the input is `false`, and `false` + /// if the input is `true`. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const not = "!"; + + /// Returns `true` if the input string is expected to render legibly. + /// Returns `false` if the input string contains sections that cannot be + /// rendered without potential loss of meaning (e.g. Indic scripts that + /// require complex text shaping, or right-to-left scripts if the the + /// `mapbox-gl-rtl-text` plugin is not in use in Mapbox GL JS). + /// + /// Sdk Support + /// basic functionality with js, android + static const isSupportedScript = "is-supported-script"; + + /// Returns the input string converted to uppercase. Follows the Unicode + /// Default Case Conversion algorithm and the locale-insensitive case + /// mappings in the Unicode Character Database. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const upcase = "upcase"; + + /// Returns the input string converted to lowercase. Follows the Unicode + /// Default Case Conversion algorithm and the locale-insensitive case + /// mappings in the Unicode Character Database. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const downcase = "downcase"; + + /// Returns a `string` consisting of the concatenation of the inputs. Each + /// input is converted to a string as if by `to-string`. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const concat = "concat"; + + /// Returns the IETF language tag of the locale being used by the provided + /// `collator`. This can be used to determine the default system locale, + /// or to determine if a requested locale was successfully loaded. + /// + /// Sdk Support + /// basic functionality with js, android, ios, macos + static const resolvedLocale = "resolved-locale"; } diff --git a/lib/src/layer_properties.dart b/lib/src/layer_properties.dart index 199ecedae..0562416df 100644 --- a/lib/src/layer_properties.dart +++ b/lib/src/layer_properties.dart @@ -17,8 +17,8 @@ class SymbolLayerProperties implements LayerProperties { /// maximum: 1 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconOpacity; /// The color of the icon. This can only be used with sdf icons. @@ -27,8 +27,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: #000000 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconColor; /// The color of the icon's halo. Icon halos can only be used with SDF @@ -38,8 +38,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: rgba(0, 0, 0, 0) /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconHaloColor; /// Distance of halo to the icon outline. @@ -49,8 +49,8 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconHaloWidth; /// Fade out the halo towards the outside. @@ -60,8 +60,8 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconHaloBlur; /// Distance that the icon's anchor is moved from its original placement. @@ -72,7 +72,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: [0, 0] /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconTranslate; /// Controls the frame of reference for `icon-translate`. @@ -86,7 +86,7 @@ class SymbolLayerProperties implements LayerProperties { /// Icons are translated relative to the viewport. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconTranslateAnchor; /// The opacity at which the text will be drawn. @@ -97,8 +97,8 @@ class SymbolLayerProperties implements LayerProperties { /// maximum: 1 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textOpacity; /// The color with which the text will be drawn. @@ -107,8 +107,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: #000000 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textColor; /// The color of the text's halo, which helps it stand out from @@ -118,8 +118,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: rgba(0, 0, 0, 0) /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textHaloColor; /// Distance of halo to the font outline. Max text halo width is 1/4 of @@ -130,8 +130,8 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textHaloWidth; /// The halo's fadeout distance towards the outside. @@ -141,8 +141,8 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textHaloBlur; /// Distance that the text's anchor is moved from its original placement. @@ -153,7 +153,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: [0, 0] /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textTranslate; /// Controls the frame of reference for `text-translate`. @@ -167,7 +167,7 @@ class SymbolLayerProperties implements LayerProperties { /// The text is translated relative to the viewport. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textTranslateAnchor; // Layout Properties @@ -188,7 +188,7 @@ class SymbolLayerProperties implements LayerProperties { /// geometries. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic symbolPlacement; /// Distance between two symbol anchors. @@ -198,7 +198,7 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 1 /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic symbolSpacing; /// If true, the symbols will not cross tile edges to avoid mutual @@ -213,7 +213,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: false /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic symbolAvoidEdges; /// Sorts features in ascending order based on this value. Features with @@ -226,8 +226,8 @@ class SymbolLayerProperties implements LayerProperties { /// Type: number /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic symbolSortKey; /// Controls the order in which overlapping symbols in the same layer are @@ -247,7 +247,7 @@ class SymbolLayerProperties implements LayerProperties { /// with no sorting applied. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic symbolZOrder; /// If true, the icon will be visible even if it collides with other @@ -257,7 +257,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: false /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconAllowOverlap; /// If true, other symbols can be visible even if they collide with the @@ -267,7 +267,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: false /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconIgnorePlacement; /// If true, text will display without their corresponding icons when the @@ -277,7 +277,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: false /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconOptional; /// In combination with `symbol-placement`, determines the rotation @@ -299,7 +299,7 @@ class SymbolLayerProperties implements LayerProperties { /// `line-center`, this is equivalent to `map`. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconRotationAlignment; /// Scales the original size of the icon by the provided factor. The new @@ -311,8 +311,8 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconSize; /// Scales the icon to fit around the associated text. @@ -332,7 +332,7 @@ class SymbolLayerProperties implements LayerProperties { /// The icon is scaled in both x- and y-dimensions. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconTextFit; /// Size of the additional area added to dimensions determined by @@ -342,7 +342,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: [0, 0, 0, 0] /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconTextFitPadding; /// Name of image in sprite to use for drawing an image background. @@ -350,8 +350,8 @@ class SymbolLayerProperties implements LayerProperties { /// Type: resolvedImage /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconImage; /// Rotates the icon clockwise. @@ -360,8 +360,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconRotate; /// Size of the additional area around the icon bounding box used for @@ -372,7 +372,7 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconPadding; /// If true, the icon may be flipped to prevent it from being rendered @@ -382,7 +382,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: false /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconKeepUpright; /// Offset distance of icon from its anchor. Positive values indicate @@ -395,8 +395,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: [0, 0] /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconOffset; /// Part of the icon placed closest to the anchor. @@ -426,8 +426,8 @@ class SymbolLayerProperties implements LayerProperties { /// anchor. /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic iconAnchor; /// Orientation of icon when map is pitched. @@ -443,7 +443,7 @@ class SymbolLayerProperties implements LayerProperties { /// Automatically matches the value of `icon-rotation-alignment`. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic iconPitchAlignment; /// Orientation of text when map is pitched. @@ -459,7 +459,7 @@ class SymbolLayerProperties implements LayerProperties { /// Automatically matches the value of `text-rotation-alignment`. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textPitchAlignment; /// In combination with `symbol-placement`, determines the rotation @@ -481,7 +481,7 @@ class SymbolLayerProperties implements LayerProperties { /// `line-center`, this is equivalent to `map`. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textRotationAlignment; /// Value to use for a text label. If a plain `string` is provided, it @@ -492,8 +492,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textField; /// Font stack to use for displaying text. @@ -502,8 +502,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: [Open Sans Regular, Arial Unicode MS Regular] /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textFont; /// Font size. @@ -513,8 +513,8 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textSize; /// The maximum line width for text wrapping. @@ -524,8 +524,8 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textMaxWidth; /// Text leading value for multi-line text. @@ -534,7 +534,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 1.2 /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textLineHeight; /// Text tracking amount. @@ -543,8 +543,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textLetterSpacing; /// Text justification options. @@ -562,8 +562,8 @@ class SymbolLayerProperties implements LayerProperties { /// The text is aligned to the right. /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textJustify; /// Radial offset of text, in the direction of the symbol's anchor. Useful @@ -574,8 +574,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textRadialOffset; /// To increase the chance of placing high-priority labels on the map, you @@ -609,7 +609,7 @@ class SymbolLayerProperties implements LayerProperties { /// anchor. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textVariableAnchor; /// Part of the text placed closest to the anchor. @@ -639,8 +639,8 @@ class SymbolLayerProperties implements LayerProperties { /// anchor. /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textAnchor; /// Maximum angle change between adjacent characters. @@ -649,7 +649,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 45 /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textMaxAngle; /// The property allows control over a symbol's orientation. Note that the @@ -670,7 +670,7 @@ class SymbolLayerProperties implements LayerProperties { /// point placement would be laid out vertically. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textWritingMode; /// Rotates the text clockwise. @@ -679,8 +679,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textRotate; /// Size of the additional area around the text bounding box used for @@ -691,7 +691,7 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textPadding; /// If true, the text may be flipped vertically to prevent it from being @@ -701,7 +701,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: true /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textKeepUpright; /// Specifies how to capitalize text, similar to the CSS `text-transform` @@ -718,8 +718,8 @@ class SymbolLayerProperties implements LayerProperties { /// Forces all letters to be displayed in lowercase. /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textTransform; /// Offset distance of text from its anchor. Positive values indicate @@ -732,8 +732,8 @@ class SymbolLayerProperties implements LayerProperties { /// default: [0, 0] /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic textOffset; /// If true, the text will be visible even if it collides with other @@ -743,7 +743,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: false /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textAllowOverlap; /// If true, other symbols can be visible even if they collide with the @@ -753,7 +753,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: false /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textIgnorePlacement; /// If true, icons will display without their corresponding text when the @@ -763,7 +763,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: false /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic textOptional; /// Whether this layer is displayed. @@ -777,7 +777,7 @@ class SymbolLayerProperties implements LayerProperties { /// The layer is not shown. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic visibility; const SymbolLayerProperties({ @@ -1041,8 +1041,8 @@ class CircleLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic circleRadius; /// The fill color of the circle. @@ -1051,8 +1051,8 @@ class CircleLayerProperties implements LayerProperties { /// default: #000000 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic circleColor; /// Amount to blur the circle. 1 blurs the circle such that only the @@ -1062,8 +1062,8 @@ class CircleLayerProperties implements LayerProperties { /// default: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic circleBlur; /// The opacity at which the circle will be drawn. @@ -1074,8 +1074,8 @@ class CircleLayerProperties implements LayerProperties { /// maximum: 1 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic circleOpacity; /// The geometry's offset. Values are [x, y] where negatives indicate left @@ -1085,7 +1085,7 @@ class CircleLayerProperties implements LayerProperties { /// default: [0, 0] /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic circleTranslate; /// Controls the frame of reference for `circle-translate`. @@ -1099,7 +1099,7 @@ class CircleLayerProperties implements LayerProperties { /// The circle is translated relative to the viewport. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic circleTranslateAnchor; /// Controls the scaling behavior of the circle when the map is pitched. @@ -1114,7 +1114,7 @@ class CircleLayerProperties implements LayerProperties { /// Circles are not scaled. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic circlePitchScale; /// Orientation of circle when map is pitched. @@ -1128,7 +1128,7 @@ class CircleLayerProperties implements LayerProperties { /// The circle is aligned to the plane of the viewport. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic circlePitchAlignment; /// The width of the circle's stroke. Strokes are placed outside of the @@ -1139,8 +1139,8 @@ class CircleLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic circleStrokeWidth; /// The stroke color of the circle. @@ -1149,8 +1149,8 @@ class CircleLayerProperties implements LayerProperties { /// default: #000000 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic circleStrokeColor; /// The opacity of the circle's stroke. @@ -1161,8 +1161,8 @@ class CircleLayerProperties implements LayerProperties { /// maximum: 1 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic circleStrokeOpacity; // Layout Properties @@ -1187,7 +1187,7 @@ class CircleLayerProperties implements LayerProperties { /// The layer is not shown. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic visibility; const CircleLayerProperties({ @@ -1280,8 +1280,8 @@ class LineLayerProperties implements LayerProperties { /// maximum: 1 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic lineOpacity; /// The color with which the line will be drawn. @@ -1290,8 +1290,8 @@ class LineLayerProperties implements LayerProperties { /// default: #000000 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic lineColor; /// The geometry's offset. Values are [x, y] where negatives indicate left @@ -1301,7 +1301,7 @@ class LineLayerProperties implements LayerProperties { /// default: [0, 0] /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic lineTranslate; /// Controls the frame of reference for `line-translate`. @@ -1315,7 +1315,7 @@ class LineLayerProperties implements LayerProperties { /// The line is translated relative to the viewport. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic lineTranslateAnchor; /// Stroke thickness. @@ -1325,8 +1325,8 @@ class LineLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic lineWidth; /// Draws a line casing outside of a line's actual path. Value indicates @@ -1337,8 +1337,8 @@ class LineLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic lineGapWidth; /// The line's offset. For linear features, a positive value offsets the @@ -1350,8 +1350,8 @@ class LineLayerProperties implements LayerProperties { /// default: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic lineOffset; /// Blur applied to the line, in pixels. @@ -1361,8 +1361,8 @@ class LineLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic lineBlur; /// Specifies the lengths of the alternating dashes and gaps that form the @@ -1377,7 +1377,7 @@ class LineLayerProperties implements LayerProperties { /// minimum: 0 /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic lineDasharray; /// Name of image in sprite to use for drawing image lines. For seamless @@ -1388,8 +1388,8 @@ class LineLayerProperties implements LayerProperties { /// Type: resolvedImage /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android macos ios + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, macos, ios final dynamic linePattern; /// Defines a gradient with which to color a line feature. Can only be @@ -1398,7 +1398,7 @@ class LineLayerProperties implements LayerProperties { /// Type: color /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic lineGradient; // Layout Properties @@ -1419,7 +1419,7 @@ class LineLayerProperties implements LayerProperties { /// of the line at a distance of one-half of the line's width. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic lineCap; /// The display of lines when joining. @@ -1439,8 +1439,8 @@ class LineLayerProperties implements LayerProperties { /// sides beyond the endpoint of the path until they meet. /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic lineJoin; /// Used to automatically convert miter joins to bevel joins for sharp @@ -1450,7 +1450,7 @@ class LineLayerProperties implements LayerProperties { /// default: 2 /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic lineMiterLimit; /// Used to automatically convert round joins to miter joins for shallow @@ -1460,7 +1460,7 @@ class LineLayerProperties implements LayerProperties { /// default: 1.05 /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic lineRoundLimit; /// Sorts features in ascending order based on this value. Features with a @@ -1484,7 +1484,7 @@ class LineLayerProperties implements LayerProperties { /// The layer is not shown. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic visibility; const LineLayerProperties({ @@ -1589,7 +1589,7 @@ class FillLayerProperties implements LayerProperties { /// default: true /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic fillAntialias; /// The opacity of the entire fill layer. In contrast to the `fill-color`, @@ -1602,8 +1602,8 @@ class FillLayerProperties implements LayerProperties { /// maximum: 1 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic fillOpacity; /// The color of the filled part of this layer. This color can be @@ -1614,8 +1614,8 @@ class FillLayerProperties implements LayerProperties { /// default: #000000 /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic fillColor; /// The outline color of the fill. Matches the value of `fill-color` if @@ -1624,8 +1624,8 @@ class FillLayerProperties implements LayerProperties { /// Type: color /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android ios macos + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, ios, macos final dynamic fillOutlineColor; /// The geometry's offset. Values are [x, y] where negatives indicate left @@ -1635,7 +1635,7 @@ class FillLayerProperties implements LayerProperties { /// default: [0, 0] /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic fillTranslate; /// Controls the frame of reference for `fill-translate`. @@ -1649,7 +1649,7 @@ class FillLayerProperties implements LayerProperties { /// The fill is translated relative to the viewport. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic fillTranslateAnchor; /// Name of image in sprite to use for drawing image fills. For seamless @@ -1660,8 +1660,8 @@ class FillLayerProperties implements LayerProperties { /// Type: resolvedImage /// /// Sdk Support - /// basic functionality with js android ios macos - /// data-driven styling with js android macos ios + /// basic functionality with js, android, ios, macos + /// data-driven styling with js, android, macos, ios final dynamic fillPattern; // Layout Properties @@ -1686,7 +1686,7 @@ class FillLayerProperties implements LayerProperties { /// The layer is not shown. /// /// Sdk Support - /// basic functionality with js android ios macos + /// basic functionality with js, android, ios, macos final dynamic visibility; const FillLayerProperties({ diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index 17bd13843..3c9222b67 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -159,10 +159,10 @@ List buildDocSplit(Map item) { result.add(""); result.add("Sdk Support"); if (basic != null && basic.isNotEmpty) { - result.add(" basic functionality with " + basic.keys.join(" ")); + result.add(" basic functionality with " + basic.keys.join(", ")); } if (dataDriven != null && dataDriven.isNotEmpty) { - result.add(" data-driven styling with " + dataDriven.keys.join(" ")); + result.add(" data-driven styling with " + dataDriven.keys.join(", ")); } } diff --git a/scripts/templates/layer_expressions.dart.template b/scripts/templates/layer_expressions.dart.template index 8ea98d4b9..5f02944a8 100644 --- a/scripts/templates/layer_expressions.dart.template +++ b/scripts/templates/layer_expressions.dart.template @@ -4,11 +4,11 @@ part of mapbox_gl; class Expressions{ - {{#expressions}} - {{#docSplit}} - /// {{{part}}} - {{/docSplit}} - static const {{valueAsCamelCase}} = "{{{value}}}"; + {{#expressions}} + {{#docSplit}} + /// {{{part}}} + {{/docSplit}} + static const {{valueAsCamelCase}} = "{{{value}}}"; - {{/expressions}} + {{/expressions}} } From 807f93c4c827cf38439e2e00a49ab7c3fed81d1a Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Tue, 26 Oct 2021 19:09:44 +0200 Subject: [PATCH 25/33] deprecated addLayer fixed issue with remove source --- example/lib/place_source.dart | 5 +++-- lib/src/controller.dart | 17 +++++++++++++++-- .../lib/src/method_channel_mapbox_gl.dart | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/example/lib/place_source.dart b/example/lib/place_source.dart index 1a92855fc..aa610832a 100644 --- a/example/lib/place_source.dart +++ b/example/lib/place_source.dart @@ -68,12 +68,13 @@ class PlaceSymbolBodyState extends State { } Future addLayer(String imageLayerId, String imageSourceId) { - return controller.addLayer(imageLayerId, imageSourceId); + return controller.addImageLayer(imageLayerId, imageSourceId); } Future addLayerBelow( String imageLayerId, String imageSourceId, String belowLayerId) { - return controller.addLayerBelow(imageLayerId, imageSourceId, belowLayerId); + return controller.addImageLayerBelow( + imageLayerId, imageSourceId, belowLayerId); } Future removeLayer(String imageLayerId) { diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 9645ca6d1..3ca1adbc2 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -850,12 +850,25 @@ class MapboxMapController extends ChangeNotifier { return _mapboxGlPlatform.removeImageSource(imageSourceId); } - /// Adds a Mapbox image layer to the map's style at render time. Only works for image sources! - Future addLayer(String layerId, String imageSourceId) { + /// Adds a Mapbox image layer to the map's style at render time. + Future addImageLayer(String layerId, String imageSourceId) { return _mapboxGlPlatform.addLayer(layerId, imageSourceId); } + /// Adds a Mapbox image layer below the layer provided with belowLayerId to the map's style at render time. + Future addImageLayerBelow( + String layerId, String sourceId, String imageSourceId) { + return _mapboxGlPlatform.addLayerBelow(layerId, sourceId, imageSourceId); + } + + /// Adds a Mapbox image layer to the map's style at render time. Only works for image sources! + @Deprecated("This method was renamed to addImageLayer for clarity.") + Future addLayer(String imageLayerId, String imageSourceId) { + return _mapboxGlPlatform.addLayer(imageLayerId, imageSourceId); + } + /// Adds a Mapbox image layer below the layer provided with belowLayerId to the map's style at render time. Only works for image sources! + @Deprecated("This method was renamed to addImageLayerBelow for clarity.") Future addLayerBelow( String layerId, String sourceId, String imageSourceId) { return _mapboxGlPlatform.addLayerBelow(layerId, sourceId, imageSourceId); diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index 68d5dec2e..ae7aaea7a 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -693,7 +693,7 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { Future removeLayer(String layerId) async { try { return await _channel.invokeMethod( - 'style#removeLayer', {'imageLayerId': layerId}); + 'style#removeLayer', {'layerId': layerId}); } on PlatformException catch (e) { return new Future.error(e); } From f205d7ea0710554c8505ac4457694bc0ea8bb216 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Tue, 26 Oct 2021 19:13:50 +0200 Subject: [PATCH 26/33] added colon to Sdk Support --- example/lib/main.dart | 3 +- lib/src/layer_expressions.dart | 158 +++++++++++++-------------- lib/src/layer_properties.dart | 190 ++++++++++++++++----------------- scripts/lib/generate.dart | 2 +- 4 files changed, 177 insertions(+), 176 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 7ab20be1a..3983e85d7 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -46,7 +46,8 @@ final List _allPages = [ class MapsDemo extends StatelessWidget { //FIXME: Add your Mapbox access token here - static const String ACCESS_TOKEN = "YOUR_TOKEN_HERE"; + static const String ACCESS_TOKEN = + "pk.eyJ1Ijoib2NlbGwiLCJhIjoiY2pvdTE5bnhoMTc1cDNrcWlha2todGFkYiJ9.hW9Q853ix58dukevFHX1pw"; void _pushPage(BuildContext context, ExamplePage page) async { if (!kIsWeb) { diff --git a/lib/src/layer_expressions.dart b/lib/src/layer_expressions.dart index 4d612e1ad..5ae943209 100644 --- a/lib/src/layer_expressions.dart +++ b/lib/src/layer_expressions.dart @@ -7,19 +7,19 @@ class Expressions{ /// Binds expressions to named variables, which can then be referenced in /// the result expression using ["var", "variable_name"]. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const let = "let"; /// References variable bound using "let". /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const varExpression = "var"; /// Provides a literal array or object value. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const literal = "literal"; @@ -28,27 +28,27 @@ class Expressions{ /// not of the asserted type, then this assertion will cause the whole /// expression to be aborted. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const array = "array"; /// Retrieves an item from an array. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const at = "at"; /// Determines whether an item exists in an array or a substring exists in /// a string. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js static const inExpression = "in"; /// Selects the first output whose corresponding test condition evaluates /// to true, or the fallback value otherwise. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const caseExpression = "case"; @@ -62,14 +62,14 @@ class Expressions{ /// operator.Each label must be unique. If the input type does not match /// the type of the labels, the result will be the fallback value. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const match = "match"; /// Evaluates each expression in turn until the first non-null value is /// obtained, and returns that value. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const coalesce = "coalesce"; @@ -80,7 +80,7 @@ class Expressions{ /// Returns the output value of the stop just less than the input, or the /// first output if the input is less than the first stop. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const step = "step"; @@ -98,7 +98,7 @@ class Expressions{ /// linearly.- `["cubic-bezier", x1, y1, x2, y2]`: interpolates using the /// cubic bezier curve defined by the given control points. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const interpolate = "interpolate"; @@ -107,7 +107,7 @@ class Expressions{ /// output type must be `color`, and the interpolation is performed in the /// Hue-Chroma-Luminance color space. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js static const interpolateHcl = "interpolate-hcl"; @@ -116,31 +116,31 @@ class Expressions{ /// output type must be `color`, and the interpolation is performed in the /// CIELAB color space. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js static const interpolateLab = "interpolate-lab"; /// Returns mathematical constant ln(2). /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const ln2 = "ln2"; /// Returns the mathematical constant pi. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const pi = "pi"; /// Returns the mathematical constant e. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const e = "e"; /// Returns a string describing the type of the given value. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const typeof = "typeof"; @@ -148,7 +148,7 @@ class Expressions{ /// provided, each one is evaluated in order until a string is obtained. /// If none of the inputs are strings, the expression is an error. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const string = "string"; @@ -156,7 +156,7 @@ class Expressions{ /// provided, each one is evaluated in order until a number is obtained. /// If none of the inputs are numbers, the expression is an error. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const number = "number"; @@ -164,7 +164,7 @@ class Expressions{ /// provided, each one is evaluated in order until a boolean is obtained. /// If none of the inputs are booleans, the expression is an error. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const boolean = "boolean"; @@ -172,7 +172,7 @@ class Expressions{ /// provided, each one is evaluated in order until an object is obtained. /// If none of the inputs are objects, the expression is an error. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const object = "object"; @@ -184,7 +184,7 @@ class Expressions{ /// use a system-defined fallback locale. Use `resolved-locale` to test /// the results of locale fallback behavior. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const collator = "collator"; @@ -197,7 +197,7 @@ class Expressions{ /// properties. If set, the `text-color` value overrides the color /// specified by the root paint properties for this layer. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const format = "format"; @@ -209,7 +209,7 @@ class Expressions{ /// process is synchronous and requires the image to have been added to /// the style before requesting it in the `image` argument. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios static const image = "image"; @@ -221,7 +221,7 @@ class Expressions{ /// `max-fraction-digits` arguments specify the minimum and maximum number /// of fractional digits to include. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js static const numberFormat = "number-format"; @@ -238,7 +238,7 @@ class Expressions{ /// [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) /// function of the ECMAScript Language Specification. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const toStringExpression = "to-string"; @@ -252,7 +252,7 @@ class Expressions{ /// conversion is obtained. If none of the inputs can be converted, the /// expression is an error. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const toNumber = "to-number"; @@ -260,14 +260,14 @@ class Expressions{ /// input is an empty string, 0, `false`, `null`, or `NaN`; otherwise it /// is `true`. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const toBoolean = "to-boolean"; /// Returns a four-element array containing the input color's red, green, /// blue, and alpha components, in that order. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const toRgba = "to-rgba"; @@ -276,7 +276,7 @@ class Expressions{ /// is obtained. If none of the inputs can be converted, the expression is /// an error. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const toColor = "to-color"; @@ -284,7 +284,7 @@ class Expressions{ /// range between 0 and 255, and an alpha component of 1. If any component /// is out of range, the expression is an error. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const rgb = "rgb"; @@ -293,7 +293,7 @@ class Expressions{ /// between 0 and 1. If any component is out of range, the expression is /// an error. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const rgba = "rgba"; @@ -301,27 +301,27 @@ class Expressions{ /// from another object if a second argument is provided. Returns null if /// the requested property is missing. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const get = "get"; /// Tests for the presence of an property value in the current feature's /// properties, or from another object if a second argument is provided. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const has = "has"; /// Gets the length of an array or string. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const length = "length"; /// Gets the feature properties object. Note that in some cases, it may /// be more efficient to use ["get", "property_name"] directly. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const properties = "properties"; @@ -333,20 +333,20 @@ class Expressions{ /// be cast to an integer. Note that ["feature-state"] can only be used /// with paint properties that support data-driven styling. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js static const featureState = "feature-state"; /// Gets the feature's geometry type: Point, MultiPoint, LineString, /// MultiLineString, Polygon, MultiPolygon. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const geometryType = "geometry-type"; /// Gets the feature's id, if it has one. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const id = "id"; @@ -354,7 +354,7 @@ class Expressions{ /// properties, ["zoom"] may only appear as the input to a top-level /// "step" or "interpolate" expression. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const zoom = "zoom"; @@ -362,33 +362,33 @@ class Expressions{ /// which is a relative measure of how many data points are crowded around /// a particular pixel. Can only be used in the `heatmap-color` property. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const heatmapDensity = "heatmap-density"; /// Gets the progress along a gradient line. Can only be used in the /// `line-gradient` property. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const lineProgress = "line-progress"; /// Gets the value of a cluster property accumulated so far. Can only be /// used in the `clusterProperties` option of a clustered GeoJSON source. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js static const accumulated = "accumulated"; /// Returns the sum of the inputs. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const plus = "+"; /// Returns the product of the inputs. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const multiply = "*"; @@ -396,126 +396,126 @@ class Expressions{ /// from the first. For a single input, returns the result of subtracting /// it from 0. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const minus = "-"; /// Returns the result of floating point division of the first input by /// the second. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const divide = "/"; /// Returns the remainder after integer division of the first input by the /// second. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const precent = "%"; /// Returns the result of raising the first input to the power specified /// by the second. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const xor = "^"; /// Returns the square root of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const sqrt = "sqrt"; /// Returns the base-ten logarithm of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const log10 = "log10"; /// Returns the natural logarithm of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const ln = "ln"; /// Returns the base-two logarithm of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const log2 = "log2"; /// Returns the sine of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const sin = "sin"; /// Returns the cosine of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const cos = "cos"; /// Returns the tangent of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const tan = "tan"; /// Returns the arcsine of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const asin = "asin"; /// Returns the arccosine of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const acos = "acos"; /// Returns the arctangent of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const atan = "atan"; /// Returns the minimum value of the inputs. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const min = "min"; /// Returns the maximum value of the inputs. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const max = "max"; /// Rounds the input to the nearest integer. Halfway values are rounded /// away from zero. For example, `["round", -1.5]` evaluates to -2. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const round = "round"; /// Returns the absolute value of the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const abs = "abs"; /// Returns the smallest integer that is greater than or equal to the /// input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const ceil = "ceil"; /// Returns the largest integer that is less than or equal to the input. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const floor = "floor"; @@ -526,7 +526,7 @@ class Expressions{ /// parse error. Accepts an optional `collator` argument to control /// locale-dependent string comparisons. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const equal = "=="; @@ -537,7 +537,7 @@ class Expressions{ /// parse error. Accepts an optional `collator` argument to control /// locale-dependent string comparisons. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const notEqual = "!="; @@ -549,7 +549,7 @@ class Expressions{ /// error. Accepts an optional `collator` argument to control /// locale-dependent string comparisons. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const larger = ">"; @@ -561,7 +561,7 @@ class Expressions{ /// error. Accepts an optional `collator` argument to control /// locale-dependent string comparisons. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const smaller = "<"; @@ -573,7 +573,7 @@ class Expressions{ /// produce a parse error. Accepts an optional `collator` argument to /// control locale-dependent string comparisons. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const largerOrEqual = ">="; @@ -585,7 +585,7 @@ class Expressions{ /// error. Accepts an optional `collator` argument to control /// locale-dependent string comparisons. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const smallerOrEqual = "<="; @@ -594,7 +594,7 @@ class Expressions{ /// once an input expression evaluates to `false`, the result is `false` /// and no further input expressions are evaluated. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const all = "all"; @@ -603,14 +603,14 @@ class Expressions{ /// once an input expression evaluates to `true`, the result is `true` and /// no further input expressions are evaluated. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const any = "any"; /// Logical negation. Returns `true` if the input is `false`, and `false` /// if the input is `true`. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const not = "!"; @@ -620,7 +620,7 @@ class Expressions{ /// require complex text shaping, or right-to-left scripts if the the /// `mapbox-gl-rtl-text` plugin is not in use in Mapbox GL JS). /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android static const isSupportedScript = "is-supported-script"; @@ -628,7 +628,7 @@ class Expressions{ /// Default Case Conversion algorithm and the locale-insensitive case /// mappings in the Unicode Character Database. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const upcase = "upcase"; @@ -636,14 +636,14 @@ class Expressions{ /// Default Case Conversion algorithm and the locale-insensitive case /// mappings in the Unicode Character Database. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const downcase = "downcase"; /// Returns a `string` consisting of the concatenation of the inputs. Each /// input is converted to a string as if by `to-string`. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const concat = "concat"; @@ -651,7 +651,7 @@ class Expressions{ /// `collator`. This can be used to determine the default system locale, /// or to determine if a requested locale was successfully loaded. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos static const resolvedLocale = "resolved-locale"; diff --git a/lib/src/layer_properties.dart b/lib/src/layer_properties.dart index 0562416df..e24f4431b 100644 --- a/lib/src/layer_properties.dart +++ b/lib/src/layer_properties.dart @@ -16,7 +16,7 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// maximum: 1 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconOpacity; @@ -26,7 +26,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: color /// default: #000000 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconColor; @@ -37,7 +37,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: color /// default: rgba(0, 0, 0, 0) /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconHaloColor; @@ -48,7 +48,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 0 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconHaloWidth; @@ -59,7 +59,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 0 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconHaloBlur; @@ -71,7 +71,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: array /// default: [0, 0] /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconTranslate; @@ -85,7 +85,7 @@ class SymbolLayerProperties implements LayerProperties { /// "viewport" /// Icons are translated relative to the viewport. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconTranslateAnchor; @@ -96,7 +96,7 @@ class SymbolLayerProperties implements LayerProperties { /// minimum: 0 /// maximum: 1 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textOpacity; @@ -106,7 +106,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: color /// default: #000000 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textColor; @@ -117,7 +117,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: color /// default: rgba(0, 0, 0, 0) /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textHaloColor; @@ -129,7 +129,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 0 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textHaloWidth; @@ -140,7 +140,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 0 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textHaloBlur; @@ -152,7 +152,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: array /// default: [0, 0] /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textTranslate; @@ -166,7 +166,7 @@ class SymbolLayerProperties implements LayerProperties { /// "viewport" /// The text is translated relative to the viewport. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textTranslateAnchor; @@ -187,7 +187,7 @@ class SymbolLayerProperties implements LayerProperties { /// that a single feature in a vector tile may contain multiple line /// geometries. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic symbolPlacement; @@ -197,7 +197,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 250 /// minimum: 1 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic symbolSpacing; @@ -212,7 +212,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: boolean /// default: false /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic symbolAvoidEdges; @@ -225,7 +225,7 @@ class SymbolLayerProperties implements LayerProperties { /// /// Type: number /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic symbolSortKey; @@ -246,7 +246,7 @@ class SymbolLayerProperties implements LayerProperties { /// Symbols will be rendered in the same order as the source data /// with no sorting applied. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic symbolZOrder; @@ -256,7 +256,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: boolean /// default: false /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconAllowOverlap; @@ -266,7 +266,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: boolean /// default: false /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconIgnorePlacement; @@ -276,7 +276,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: boolean /// default: false /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconOptional; @@ -298,7 +298,7 @@ class SymbolLayerProperties implements LayerProperties { /// `viewport`. When `symbol-placement` is set to `line` or /// `line-center`, this is equivalent to `map`. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconRotationAlignment; @@ -310,7 +310,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 1 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconSize; @@ -331,7 +331,7 @@ class SymbolLayerProperties implements LayerProperties { /// "both" /// The icon is scaled in both x- and y-dimensions. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconTextFit; @@ -341,7 +341,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: array /// default: [0, 0, 0, 0] /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconTextFitPadding; @@ -349,7 +349,7 @@ class SymbolLayerProperties implements LayerProperties { /// /// Type: resolvedImage /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconImage; @@ -359,7 +359,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: number /// default: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconRotate; @@ -371,7 +371,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 2 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconPadding; @@ -381,7 +381,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: boolean /// default: false /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconKeepUpright; @@ -394,7 +394,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: array /// default: [0, 0] /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconOffset; @@ -425,7 +425,7 @@ class SymbolLayerProperties implements LayerProperties { /// The bottom right corner of the icon is placed closest to the /// anchor. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic iconAnchor; @@ -442,7 +442,7 @@ class SymbolLayerProperties implements LayerProperties { /// "auto" /// Automatically matches the value of `icon-rotation-alignment`. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic iconPitchAlignment; @@ -458,7 +458,7 @@ class SymbolLayerProperties implements LayerProperties { /// "auto" /// Automatically matches the value of `text-rotation-alignment`. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textPitchAlignment; @@ -480,7 +480,7 @@ class SymbolLayerProperties implements LayerProperties { /// `viewport`. When `symbol-placement` is set to `line` or /// `line-center`, this is equivalent to `map`. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textRotationAlignment; @@ -491,7 +491,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: formatted /// default: /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textField; @@ -501,7 +501,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: array /// default: [Open Sans Regular, Arial Unicode MS Regular] /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textFont; @@ -512,7 +512,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 16 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textSize; @@ -523,7 +523,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 10 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textMaxWidth; @@ -533,7 +533,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: number /// default: 1.2 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textLineHeight; @@ -542,7 +542,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: number /// default: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textLetterSpacing; @@ -561,7 +561,7 @@ class SymbolLayerProperties implements LayerProperties { /// "right" /// The text is aligned to the right. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textJustify; @@ -573,7 +573,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: number /// default: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textRadialOffset; @@ -608,7 +608,7 @@ class SymbolLayerProperties implements LayerProperties { /// The bottom right corner of the text is placed closest to the /// anchor. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textVariableAnchor; @@ -638,7 +638,7 @@ class SymbolLayerProperties implements LayerProperties { /// The bottom right corner of the text is placed closest to the /// anchor. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textAnchor; @@ -648,7 +648,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: number /// default: 45 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textMaxAngle; @@ -669,7 +669,7 @@ class SymbolLayerProperties implements LayerProperties { /// If a text's language supports vertical writing mode, symbols with /// point placement would be laid out vertically. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textWritingMode; @@ -678,7 +678,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: number /// default: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textRotate; @@ -690,7 +690,7 @@ class SymbolLayerProperties implements LayerProperties { /// default: 2 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textPadding; @@ -700,7 +700,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: boolean /// default: true /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textKeepUpright; @@ -717,7 +717,7 @@ class SymbolLayerProperties implements LayerProperties { /// "lowercase" /// Forces all letters to be displayed in lowercase. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textTransform; @@ -731,7 +731,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: array /// default: [0, 0] /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic textOffset; @@ -742,7 +742,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: boolean /// default: false /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textAllowOverlap; @@ -752,7 +752,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: boolean /// default: false /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textIgnorePlacement; @@ -762,7 +762,7 @@ class SymbolLayerProperties implements LayerProperties { /// Type: boolean /// default: false /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic textOptional; @@ -776,7 +776,7 @@ class SymbolLayerProperties implements LayerProperties { /// "none" /// The layer is not shown. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic visibility; @@ -1040,7 +1040,7 @@ class CircleLayerProperties implements LayerProperties { /// default: 5 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic circleRadius; @@ -1050,7 +1050,7 @@ class CircleLayerProperties implements LayerProperties { /// Type: color /// default: #000000 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic circleColor; @@ -1061,7 +1061,7 @@ class CircleLayerProperties implements LayerProperties { /// Type: number /// default: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic circleBlur; @@ -1073,7 +1073,7 @@ class CircleLayerProperties implements LayerProperties { /// minimum: 0 /// maximum: 1 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic circleOpacity; @@ -1084,7 +1084,7 @@ class CircleLayerProperties implements LayerProperties { /// Type: array /// default: [0, 0] /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic circleTranslate; @@ -1098,7 +1098,7 @@ class CircleLayerProperties implements LayerProperties { /// "viewport" /// The circle is translated relative to the viewport. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic circleTranslateAnchor; @@ -1113,7 +1113,7 @@ class CircleLayerProperties implements LayerProperties { /// "viewport" /// Circles are not scaled. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic circlePitchScale; @@ -1127,7 +1127,7 @@ class CircleLayerProperties implements LayerProperties { /// "viewport" /// The circle is aligned to the plane of the viewport. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic circlePitchAlignment; @@ -1138,7 +1138,7 @@ class CircleLayerProperties implements LayerProperties { /// default: 0 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic circleStrokeWidth; @@ -1148,7 +1148,7 @@ class CircleLayerProperties implements LayerProperties { /// Type: color /// default: #000000 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic circleStrokeColor; @@ -1160,7 +1160,7 @@ class CircleLayerProperties implements LayerProperties { /// minimum: 0 /// maximum: 1 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic circleStrokeOpacity; @@ -1171,7 +1171,7 @@ class CircleLayerProperties implements LayerProperties { /// /// Type: number /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js /// data-driven styling with js final dynamic circleSortKey; @@ -1186,7 +1186,7 @@ class CircleLayerProperties implements LayerProperties { /// "none" /// The layer is not shown. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic visibility; @@ -1279,7 +1279,7 @@ class LineLayerProperties implements LayerProperties { /// minimum: 0 /// maximum: 1 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic lineOpacity; @@ -1289,7 +1289,7 @@ class LineLayerProperties implements LayerProperties { /// Type: color /// default: #000000 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic lineColor; @@ -1300,7 +1300,7 @@ class LineLayerProperties implements LayerProperties { /// Type: array /// default: [0, 0] /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic lineTranslate; @@ -1314,7 +1314,7 @@ class LineLayerProperties implements LayerProperties { /// "viewport" /// The line is translated relative to the viewport. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic lineTranslateAnchor; @@ -1324,7 +1324,7 @@ class LineLayerProperties implements LayerProperties { /// default: 1 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic lineWidth; @@ -1336,7 +1336,7 @@ class LineLayerProperties implements LayerProperties { /// default: 0 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic lineGapWidth; @@ -1349,7 +1349,7 @@ class LineLayerProperties implements LayerProperties { /// Type: number /// default: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic lineOffset; @@ -1360,7 +1360,7 @@ class LineLayerProperties implements LayerProperties { /// default: 0 /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic lineBlur; @@ -1376,7 +1376,7 @@ class LineLayerProperties implements LayerProperties { /// Type: array /// minimum: 0 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic lineDasharray; @@ -1387,7 +1387,7 @@ class LineLayerProperties implements LayerProperties { /// /// Type: resolvedImage /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, macos, ios final dynamic linePattern; @@ -1397,7 +1397,7 @@ class LineLayerProperties implements LayerProperties { /// /// Type: color /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic lineGradient; @@ -1418,7 +1418,7 @@ class LineLayerProperties implements LayerProperties { /// A cap with a squared-off end which is drawn beyond the endpoint /// of the line at a distance of one-half of the line's width. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic lineCap; @@ -1438,7 +1438,7 @@ class LineLayerProperties implements LayerProperties { /// A join with a sharp, angled corner which is drawn with the outer /// sides beyond the endpoint of the path until they meet. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic lineJoin; @@ -1449,7 +1449,7 @@ class LineLayerProperties implements LayerProperties { /// Type: number /// default: 2 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic lineMiterLimit; @@ -1459,7 +1459,7 @@ class LineLayerProperties implements LayerProperties { /// Type: number /// default: 1.05 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic lineRoundLimit; @@ -1468,7 +1468,7 @@ class LineLayerProperties implements LayerProperties { /// /// Type: number /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js /// data-driven styling with js final dynamic lineSortKey; @@ -1483,7 +1483,7 @@ class LineLayerProperties implements LayerProperties { /// "none" /// The layer is not shown. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic visibility; @@ -1588,7 +1588,7 @@ class FillLayerProperties implements LayerProperties { /// Type: boolean /// default: true /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic fillAntialias; @@ -1601,7 +1601,7 @@ class FillLayerProperties implements LayerProperties { /// minimum: 0 /// maximum: 1 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic fillOpacity; @@ -1613,7 +1613,7 @@ class FillLayerProperties implements LayerProperties { /// Type: color /// default: #000000 /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic fillColor; @@ -1623,7 +1623,7 @@ class FillLayerProperties implements LayerProperties { /// /// Type: color /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, ios, macos final dynamic fillOutlineColor; @@ -1634,7 +1634,7 @@ class FillLayerProperties implements LayerProperties { /// Type: array /// default: [0, 0] /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic fillTranslate; @@ -1648,7 +1648,7 @@ class FillLayerProperties implements LayerProperties { /// "viewport" /// The fill is translated relative to the viewport. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic fillTranslateAnchor; @@ -1659,7 +1659,7 @@ class FillLayerProperties implements LayerProperties { /// /// Type: resolvedImage /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos /// data-driven styling with js, android, macos, ios final dynamic fillPattern; @@ -1670,7 +1670,7 @@ class FillLayerProperties implements LayerProperties { /// /// Type: number /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js /// data-driven styling with js final dynamic fillSortKey; @@ -1685,7 +1685,7 @@ class FillLayerProperties implements LayerProperties { /// "none" /// The layer is not shown. /// - /// Sdk Support + /// Sdk Support: /// basic functionality with js, android, ios, macos final dynamic visibility; diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index 3c9222b67..8931e3e7f 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -157,7 +157,7 @@ List buildDocSplit(Map item) { final Map? dataDriven = sdkSupport["data-driven styling"]; result.add(""); - result.add("Sdk Support"); + result.add("Sdk Support:"); if (basic != null && basic.isNotEmpty) { result.add(" basic functionality with " + basic.keys.join(", ")); } From ad3460415262d0bc761e267560529c87fa63a7a1 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Tue, 26 Oct 2021 19:18:42 +0200 Subject: [PATCH 27/33] removed token --- example/lib/main.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 3983e85d7..7ab20be1a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -46,8 +46,7 @@ final List _allPages = [ class MapsDemo extends StatelessWidget { //FIXME: Add your Mapbox access token here - static const String ACCESS_TOKEN = - "pk.eyJ1Ijoib2NlbGwiLCJhIjoiY2pvdTE5bnhoMTc1cDNrcWlha2todGFkYiJ9.hW9Q853ix58dukevFHX1pw"; + static const String ACCESS_TOKEN = "YOUR_TOKEN_HERE"; void _pushPage(BuildContext context, ExamplePage page) async { if (!kIsWeb) { From bf34f6995ca170d17f865ec486c49b128a255c32 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Wed, 3 Nov 2021 15:40:38 +0100 Subject: [PATCH 28/33] renamed removeImageSource to removeSource --- .../java/com/mapbox/mapboxgl/MapboxMapController.java | 4 ++-- example/lib/place_source.dart | 2 +- ios/Classes/MapboxMapController.swift | 6 +++--- lib/src/controller.dart | 8 +++++++- .../lib/src/mapbox_gl_platform_interface.dart | 8 ++++---- .../lib/src/method_channel_mapbox_gl.dart | 8 +++++--- mapbox_gl_web/lib/src/mapbox_map_controller.dart | 10 ++++++++++ 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index 2fe40ea1e..3e97dcf99 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -1052,11 +1052,11 @@ public void onFailure(@NonNull Exception exception) { result.success(null); break; } - case "style#removeImageSource": { + case "style#removeSource": { if (style == null) { result.error("STYLE IS NULL", "The style is null. Has onStyleLoaded() already been invoked?", null); } - style.removeSource((String) call.argument("imageSourceId")); + style.removeSource((String) call.argument("sourceId")); result.success(null); break; } diff --git a/example/lib/place_source.dart b/example/lib/place_source.dart index aa610832a..d7b28d4a6 100644 --- a/example/lib/place_source.dart +++ b/example/lib/place_source.dart @@ -64,7 +64,7 @@ class PlaceSymbolBodyState extends State { } Future removeImageSource(String imageSourceId) { - return controller.removeImageSource(imageSourceId); + return controller.removeSource(imageSourceId); } Future addLayer(String imageLayerId, String imageSourceId) { diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index dd1a10042..db6dfc7b9 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -681,10 +681,10 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma self.mapView.style?.addSource(source) result(nil) - case "style#removeImageSource": + case "style#removeSource": guard let arguments = methodCall.arguments as? [String: Any] else { return } - guard let imageSourceId = arguments["imageSourceId"] as? String else { return } - guard let source = self.mapView.style?.source(withIdentifier: imageSourceId) else { return } + guard let sourceId = arguments["sourceId"] as? String else { return } + guard let source = self.mapView.style?.source(withIdentifier: sourceId) else { return } self.mapView.style?.removeSource(source) result(nil) case "style#addLayer": diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 3ca1adbc2..06c8977b3 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -846,8 +846,14 @@ class MapboxMapController extends ChangeNotifier { } /// Removes previously added image source by id + @Deprecated("This method was renamed to removeSource") Future removeImageSource(String imageSourceId) { - return _mapboxGlPlatform.removeImageSource(imageSourceId); + return _mapboxGlPlatform.removeSource(imageSourceId); + } + + /// Removes previously added source by id + Future removeSource(String sourceId) { + return _mapboxGlPlatform.removeSource(sourceId); } /// Adds a Mapbox image layer to the map's style at render time. diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index ffaa693ea..62d442d37 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -246,10 +246,6 @@ abstract class MapboxGlPlatform { throw UnimplementedError('addImageSource() has not been implemented.'); } - Future removeImageSource(String imageSourceId) async { - throw UnimplementedError('removeImageSource() has not been implemented.'); - } - Future addLayer(String imageLayerId, String imageSourceId) async { throw UnimplementedError('addLayer() has not been implemented.'); } @@ -286,6 +282,10 @@ abstract class MapboxGlPlatform { throw UnimplementedError('addGeoJsonSource() has not been implemented.'); } + Future removeSource(String sourceId) async { + throw UnimplementedError('removeSource() has not been implemented.'); + } + Future addSymbolLayer( String sourceId, String layerId, Map properties) async { throw UnimplementedError('addSymbolLayer() has not been implemented.'); diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index ae7aaea7a..85ee16d93 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -653,10 +653,12 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { } @override - Future removeImageSource(String imageSourceId) async { + Future removeSource(String sourceId) async { try { - return await _channel.invokeMethod('style#removeImageSource', - {'imageSourceId': imageSourceId}); + return await _channel.invokeMethod( + 'style#removeSource', + {'sourceId': sourceId}, + ); } on PlatformException catch (e) { return new Future.error(e); } diff --git a/mapbox_gl_web/lib/src/mapbox_map_controller.dart b/mapbox_gl_web/lib/src/mapbox_map_controller.dart index 5ee3fd077..b8323b755 100644 --- a/mapbox_gl_web/lib/src/mapbox_map_controller.dart +++ b/mapbox_gl_web/lib/src/mapbox_map_controller.dart @@ -366,6 +366,11 @@ class MapboxMapController extends MapboxGlPlatform } } + @override + Future removeSource(String sourceId) { + return _map.removeSource(sourceId); + } + @override Future setSymbolIconAllowOverlap(bool enable) async { //TODO: to implement @@ -780,26 +785,31 @@ class MapboxMapController extends MapboxGlPlatform _map.removeLayer(layerId); } + @override Future addGeoJsonSource( String sourceId, Map geojson) async { _map.addSource(sourceId, {"type": 'geojson', "data": geojson}); } + @override Future addCircleLayer( String sourceId, String layerId, Map properties) async { return _addLayer(sourceId, layerId, properties, "circle"); } + @override Future addFillLayer( String sourceId, String layerId, Map properties) async { return _addLayer(sourceId, layerId, properties, "fill"); } + @override Future addLineLayer( String sourceId, String layerId, Map properties) async { return _addLayer(sourceId, layerId, properties, "line"); } + @override Future addSymbolLayer( String sourceId, String layerId, Map properties) async { return _addLayer(sourceId, layerId, properties, "symbol"); From 0fb29b9da2beefe4f6fe9217273d9b82ef7523cf Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Wed, 3 Nov 2021 17:39:18 +0100 Subject: [PATCH 29/33] added missing result.sucess --- .../main/java/com/mapbox/mapboxgl/MapboxMapController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index 3e97dcf99..caa17193d 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -979,6 +979,7 @@ public void onError(@NonNull String message) { final String sourceId = call.argument("sourceId"); final String geojson = call.argument("geojson"); addGeoJsonSource(sourceId, geojson); + result.success(null); break; } case "symbolLayer#add": { @@ -986,6 +987,7 @@ public void onError(@NonNull String message) { final String layerId = call.argument("layerId"); final PropertyValue[] properties = LayerPropertyConverter.interpretSymbolLayerProperties(call.argument("properties")); addSymbolLayer(layerId, sourceId, properties, null); + result.success(null); break; } case "lineLayer#add": { @@ -993,6 +995,7 @@ public void onError(@NonNull String message) { final String layerId = call.argument("layerId"); final PropertyValue[] properties = LayerPropertyConverter.interpretLineLayerProperties(call.argument("properties")); addLineLayer(layerId, sourceId, properties, null); + result.success(null); break; } case "fillLayer#add": { @@ -1000,6 +1003,7 @@ public void onError(@NonNull String message) { final String layerId = call.argument("layerId"); final PropertyValue[] properties = LayerPropertyConverter.interpretFillLayerProperties(call.argument("properties")); addFillLayer(layerId, sourceId, properties, null); + result.success(null); break; } case "circleLayer#add": { @@ -1007,6 +1011,7 @@ public void onError(@NonNull String message) { final String layerId = call.argument("layerId"); final PropertyValue[] properties = LayerPropertyConverter.interpretCircleLayerProperties(call.argument("properties")); addCircleLayer(layerId, sourceId, properties, null); + result.success(null); break; } case "locationComponent#getLastLocation": { From d85fb952a59bf9c67ca6740bef3940bc02b1608c Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Wed, 3 Nov 2021 18:19:36 +0100 Subject: [PATCH 30/33] fixed issue with onFillTapped and stacked layers --- .../src/main/java/com/mapbox/mapboxgl/MapboxMapController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index caa17193d..f4e430324 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -1208,7 +1208,7 @@ public boolean onMapClick(@NonNull LatLng point) { List featureList = mapboxMap.queryRenderedFeatures(rectF, featureLayerIdentifiers.toArray(new String[0])); if(!featureList.isEmpty()){ final Map arguments = new HashMap<>(1); - arguments.put("featureId", featureList.get(featureList.size() - 1).id()); + arguments.put("featureId", featureList.get(0).id()); methodChannel.invokeMethod("feature#onTap", arguments); } else { final Map arguments = new HashMap<>(5); From db38813b07cf55e19b4d68180e28988b440de5af Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Thu, 4 Nov 2021 20:49:38 +0100 Subject: [PATCH 31/33] added setSource and add below layer capability * fixed issue with ios and array literals * added belowId options to addLayer functions * added set setGeoJsonSource to set new data on the fly --- .../mapbox/mapboxgl/MapboxMapController.java | 71 +++++++++++-- example/lib/layer.dart | 99 ++++++++++++++++--- ios/Classes/LayerPropertyConverter.swift | 23 ++++- ios/Classes/MapboxMapController.swift | 68 +++++++++---- lib/src/controller.dart | 41 ++++++-- .../lib/src/mapbox_gl_platform_interface.dart | 17 +++- .../lib/src/method_channel_mapbox_gl.dart | 25 ++++- .../lib/src/mapbox_map_controller.dart | 46 ++++++--- .../LayerPropertyConverter.swift.template | 23 ++++- 9 files changed, 337 insertions(+), 76 deletions(-) diff --git a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java index f4e430324..27b529a50 100644 --- a/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java +++ b/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java @@ -400,48 +400,82 @@ private void addGeoJsonSource(String sourceName, String source) { style.addSource(geoJsonSource); } + private void setGeoJsonSource(String sourceName, String source) { + FeatureCollection featureCollection = FeatureCollection.fromJson(source); + GeoJsonSource geoJsonSource = style.getSourceAs(sourceName); + + geoJsonSource.setGeoJson(featureCollection); + } + private void addSymbolLayer(String layerName, String sourceName, + String belowLayerId, PropertyValue[] properties, Expression filter) { SymbolLayer symbolLayer = new SymbolLayer(layerName, sourceName); symbolLayer.setProperties(properties); - style.addLayer(symbolLayer); + if(belowLayerId != null){ + style.addLayerBelow(symbolLayer, belowLayerId); + } + else + { + style.addLayer(symbolLayer); + } featureLayerIdentifiers.add(layerName); } private void addLineLayer(String layerName, String sourceName, + String belowLayerId, PropertyValue[] properties, Expression filter) { LineLayer lineLayer = new LineLayer(layerName, sourceName); lineLayer.setProperties(properties); - - style.addLayer(lineLayer); + if(belowLayerId != null){ + style.addLayerBelow(lineLayer, belowLayerId); + } + else + { + style.addLayer(lineLayer); + } featureLayerIdentifiers.add(layerName); } private void addFillLayer(String layerName, String sourceName, + String belowLayerId, PropertyValue[] properties, Expression filter) { FillLayer fillLayer = new FillLayer(layerName, sourceName); fillLayer.setProperties(properties); - style.addLayer(fillLayer); + if(belowLayerId != null){ + style.addLayerBelow(fillLayer, belowLayerId); + } + else + { + style.addLayer(fillLayer); + } featureLayerIdentifiers.add(layerName); } private void addCircleLayer(String layerName, String sourceName, + String belowLayerId, PropertyValue[] properties, Expression filter) { CircleLayer circleLayer = new CircleLayer(layerName, sourceName); circleLayer.setProperties(properties); featureLayerIdentifiers.add(layerName); - style.addLayer(circleLayer); + if(belowLayerId != null){ + style.addLayerBelow(circleLayer, belowLayerId); + } + else + { + style.addLayer(circleLayer); + } } private void enableSymbolManager(@NonNull Style style) { @@ -982,35 +1016,46 @@ public void onError(@NonNull String message) { result.success(null); break; } + case "source#setGeoJson": { + final String sourceId = call.argument("sourceId"); + final String geojson = call.argument("geojson"); + setGeoJsonSource(sourceId, geojson); + result.success(null); + break; + } case "symbolLayer#add": { final String sourceId = call.argument("sourceId"); final String layerId = call.argument("layerId"); + final String belowLayerId = call.argument("belowLayerId"); final PropertyValue[] properties = LayerPropertyConverter.interpretSymbolLayerProperties(call.argument("properties")); - addSymbolLayer(layerId, sourceId, properties, null); + addSymbolLayer(layerId, sourceId, belowLayerId, properties, null); result.success(null); break; } case "lineLayer#add": { final String sourceId = call.argument("sourceId"); final String layerId = call.argument("layerId"); + final String belowLayerId = call.argument("belowLayerId"); final PropertyValue[] properties = LayerPropertyConverter.interpretLineLayerProperties(call.argument("properties")); - addLineLayer(layerId, sourceId, properties, null); + addLineLayer(layerId, sourceId, belowLayerId, properties, null); result.success(null); break; } case "fillLayer#add": { final String sourceId = call.argument("sourceId"); final String layerId = call.argument("layerId"); + final String belowLayerId = call.argument("belowLayerId"); final PropertyValue[] properties = LayerPropertyConverter.interpretFillLayerProperties(call.argument("properties")); - addFillLayer(layerId, sourceId, properties, null); + addFillLayer(layerId, sourceId, belowLayerId, properties, null); result.success(null); break; } case "circleLayer#add": { final String sourceId = call.argument("sourceId"); final String layerId = call.argument("layerId"); + final String belowLayerId = call.argument("belowLayerId"); final PropertyValue[] properties = LayerPropertyConverter.interpretCircleLayerProperties(call.argument("properties")); - addCircleLayer(layerId, sourceId, properties, null); + addCircleLayer(layerId, sourceId, belowLayerId, properties, null); result.success(null); break; } @@ -1065,6 +1110,14 @@ public void onFailure(@NonNull Exception exception) { result.success(null); break; } + case "style#setSource": { + if (style == null) { + result.error("STYLE IS NULL", "The style is null. Has onStyleLoaded() already been invoked?", null); + } + style.removeSource((String) call.argument("sourceId")); + result.success(null); + break; + } case "style#addLayer": { if (style == null) { result.error("STYLE IS NULL", "The style is null. Has onStyleLoaded() already been invoked?", null); diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 483bb758c..c4414fc66 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -1,3 +1,6 @@ +import 'dart:async'; +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:mapbox_gl/mapbox_gl.dart'; import 'package:mapbox_gl_example/main.dart'; @@ -19,6 +22,7 @@ class LayerState extends State { static final LatLng center = const LatLng(-33.86711, 151.1947171); late MapboxMapController controller; + Timer? timer; @override Widget build(BuildContext context) { @@ -53,11 +57,12 @@ class LayerState extends State { ScaffoldMessenger.of(context).showSnackBar(snackBar); } - void _onStyleLoadedCallback() { - controller.addGeoJsonSource("fills", _fills); - controller.addGeoJsonSource("points", _points); + void _onStyleLoadedCallback() async { + await controller.addGeoJsonSource("fills", _fills); + await controller.addGeoJsonSource("points", _points); + await controller.addGeoJsonSource("moving", _movingFeature(0)); - controller.addFillLayer( + await controller.addFillLayer( "fills", "fills", FillLayerProperties(fillColor: [ @@ -69,9 +74,10 @@ class LayerState extends State { 18, 'green' ], fillOpacity: 0.4), + belowLayerId: "water", ); - controller.addLineLayer( + await controller.addLineLayer( "fills", "lines", LineLayerProperties( @@ -87,23 +93,84 @@ class LayerState extends State { ]), ); - controller.addCircleLayer( - "fills", - "circles", - CircleLayerProperties( - circleRadius: 4, - circleColor: Colors.blue.toHexStringRGB(), - )); + await controller.addCircleLayer( + "fills", + "circles", + CircleLayerProperties( + circleRadius: 4, + circleColor: Colors.blue.toHexStringRGB(), + ), + ); - controller.addSymbolLayer( - "points", - "symbols", + await controller.addSymbolLayer( + "points", + "symbols", + SymbolLayerProperties( + iconImage: "{type}-15", + iconSize: 2, + iconAllowOverlap: true, + ), + ); + + await controller.addSymbolLayer( + "moving", + "moving", SymbolLayerProperties( - iconImage: "{type}-15", + textField: "{name}", + textHaloWidth: 1, + textSize: 10, + textHaloColor: Colors.white.toHexStringRGB(), + textOffset: [ + Expressions.literal, + [0, 2] + ], + iconImage: "bicycle-15", iconSize: 2, iconAllowOverlap: true, + textAllowOverlap: true, )); + timer = Timer.periodic( + Duration(milliseconds: 10), + (t) => controller.setGeoJsonSource( + "moving", _movingFeature(t.tick / 2000))); } + + @override + void dispose() { + timer?.cancel(); + super.dispose(); + } +} + +Map _movingFeature(double t) { + List makeLatLong(double t) { + final angle = t * 2 * pi; + const r = 0.025; + const center_x = 151.1849; + const center_y = -33.8748; + return [ + center_x + r * sin(angle), + center_y + r * cos(angle), + ]; + } + + return { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {"name": "POGAČAR Tadej"}, + "id": 10, + "geometry": {"type": "Point", "coordinates": makeLatLong(t)} + }, + { + "type": "Feature", + "properties": {"name": "VAN AERT Wout"}, + "id": 11, + "geometry": {"type": "Point", "coordinates": makeLatLong(t + 0.15)} + }, + ] + }; } final _fills = { diff --git a/ios/Classes/LayerPropertyConverter.swift b/ios/Classes/LayerPropertyConverter.swift index 3bde90439..9ccc79a26 100644 --- a/ios/Classes/LayerPropertyConverter.swift +++ b/ios/Classes/LayerPropertyConverter.swift @@ -336,10 +336,29 @@ class LayerPropertyConverter { private class func interpretExpression(propertyName: String, expression: String) -> NSExpression? { let isColor = propertyName.contains("color"); + do { let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: .fragmentsAllowed) - if(isColor && json is String){ - return NSExpression(forConstantValue: UIColor(hexString: json as! String)) + // this is required because NSExpression.init(mglJSONObject: json) fails to create + // a proper Expression if the data of is a hexString + if isColor { + if let color = json as? String { + return NSExpression(forConstantValue: UIColor(hexString: color)) + } + } + // this is required because NSExpression.init(mglJSONObject: json) fails to create + // a proper Expression if the data of a literal is an array + if let offset = json as? [Any]{ + if offset.count == 2 && offset.first is String && offset.first as? String == "literal" { + if let vector = offset.last as? [Any]{ + if(vector.count == 2) { + if let x = vector.first as? Double, let y = vector.last as? Double { + return NSExpression(forConstantValue: NSValue(cgVector: CGVector(dx: x, dy: y))) + } + + } + } + } } return NSExpression.init(mglJSONObject: json) } catch { diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift index db6dfc7b9..012706bc0 100644 --- a/ios/Classes/MapboxMapController.swift +++ b/ios/Classes/MapboxMapController.swift @@ -507,7 +507,8 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma guard let sourceId = arguments["sourceId"] as? String else { return } guard let layerId = arguments["layerId"] as? String else { return } guard let properties = arguments["properties"] as? [String: String] else { return } - addSymbolLayer(sourceId: sourceId, layerId: layerId, properties: properties) + let belowLayerId = arguments["belowLayerId"] as? String + addSymbolLayer(sourceId: sourceId, layerId: layerId, belowLayerId: belowLayerId, properties: properties) result(nil) case "lineLayer#add": @@ -515,7 +516,8 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma guard let sourceId = arguments["sourceId"] as? String else { return } guard let layerId = arguments["layerId"] as? String else { return } guard let properties = arguments["properties"] as? [String: String] else { return } - addLineLayer(sourceId: sourceId, layerId: layerId, properties: properties) + let belowLayerId = arguments["belowLayerId"] as? String + addLineLayer(sourceId: sourceId, layerId: layerId, belowLayerId: belowLayerId, properties: properties) result(nil) case "fillLayer#add": @@ -523,7 +525,8 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma guard let sourceId = arguments["sourceId"] as? String else { return } guard let layerId = arguments["layerId"] as? String else { return } guard let properties = arguments["properties"] as? [String: String] else { return } - addFillLayer(sourceId: sourceId, layerId: layerId, properties: properties) + let belowLayerId = arguments["belowLayerId"] as? String + addFillLayer(sourceId: sourceId, layerId: layerId, belowLayerId: belowLayerId, properties: properties) result(nil) case "circleLayer#add": @@ -531,10 +534,10 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma guard let sourceId = arguments["sourceId"] as? String else { return } guard let layerId = arguments["layerId"] as? String else { return } guard let properties = arguments["properties"] as? [String: String] else { return } - addCircleLayer(sourceId: sourceId, layerId: layerId, properties: properties) + let belowLayerId = arguments["belowLayerId"] as? String + addCircleLayer(sourceId: sourceId, layerId: layerId, belowLayerId: belowLayerId, properties: properties) result(nil) - case "line#getGeometry": guard let lineAnnotationController = lineAnnotationController else { return } guard let arguments = methodCall.arguments as? [String: Any] else { return } @@ -745,14 +748,13 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma guard let geojson = arguments["geojson"] as? String else { return } addSource(sourceId: sourceId, geojson: geojson) result(nil) - - case "lineLayer#add": + + case "source#setGeoJson": guard let arguments = methodCall.arguments as? [String: Any] else { return } guard let sourceId = arguments["sourceId"] as? String else { return } - guard let layerId = arguments["layerId"] as? String else { return } - guard let properties = arguments["properties"] as? [String: String] else { return } - addLineLayer(sourceId: sourceId, layerId: layerId, properties: properties) - result(nil) + guard let geojson = arguments["geojson"] as? String else { return } + setSource(sourceId: sourceId, geojson: geojson) + result(nil) default: result(FlutterMethodNotImplemented) @@ -847,7 +849,6 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } - /* * MGLAnnotationControllerDelegate */ @@ -1018,45 +1019,62 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } } - func addSymbolLayer(sourceId: String, layerId: String, properties: [String: String]) { + func addSymbolLayer(sourceId: String, layerId: String, belowLayerId: String?, properties: [String: String]) { if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { + let layer = MGLSymbolStyleLayer(identifier: layerId, source: source) LayerPropertyConverter.addSymbolProperties(symbolLayer: layer, properties: properties) - style.addLayer(layer) + if let id = belowLayerId, let belowLayer = style.layer(withIdentifier: id) { + style.insertLayer(layer, below: belowLayer) + } else { + style.addLayer(layer) + } featureLayerIdentifiers.insert(layerId) } } } - func addLineLayer(sourceId: String, layerId: String, properties: [String: String]) { + func addLineLayer(sourceId: String, layerId: String, belowLayerId: String?, properties: [String: String]) { if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { let layer = MGLLineStyleLayer(identifier: layerId, source: source) LayerPropertyConverter.addLineProperties(lineLayer: layer, properties: properties) - style.addLayer(layer) + if let id = belowLayerId, let belowLayer = style.layer(withIdentifier: id) { + style.insertLayer(layer, below: belowLayer) + } else { + style.addLayer(layer) + } featureLayerIdentifiers.insert(layerId) } } } - func addFillLayer(sourceId: String, layerId: String, properties: [String: String]) { + func addFillLayer(sourceId: String, layerId: String, belowLayerId: String?, properties: [String: String]) { if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { let layer = MGLFillStyleLayer(identifier: layerId, source: source) LayerPropertyConverter.addFillProperties(fillLayer: layer, properties: properties) - style.addLayer(layer) + if let id = belowLayerId, let belowLayer = style.layer(withIdentifier: id) { + style.insertLayer(layer, below: belowLayer) + } else { + style.addLayer(layer) + } featureLayerIdentifiers.insert(layerId) } } } - func addCircleLayer(sourceId: String, layerId: String, properties: [String: String]) { + func addCircleLayer(sourceId: String, layerId: String, belowLayerId: String?, properties: [String: String]) { if let style = mapView.style { if let source = style.source(withIdentifier: sourceId) { let layer = MGLCircleStyleLayer(identifier: layerId, source: source) LayerPropertyConverter.addCircleProperties(circleLayer: layer, properties: properties) - style.addLayer(layer) + if let id = belowLayerId, let belowLayer = style.layer(withIdentifier: id) { + style.insertLayer(layer, below: belowLayer) + } else { + style.addLayer(layer) + } featureLayerIdentifiers.insert(layerId) } } @@ -1100,6 +1118,16 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma } catch { } } + + func setSource(sourceId: String, geojson: String) { + do { + let parsed = try MGLShape.init(data: geojson.data(using: .utf8)!, encoding: String.Encoding.utf8.rawValue) + if let source = mapView.style?.source(withIdentifier: sourceId) as? MGLShapeSource { + source.shape = parsed + } + } catch { + } + } /* diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 06c8977b3..c0ddf6c9c 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -272,28 +272,53 @@ class MapboxMapController extends ChangeNotifier { await _mapboxGlPlatform.addGeoJsonSource(sourceId, geojson); } + Future setGeoJsonSource( + String sourceId, Map geojson) async { + await _mapboxGlPlatform.setGeoJsonSource(sourceId, geojson); + } + Future addSymbolLayer( - String sourceId, String layerId, SymbolLayerProperties properties) async { + String sourceId, String layerId, SymbolLayerProperties properties, + {String? belowLayerId}) async { await _mapboxGlPlatform.addSymbolLayer( - sourceId, layerId, properties.toJson()); + sourceId, + layerId, + properties.toJson(), + belowLayerId: belowLayerId, + ); } Future addLineLayer( - String sourceId, String layerId, LineLayerProperties properties) async { + String sourceId, String layerId, LineLayerProperties properties, + {String? belowLayerId}) async { await _mapboxGlPlatform.addLineLayer( - sourceId, layerId, properties.toJson()); + sourceId, + layerId, + properties.toJson(), + belowLayerId: belowLayerId, + ); } Future addFillLayer( - String sourceId, String layerId, FillLayerProperties properties) async { + String sourceId, String layerId, FillLayerProperties properties, + {String? belowLayerId}) async { await _mapboxGlPlatform.addFillLayer( - sourceId, layerId, properties.toJson()); + sourceId, + layerId, + properties.toJson(), + belowLayerId: belowLayerId, + ); } Future addCircleLayer( - String sourceId, String layerId, CircleLayerProperties properties) async { + String sourceId, String layerId, CircleLayerProperties properties, + {String? belowLayerId}) async { await _mapboxGlPlatform.addCircleLayer( - sourceId, layerId, properties.toJson()); + sourceId, + layerId, + properties.toJson(), + belowLayerId: belowLayerId, + ); } /// Updates user location tracking mode. diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart index 62d442d37..2dbe5cd1e 100644 --- a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart +++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart @@ -282,27 +282,36 @@ abstract class MapboxGlPlatform { throw UnimplementedError('addGeoJsonSource() has not been implemented.'); } + Future setGeoJsonSource( + String sourceId, Map geojson) async { + throw UnimplementedError('setGeoJsonSource() has not been implemented.'); + } + Future removeSource(String sourceId) async { throw UnimplementedError('removeSource() has not been implemented.'); } Future addSymbolLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { throw UnimplementedError('addSymbolLayer() has not been implemented.'); } Future addLineLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { throw UnimplementedError('addLineLayer() has not been implemented.'); } Future addCircleLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { throw UnimplementedError('addCircleLayer() has not been implemented.'); } Future addFillLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { throw UnimplementedError('addFillLayer() has not been implemented.'); } } diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart index 85ee16d93..d6a1f5d9b 100644 --- a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart +++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart @@ -737,12 +737,23 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { }); } + @override + Future setGeoJsonSource( + String sourceId, Map geojson) async { + await _channel.invokeMethod('source#setGeoJson', { + 'sourceId': sourceId, + 'geojson': jsonEncode(geojson), + }); + } + @override Future addSymbolLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { await _channel.invokeMethod('symbolLayer#add', { 'sourceId': sourceId, 'layerId': layerId, + 'belowLayerId': belowLayerId, 'properties': properties .map((key, value) => MapEntry(key, jsonEncode(value))) }); @@ -750,10 +761,12 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { @override Future addLineLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { await _channel.invokeMethod('lineLayer#add', { 'sourceId': sourceId, 'layerId': layerId, + 'belowLayerId': belowLayerId, 'properties': properties .map((key, value) => MapEntry(key, jsonEncode(value))) }); @@ -761,10 +774,12 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { @override Future addCircleLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { await _channel.invokeMethod('circleLayer#add', { 'sourceId': sourceId, 'layerId': layerId, + 'belowLayerId': belowLayerId, 'properties': properties .map((key, value) => MapEntry(key, jsonEncode(value))) }); @@ -772,10 +787,12 @@ class MethodChannelMapboxGl extends MapboxGlPlatform { @override Future addFillLayer( - String sourceId, String layerId, Map properties) async { + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { await _channel.invokeMethod('fillLayer#add', { 'sourceId': sourceId, 'layerId': layerId, + 'belowLayerId': belowLayerId, 'properties': properties .map((key, value) => MapEntry(key, jsonEncode(value))) }); diff --git a/mapbox_gl_web/lib/src/mapbox_map_controller.dart b/mapbox_gl_web/lib/src/mapbox_map_controller.dart index b8323b755..0ce74cd9d 100644 --- a/mapbox_gl_web/lib/src/mapbox_map_controller.dart +++ b/mapbox_gl_web/lib/src/mapbox_map_controller.dart @@ -791,44 +791,68 @@ class MapboxMapController extends MapboxGlPlatform _map.addSource(sourceId, {"type": 'geojson', "data": geojson}); } + @override + Future setGeoJsonSource( + String sourceId, Map geojson) async { + final source = _map.getSource(sourceId) as GeoJsonSource; + final data = FeatureCollection(features: [ + for (final f in geojson["features"] ?? []) + Feature( + geometry: Geometry( + type: f["geometry"]["type"], + coordinates: f["geometry"]["coordinates"]), + properties: f["properties"], + id: f["id"]) + ]); + source.setData(data); + } + @override Future addCircleLayer( - String sourceId, String layerId, Map properties) async { - return _addLayer(sourceId, layerId, properties, "circle"); + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { + return _addLayer(sourceId, layerId, properties, "circle", + belowLayerId: belowLayerId); } @override Future addFillLayer( - String sourceId, String layerId, Map properties) async { - return _addLayer(sourceId, layerId, properties, "fill"); + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { + return _addLayer(sourceId, layerId, properties, "fill", + belowLayerId: belowLayerId); } @override Future addLineLayer( - String sourceId, String layerId, Map properties) async { - return _addLayer(sourceId, layerId, properties, "line"); + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { + return _addLayer(sourceId, layerId, properties, "line", + belowLayerId: belowLayerId); } @override Future addSymbolLayer( - String sourceId, String layerId, Map properties) async { - return _addLayer(sourceId, layerId, properties, "symbol"); + String sourceId, String layerId, Map properties, + {String? belowLayerId}) async { + return _addLayer(sourceId, layerId, properties, "symbol", + belowLayerId: belowLayerId); } Future _addLayer(String sourceId, String layerId, - Map properties, String layerType) async { + Map properties, String layerType, + {String? belowLayerId}) async { final layout = Map.fromEntries( properties.entries.where((entry) => isLayoutProperty(entry.key))); final paint = Map.fromEntries( properties.entries.where((entry) => !isLayoutProperty(entry.key))); - _featureLayerIdentifiers.add(layerId); _map.addLayer({ 'id': layerId, 'type': layerType, 'source': sourceId, 'layout': layout, 'paint': paint - }); + }, belowLayerId); } } diff --git a/scripts/templates/LayerPropertyConverter.swift.template b/scripts/templates/LayerPropertyConverter.swift.template index f94bfdad1..4719a9cdb 100644 --- a/scripts/templates/LayerPropertyConverter.swift.template +++ b/scripts/templates/LayerPropertyConverter.swift.template @@ -45,10 +45,29 @@ class LayerPropertyConverter { {{/layerTypes}} private class func interpretExpression(propertyName: String, expression: String) -> NSExpression? { let isColor = propertyName.contains("color"); + do { let json = try JSONSerialization.jsonObject(with: expression.data(using: .utf8)!, options: .fragmentsAllowed) - if(isColor && json is String){ - return NSExpression(forConstantValue: UIColor(hexString: json as! String)) + // this is required because NSExpression.init(mglJSONObject: json) fails to create + // a proper Expression if the data of is a hexString + if isColor { + if let color = json as? String { + return NSExpression(forConstantValue: UIColor(hexString: color)) + } + } + // this is required because NSExpression.init(mglJSONObject: json) fails to create + // a proper Expression if the data of a literal is an array + if let offset = json as? [Any]{ + if offset.count == 2 && offset.first is String && offset.first as? String == "literal" { + if let vector = offset.last as? [Any]{ + if(vector.count == 2) { + if let x = vector.first as? Double, let y = vector.last as? Double { + return NSExpression(forConstantValue: NSValue(cgVector: CGVector(dx: x, dy: y))) + } + + } + } + } } return NSExpression.init(mglJSONObject: json) } catch { From 8e2d97d0c4d8189b000d94209c8b15b5f30a5500 Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Thu, 4 Nov 2021 21:09:38 +0100 Subject: [PATCH 32/33] added doc strings --- lib/src/controller.dart | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lib/src/controller.dart b/lib/src/controller.dart index c0ddf6c9c..2544245e4 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -267,16 +267,40 @@ class MapboxMapController extends ChangeNotifier { return _mapboxGlPlatform.moveCamera(cameraUpdate); } + /// Adds a new geojson source + /// + /// The json in [geojson] has to comply with the schema for FeatureCollection + /// as specified in https://datatracker.ietf.org/doc/html/rfc7946#section-3.3 + /// + /// The returned [Future] completes after the change has been made on the + /// platform side. Future addGeoJsonSource( String sourceId, Map geojson) async { await _mapboxGlPlatform.addGeoJsonSource(sourceId, geojson); } + /// Sets new geojson data to and existing source + /// + /// This only works as exected if the source has been created with + /// [addGeoJsonSource] before. This is very useful if you want to update and + /// existing source with modified data. + /// + /// The json in [geojson] has to comply with the schema for FeatureCollection + /// as specified in https://datatracker.ietf.org/doc/html/rfc7946#section-3.3 + /// + /// The returned [Future] completes after the change has been made on the + /// platform side. Future setGeoJsonSource( String sourceId, Map geojson) async { await _mapboxGlPlatform.setGeoJsonSource(sourceId, geojson); } + /// Add a symbol layer to the map with the given properties + /// + /// The returned [Future] completes after the change has been made on the + /// platform side. + /// + /// Note: [belowLayerId] is currently ignored on the web Future addSymbolLayer( String sourceId, String layerId, SymbolLayerProperties properties, {String? belowLayerId}) async { @@ -288,6 +312,12 @@ class MapboxMapController extends ChangeNotifier { ); } + /// Add a line layer to the map with the given properties + /// + /// The returned [Future] completes after the change has been made on the + /// platform side. + /// + /// Note: [belowLayerId] is currently ignored on the web Future addLineLayer( String sourceId, String layerId, LineLayerProperties properties, {String? belowLayerId}) async { @@ -299,6 +329,12 @@ class MapboxMapController extends ChangeNotifier { ); } + /// Add a fill layer to the map with the given properties + /// + /// The returned [Future] completes after the change has been made on the + /// platform side. + /// + /// Note: [belowLayerId] is currently ignored on the web Future addFillLayer( String sourceId, String layerId, FillLayerProperties properties, {String? belowLayerId}) async { @@ -310,6 +346,12 @@ class MapboxMapController extends ChangeNotifier { ); } + /// Add a circle layer to the map with the given properties + /// + /// The returned [Future] completes after the change has been made on the + /// platform side. + /// + /// Note: [belowLayerId] is currently ignored on the web Future addCircleLayer( String sourceId, String layerId, CircleLayerProperties properties, {String? belowLayerId}) async { From 1ebc4e4f30efbe1fb32c90f7a2076918f342cedb Mon Sep 17 00:00:00 2001 From: Felix Horvat Date: Thu, 4 Nov 2021 21:22:42 +0100 Subject: [PATCH 33/33] fixed issues with android in the example --- example/lib/layer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/lib/layer.dart b/example/lib/layer.dart index c4414fc66..37e0c2d09 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -116,7 +116,7 @@ class LayerState extends State { "moving", "moving", SymbolLayerProperties( - textField: "{name}", + textField: [Expressions.get, "name"], textHaloWidth: 1, textSize: 10, textHaloColor: Colors.white.toHexStringRGB(),