summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/Symbol.java566
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/SymbolManager.java597
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/symbol.java.ejs123
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/symbolManager.java.ejs153
4 files changed, 1439 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/Symbol.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/Symbol.java
new file mode 100644
index 0000000000..f4155e1b07
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/Symbol.java
@@ -0,0 +1,566 @@
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
+
+package com.mapbox.mapboxsdk.symbol;
+
+import android.support.annotation.UiThread;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.mapbox.geojson.Geometry;
+import com.mapbox.geojson.Point;
+import com.mapbox.mapboxsdk.geometry.LatLng;
+
+@UiThread
+public class Symbol {
+
+ public static final String ID_KEY = "id-symbol";
+
+ private final SymbolManager symbolManager;
+ private final JsonObject jsonObject = new JsonObject();
+ private Geometry geometry;
+
+ /**
+ * Create a symbol.
+ *
+ * @param symbolManager the symbol manager created and managing the symbol
+ * @param id the id of the symbol
+ */
+ Symbol(SymbolManager symbolManager, long id) {
+ this.symbolManager = symbolManager;
+ this.jsonObject.addProperty(ID_KEY, id);
+ }
+
+ /**
+ * Get the symbol geometry.
+ *
+ * @return the symbol geometry
+ */
+ Geometry getGeometry() {
+ if (geometry == null) {
+ throw new IllegalStateException();
+ }
+ return geometry;
+ }
+
+ /**
+ * Get the symbol feature properties.
+ *
+ * @return the symbol feature properties
+ */
+ JsonObject getFeature() {
+ return jsonObject;
+ }
+
+ /**
+ * Set the LatLng of the symbol, which represents the location of the symbol on the map
+ *
+ * @param latLng the location of the symbol in a longitude and latitude pair
+ */
+ public void setLatLng(LatLng latLng) {
+ geometry = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude());
+ symbolManager.updateSource();
+ }
+
+ // Property accessors
+ /**
+ * Get the IconSize property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getIconSize() {
+ return jsonObject.get("icon-size").getAsFloat();
+ }
+
+ /**
+ * Set the IconSize property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setIconSize(Float value) {
+ jsonObject.addProperty("icon-size", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the IconImage property
+ *
+ * @return property wrapper value around String
+ */
+ public String getIconImage() {
+ return jsonObject.get("icon-image").getAsString();
+ }
+
+ /**
+ * Set the IconImage property
+ *
+ * @return property wrapper value around String
+ */
+ public void setIconImage(String value) {
+ jsonObject.addProperty("icon-image", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the IconRotate property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getIconRotate() {
+ return jsonObject.get("icon-rotate").getAsFloat();
+ }
+
+ /**
+ * Set the IconRotate property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setIconRotate(Float value) {
+ jsonObject.addProperty("icon-rotate", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the IconOffset property
+ *
+ * @return property wrapper value around Float[]
+ */
+ public Float[] getIconOffset() {
+ JsonArray jsonArray = jsonObject.getAsJsonArray("icon-offset");
+ Float[] value = new Float[jsonArray.size()];
+ for (int i = 0; i < jsonArray.size(); i++) {
+ value[i] = jsonArray.get(i).getAsFloat();
+ }
+ return value;
+ }
+
+ /**
+ * Set the IconOffset property
+ *
+ * @return property wrapper value around Float[]
+ */
+ public void setIconOffset(Float[] value) {
+ JsonArray jsonArray = new JsonArray();
+ for (Float element : value) {
+ jsonArray.add(element);
+ }
+ jsonObject.add("icon-offset", jsonArray);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the IconAnchor property
+ *
+ * @return property wrapper value around String
+ */
+ public String getIconAnchor() {
+ return jsonObject.get("icon-anchor").getAsString();
+ }
+
+ /**
+ * Set the IconAnchor property
+ *
+ * @return property wrapper value around String
+ */
+ public void setIconAnchor(String value) {
+ jsonObject.addProperty("icon-anchor", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextField property
+ *
+ * @return property wrapper value around String
+ */
+ public String getTextField() {
+ return jsonObject.get("text-field").getAsString();
+ }
+
+ /**
+ * Set the TextField property
+ *
+ * @return property wrapper value around String
+ */
+ public void setTextField(String value) {
+ jsonObject.addProperty("text-field", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextFont property
+ *
+ * @return property wrapper value around String[]
+ */
+ public String[] getTextFont() {
+ JsonArray jsonArray = jsonObject.getAsJsonArray("text-font");
+ String[] value = new String[jsonArray.size()];
+ for (int i = 0; i < jsonArray.size(); i++) {
+ value[i] = jsonArray.get(i).getAsString();
+ }
+ return value;
+ }
+
+ /**
+ * Set the TextFont property
+ *
+ * @return property wrapper value around String[]
+ */
+ public void setTextFont(String[] value) {
+ JsonArray jsonArray = new JsonArray();
+ for (String element : value) {
+ jsonArray.add(element);
+ }
+ jsonObject.add("text-font", jsonArray);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextSize property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextSize() {
+ return jsonObject.get("text-size").getAsFloat();
+ }
+
+ /**
+ * Set the TextSize property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setTextSize(Float value) {
+ jsonObject.addProperty("text-size", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextMaxWidth property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextMaxWidth() {
+ return jsonObject.get("text-max-width").getAsFloat();
+ }
+
+ /**
+ * Set the TextMaxWidth property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setTextMaxWidth(Float value) {
+ jsonObject.addProperty("text-max-width", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextLetterSpacing property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextLetterSpacing() {
+ return jsonObject.get("text-letter-spacing").getAsFloat();
+ }
+
+ /**
+ * Set the TextLetterSpacing property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setTextLetterSpacing(Float value) {
+ jsonObject.addProperty("text-letter-spacing", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextJustify property
+ *
+ * @return property wrapper value around String
+ */
+ public String getTextJustify() {
+ return jsonObject.get("text-justify").getAsString();
+ }
+
+ /**
+ * Set the TextJustify property
+ *
+ * @return property wrapper value around String
+ */
+ public void setTextJustify(String value) {
+ jsonObject.addProperty("text-justify", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextAnchor property
+ *
+ * @return property wrapper value around String
+ */
+ public String getTextAnchor() {
+ return jsonObject.get("text-anchor").getAsString();
+ }
+
+ /**
+ * Set the TextAnchor property
+ *
+ * @return property wrapper value around String
+ */
+ public void setTextAnchor(String value) {
+ jsonObject.addProperty("text-anchor", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextRotate property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextRotate() {
+ return jsonObject.get("text-rotate").getAsFloat();
+ }
+
+ /**
+ * Set the TextRotate property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setTextRotate(Float value) {
+ jsonObject.addProperty("text-rotate", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextTransform property
+ *
+ * @return property wrapper value around String
+ */
+ public String getTextTransform() {
+ return jsonObject.get("text-transform").getAsString();
+ }
+
+ /**
+ * Set the TextTransform property
+ *
+ * @return property wrapper value around String
+ */
+ public void setTextTransform(String value) {
+ jsonObject.addProperty("text-transform", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextOffset property
+ *
+ * @return property wrapper value around Float[]
+ */
+ public Float[] getTextOffset() {
+ JsonArray jsonArray = jsonObject.getAsJsonArray("text-offset");
+ Float[] value = new Float[jsonArray.size()];
+ for (int i = 0; i < jsonArray.size(); i++) {
+ value[i] = jsonArray.get(i).getAsFloat();
+ }
+ return value;
+ }
+
+ /**
+ * Set the TextOffset property
+ *
+ * @return property wrapper value around Float[]
+ */
+ public void setTextOffset(Float[] value) {
+ JsonArray jsonArray = new JsonArray();
+ for (Float element : value) {
+ jsonArray.add(element);
+ }
+ jsonObject.add("text-offset", jsonArray);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the IconOpacity property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getIconOpacity() {
+ return jsonObject.get("icon-opacity").getAsFloat();
+ }
+
+ /**
+ * Set the IconOpacity property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setIconOpacity(Float value) {
+ jsonObject.addProperty("icon-opacity", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the IconColor property
+ *
+ * @return property wrapper value around String
+ */
+ public String getIconColor() {
+ return jsonObject.get("icon-color").getAsString();
+ }
+
+ /**
+ * Set the IconColor property
+ *
+ * @return property wrapper value around String
+ */
+ public void setIconColor(String value) {
+ jsonObject.addProperty("icon-color", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the IconHaloColor property
+ *
+ * @return property wrapper value around String
+ */
+ public String getIconHaloColor() {
+ return jsonObject.get("icon-halo-color").getAsString();
+ }
+
+ /**
+ * Set the IconHaloColor property
+ *
+ * @return property wrapper value around String
+ */
+ public void setIconHaloColor(String value) {
+ jsonObject.addProperty("icon-halo-color", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the IconHaloWidth property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getIconHaloWidth() {
+ return jsonObject.get("icon-halo-width").getAsFloat();
+ }
+
+ /**
+ * Set the IconHaloWidth property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setIconHaloWidth(Float value) {
+ jsonObject.addProperty("icon-halo-width", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the IconHaloBlur property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getIconHaloBlur() {
+ return jsonObject.get("icon-halo-blur").getAsFloat();
+ }
+
+ /**
+ * Set the IconHaloBlur property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setIconHaloBlur(Float value) {
+ jsonObject.addProperty("icon-halo-blur", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextOpacity property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextOpacity() {
+ return jsonObject.get("text-opacity").getAsFloat();
+ }
+
+ /**
+ * Set the TextOpacity property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setTextOpacity(Float value) {
+ jsonObject.addProperty("text-opacity", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextColor property
+ *
+ * @return property wrapper value around String
+ */
+ public String getTextColor() {
+ return jsonObject.get("text-color").getAsString();
+ }
+
+ /**
+ * Set the TextColor property
+ *
+ * @return property wrapper value around String
+ */
+ public void setTextColor(String value) {
+ jsonObject.addProperty("text-color", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextHaloColor property
+ *
+ * @return property wrapper value around String
+ */
+ public String getTextHaloColor() {
+ return jsonObject.get("text-halo-color").getAsString();
+ }
+
+ /**
+ * Set the TextHaloColor property
+ *
+ * @return property wrapper value around String
+ */
+ public void setTextHaloColor(String value) {
+ jsonObject.addProperty("text-halo-color", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextHaloWidth property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextHaloWidth() {
+ return jsonObject.get("text-halo-width").getAsFloat();
+ }
+
+ /**
+ * Set the TextHaloWidth property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setTextHaloWidth(Float value) {
+ jsonObject.addProperty("text-halo-width", value);
+ symbolManager.updateSource();
+ }
+
+ /**
+ * Get the TextHaloBlur property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextHaloBlur() {
+ return jsonObject.get("text-halo-blur").getAsFloat();
+ }
+
+ /**
+ * Set the TextHaloBlur property
+ *
+ * @return property wrapper value around Float
+ */
+ public void setTextHaloBlur(Float value) {
+ jsonObject.addProperty("text-halo-blur", value);
+ symbolManager.updateSource();
+ }
+
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/SymbolManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/SymbolManager.java
new file mode 100644
index 0000000000..c0b745d954
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/SymbolManager.java
@@ -0,0 +1,597 @@
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
+
+package com.mapbox.mapboxsdk.symbol;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.UiThread;
+import android.support.annotation.VisibleForTesting;
+import com.mapbox.geojson.Feature;
+import com.mapbox.geojson.FeatureCollection;
+import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.style.layers.PropertyValue;
+import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
+import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+
+/**
+ * The symbol manager allows to add symbols to a map.
+ */
+public class SymbolManager {
+
+ public static final String ID_GEOJSON_SOURCE = "mapbox-android-symbol-source";
+ public static final String ID_GEOJSON_LAYER = "mapbox-android-symbol-layer";
+
+ // map integration components
+ private GeoJsonSource geoJsonSource;
+ private SymbolLayer symbolLayer;
+
+ // internal data set
+ private List<Symbol> symbolList = new ArrayList<>();
+ private long currentMarkerId;
+
+ /**
+ * Create a symbol manager, used to manage symbols.
+ *
+ * @param mapboxMap the map object to add symbols to
+ */
+ @UiThread
+ public SymbolManager(@NonNull MapboxMap mapboxMap) {
+ this(mapboxMap, new GeoJsonSource(ID_GEOJSON_SOURCE), new SymbolLayer(ID_GEOJSON_LAYER, ID_GEOJSON_SOURCE)
+ .withProperties(
+ getLayerDefinition()
+ )
+ );
+ }
+
+ /**
+ * Create a symbol manager, used to manage symbols.
+ *
+ * @param mapboxMap the map object to add symbols to
+ * @param geoJsonSource the geojson source to add symbols to
+ * @param symbolLayer the sybol layer to visualise symbols with
+ */
+ @VisibleForTesting
+ public SymbolManager(MapboxMap mapboxMap, @NonNull GeoJsonSource geoJsonSource, SymbolLayer symbolLayer) {
+ this.geoJsonSource = geoJsonSource;
+ this.symbolLayer = symbolLayer;
+ mapboxMap.addSource(geoJsonSource);
+ mapboxMap.addLayer(symbolLayer);
+ }
+
+ /**
+ * Create a symbol on the map from a LatLng coordinate.
+ *
+ * @param latLng place to layout the symbol on the map
+ * @return the newly created symbol
+ */
+ @UiThread
+ public Symbol createSymbol(@NonNull LatLng latLng) {
+ Symbol symbol = new Symbol(this, currentMarkerId);
+ symbol.setLatLng(latLng);
+ currentMarkerId++;
+ symbolList.add(symbol);
+ return symbol;
+ }
+
+ /**
+ * Delete a symbol from the map.
+ *
+ * @param symbol to be deleted
+ */
+ @UiThread
+ public void deleteSymbol(@NonNull Symbol symbol) {
+ symbolList.remove(symbol);
+ updateSource();
+ }
+
+ /**
+ * Get a list of current symbols.
+ *
+ * @return list of symbols
+ */
+ @UiThread
+ public List<Symbol> getSymbols() {
+ return symbolList;
+ }
+
+ /**
+ * Trigger an update to the underlying source
+ */
+ public void updateSource() {
+ // todo move feature creation to a background thread?
+ List<Feature> features = new ArrayList<>();
+ for (Symbol symbol : symbolList) {
+ features.add(Feature.fromGeometry(symbol.getGeometry(), symbol.getFeature()));
+ }
+ geoJsonSource.setGeoJson(FeatureCollection.fromFeatures(features));
+ }
+
+
+ private static PropertyValue<?>[] getLayerDefinition() {
+ return new PropertyValue[]{
+ iconSize(get("icon-size")),
+ iconImage(get("icon-image")),
+ iconRotate(get("icon-rotate")),
+ iconOffset(get("icon-offset")),
+ iconAnchor(get("icon-anchor")),
+ textField(get("text-field")),
+ textFont(get("text-font")),
+ textSize(get("text-size")),
+ textMaxWidth(get("text-max-width")),
+ textLetterSpacing(get("text-letter-spacing")),
+ textJustify(get("text-justify")),
+ textAnchor(get("text-anchor")),
+ textRotate(get("text-rotate")),
+ textTransform(get("text-transform")),
+ textOffset(get("text-offset")),
+ iconOpacity(get("icon-opacity")),
+ iconColor(get("icon-color")),
+ iconHaloColor(get("icon-halo-color")),
+ iconHaloWidth(get("icon-halo-width")),
+ iconHaloBlur(get("icon-halo-blur")),
+ textOpacity(get("text-opacity")),
+ textColor(get("text-color")),
+ textHaloColor(get("text-halo-color")),
+ textHaloWidth(get("text-halo-width")),
+ textHaloBlur(get("text-halo-blur")),
+ };
+ }
+
+ // Property accessors
+ /**
+ * Get the SymbolPlacement property
+ *
+ * @return property wrapper value around String
+ */
+ public String getSymbolPlacement() {
+ return symbolLayer.getSymbolPlacement().value;
+ }
+
+ /**
+ * Set the SymbolPlacement property
+ *
+ * @param value property wrapper value around String
+ */
+ public void setSymbolPlacement(String value) {
+ symbolLayer.setProperties(symbolPlacement(value));
+ }
+
+ /**
+ * Get the SymbolSpacing property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getSymbolSpacing() {
+ return symbolLayer.getSymbolSpacing().value;
+ }
+
+ /**
+ * Set the SymbolSpacing property
+ *
+ * @param value property wrapper value around Float
+ */
+ public void setSymbolSpacing(Float value) {
+ symbolLayer.setProperties(symbolSpacing(value));
+ }
+
+ /**
+ * Get the SymbolAvoidEdges property
+ *
+ * @return property wrapper value around Boolean
+ */
+ public Boolean getSymbolAvoidEdges() {
+ return symbolLayer.getSymbolAvoidEdges().value;
+ }
+
+ /**
+ * Set the SymbolAvoidEdges property
+ *
+ * @param value property wrapper value around Boolean
+ */
+ public void setSymbolAvoidEdges(Boolean value) {
+ symbolLayer.setProperties(symbolAvoidEdges(value));
+ }
+
+ /**
+ * Get the IconAllowOverlap property
+ *
+ * @return property wrapper value around Boolean
+ */
+ public Boolean getIconAllowOverlap() {
+ return symbolLayer.getIconAllowOverlap().value;
+ }
+
+ /**
+ * Set the IconAllowOverlap property
+ *
+ * @param value property wrapper value around Boolean
+ */
+ public void setIconAllowOverlap(Boolean value) {
+ symbolLayer.setProperties(iconAllowOverlap(value));
+ }
+
+ /**
+ * Get the IconIgnorePlacement property
+ *
+ * @return property wrapper value around Boolean
+ */
+ public Boolean getIconIgnorePlacement() {
+ return symbolLayer.getIconIgnorePlacement().value;
+ }
+
+ /**
+ * Set the IconIgnorePlacement property
+ *
+ * @param value property wrapper value around Boolean
+ */
+ public void setIconIgnorePlacement(Boolean value) {
+ symbolLayer.setProperties(iconIgnorePlacement(value));
+ }
+
+ /**
+ * Get the IconOptional property
+ *
+ * @return property wrapper value around Boolean
+ */
+ public Boolean getIconOptional() {
+ return symbolLayer.getIconOptional().value;
+ }
+
+ /**
+ * Set the IconOptional property
+ *
+ * @param value property wrapper value around Boolean
+ */
+ public void setIconOptional(Boolean value) {
+ symbolLayer.setProperties(iconOptional(value));
+ }
+
+ /**
+ * Get the IconRotationAlignment property
+ *
+ * @return property wrapper value around String
+ */
+ public String getIconRotationAlignment() {
+ return symbolLayer.getIconRotationAlignment().value;
+ }
+
+ /**
+ * Set the IconRotationAlignment property
+ *
+ * @param value property wrapper value around String
+ */
+ public void setIconRotationAlignment(String value) {
+ symbolLayer.setProperties(iconRotationAlignment(value));
+ }
+
+ /**
+ * Get the IconTextFit property
+ *
+ * @return property wrapper value around String
+ */
+ public String getIconTextFit() {
+ return symbolLayer.getIconTextFit().value;
+ }
+
+ /**
+ * Set the IconTextFit property
+ *
+ * @param value property wrapper value around String
+ */
+ public void setIconTextFit(String value) {
+ symbolLayer.setProperties(iconTextFit(value));
+ }
+
+ /**
+ * Get the IconTextFitPadding property
+ *
+ * @return property wrapper value around Float[]
+ */
+ public Float[] getIconTextFitPadding() {
+ return symbolLayer.getIconTextFitPadding().value;
+ }
+
+ /**
+ * Set the IconTextFitPadding property
+ *
+ * @param value property wrapper value around Float[]
+ */
+ public void setIconTextFitPadding(Float[] value) {
+ symbolLayer.setProperties(iconTextFitPadding(value));
+ }
+
+ /**
+ * Get the IconPadding property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getIconPadding() {
+ return symbolLayer.getIconPadding().value;
+ }
+
+ /**
+ * Set the IconPadding property
+ *
+ * @param value property wrapper value around Float
+ */
+ public void setIconPadding(Float value) {
+ symbolLayer.setProperties(iconPadding(value));
+ }
+
+ /**
+ * Get the IconKeepUpright property
+ *
+ * @return property wrapper value around Boolean
+ */
+ public Boolean getIconKeepUpright() {
+ return symbolLayer.getIconKeepUpright().value;
+ }
+
+ /**
+ * Set the IconKeepUpright property
+ *
+ * @param value property wrapper value around Boolean
+ */
+ public void setIconKeepUpright(Boolean value) {
+ symbolLayer.setProperties(iconKeepUpright(value));
+ }
+
+ /**
+ * Get the IconPitchAlignment property
+ *
+ * @return property wrapper value around String
+ */
+ public String getIconPitchAlignment() {
+ return symbolLayer.getIconPitchAlignment().value;
+ }
+
+ /**
+ * Set the IconPitchAlignment property
+ *
+ * @param value property wrapper value around String
+ */
+ public void setIconPitchAlignment(String value) {
+ symbolLayer.setProperties(iconPitchAlignment(value));
+ }
+
+ /**
+ * Get the TextPitchAlignment property
+ *
+ * @return property wrapper value around String
+ */
+ public String getTextPitchAlignment() {
+ return symbolLayer.getTextPitchAlignment().value;
+ }
+
+ /**
+ * Set the TextPitchAlignment property
+ *
+ * @param value property wrapper value around String
+ */
+ public void setTextPitchAlignment(String value) {
+ symbolLayer.setProperties(textPitchAlignment(value));
+ }
+
+ /**
+ * Get the TextRotationAlignment property
+ *
+ * @return property wrapper value around String
+ */
+ public String getTextRotationAlignment() {
+ return symbolLayer.getTextRotationAlignment().value;
+ }
+
+ /**
+ * Set the TextRotationAlignment property
+ *
+ * @param value property wrapper value around String
+ */
+ public void setTextRotationAlignment(String value) {
+ symbolLayer.setProperties(textRotationAlignment(value));
+ }
+
+ /**
+ * Get the TextLineHeight property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextLineHeight() {
+ return symbolLayer.getTextLineHeight().value;
+ }
+
+ /**
+ * Set the TextLineHeight property
+ *
+ * @param value property wrapper value around Float
+ */
+ public void setTextLineHeight(Float value) {
+ symbolLayer.setProperties(textLineHeight(value));
+ }
+
+ /**
+ * Get the TextMaxAngle property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextMaxAngle() {
+ return symbolLayer.getTextMaxAngle().value;
+ }
+
+ /**
+ * Set the TextMaxAngle property
+ *
+ * @param value property wrapper value around Float
+ */
+ public void setTextMaxAngle(Float value) {
+ symbolLayer.setProperties(textMaxAngle(value));
+ }
+
+ /**
+ * Get the TextPadding property
+ *
+ * @return property wrapper value around Float
+ */
+ public Float getTextPadding() {
+ return symbolLayer.getTextPadding().value;
+ }
+
+ /**
+ * Set the TextPadding property
+ *
+ * @param value property wrapper value around Float
+ */
+ public void setTextPadding(Float value) {
+ symbolLayer.setProperties(textPadding(value));
+ }
+
+ /**
+ * Get the TextKeepUpright property
+ *
+ * @return property wrapper value around Boolean
+ */
+ public Boolean getTextKeepUpright() {
+ return symbolLayer.getTextKeepUpright().value;
+ }
+
+ /**
+ * Set the TextKeepUpright property
+ *
+ * @param value property wrapper value around Boolean
+ */
+ public void setTextKeepUpright(Boolean value) {
+ symbolLayer.setProperties(textKeepUpright(value));
+ }
+
+ /**
+ * Get the TextAllowOverlap property
+ *
+ * @return property wrapper value around Boolean
+ */
+ public Boolean getTextAllowOverlap() {
+ return symbolLayer.getTextAllowOverlap().value;
+ }
+
+ /**
+ * Set the TextAllowOverlap property
+ *
+ * @param value property wrapper value around Boolean
+ */
+ public void setTextAllowOverlap(Boolean value) {
+ symbolLayer.setProperties(textAllowOverlap(value));
+ }
+
+ /**
+ * Get the TextIgnorePlacement property
+ *
+ * @return property wrapper value around Boolean
+ */
+ public Boolean getTextIgnorePlacement() {
+ return symbolLayer.getTextIgnorePlacement().value;
+ }
+
+ /**
+ * Set the TextIgnorePlacement property
+ *
+ * @param value property wrapper value around Boolean
+ */
+ public void setTextIgnorePlacement(Boolean value) {
+ symbolLayer.setProperties(textIgnorePlacement(value));
+ }
+
+ /**
+ * Get the TextOptional property
+ *
+ * @return property wrapper value around Boolean
+ */
+ public Boolean getTextOptional() {
+ return symbolLayer.getTextOptional().value;
+ }
+
+ /**
+ * Set the TextOptional property
+ *
+ * @param value property wrapper value around Boolean
+ */
+ public void setTextOptional(Boolean value) {
+ symbolLayer.setProperties(textOptional(value));
+ }
+
+ /**
+ * Get the IconTranslate property
+ *
+ * @return property wrapper value around Float[]
+ */
+ public Float[] getIconTranslate() {
+ return symbolLayer.getIconTranslate().value;
+ }
+
+ /**
+ * Set the IconTranslate property
+ *
+ * @param value property wrapper value around Float[]
+ */
+ public void setIconTranslate(Float[] value) {
+ symbolLayer.setProperties(iconTranslate(value));
+ }
+
+ /**
+ * Get the IconTranslateAnchor property
+ *
+ * @return property wrapper value around String
+ */
+ public String getIconTranslateAnchor() {
+ return symbolLayer.getIconTranslateAnchor().value;
+ }
+
+ /**
+ * Set the IconTranslateAnchor property
+ *
+ * @param value property wrapper value around String
+ */
+ public void setIconTranslateAnchor(String value) {
+ symbolLayer.setProperties(iconTranslateAnchor(value));
+ }
+
+ /**
+ * Get the TextTranslate property
+ *
+ * @return property wrapper value around Float[]
+ */
+ public Float[] getTextTranslate() {
+ return symbolLayer.getTextTranslate().value;
+ }
+
+ /**
+ * Set the TextTranslate property
+ *
+ * @param value property wrapper value around Float[]
+ */
+ public void setTextTranslate(Float[] value) {
+ symbolLayer.setProperties(textTranslate(value));
+ }
+
+ /**
+ * Get the TextTranslateAnchor property
+ *
+ * @return property wrapper value around String
+ */
+ public String getTextTranslateAnchor() {
+ return symbolLayer.getTextTranslateAnchor().value;
+ }
+
+ /**
+ * Set the TextTranslateAnchor property
+ *
+ * @param value property wrapper value around String
+ */
+ public void setTextTranslateAnchor(String value) {
+ symbolLayer.setProperties(textTranslateAnchor(value));
+ }
+
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/symbol.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/symbol.java.ejs
new file mode 100644
index 0000000000..966e1681de
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/symbol.java.ejs
@@ -0,0 +1,123 @@
+<%
+ const type = locals.type;
+ const properties = locals.properties;
+ const doc = locals.doc;
+-%>
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
+
+package com.mapbox.mapboxsdk.symbol;
+
+import android.support.annotation.UiThread;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.mapbox.geojson.Geometry;
+import com.mapbox.geojson.Point;
+import com.mapbox.mapboxsdk.geometry.LatLng;
+
+@UiThread
+public class Symbol {
+
+ public static final String ID_KEY = "id-symbol";
+
+ private final SymbolManager symbolManager;
+ private final JsonObject jsonObject = new JsonObject();
+ private Geometry geometry;
+
+ /**
+ * Create a symbol.
+ *
+ * @param symbolManager the symbol manager created and managing the symbol
+ * @param id the id of the symbol
+ */
+ Symbol(SymbolManager symbolManager, long id) {
+ this.symbolManager = symbolManager;
+ this.jsonObject.addProperty(ID_KEY, id);
+ }
+
+ /**
+ * Get the symbol geometry.
+ *
+ * @return the symbol geometry
+ */
+ Geometry getGeometry() {
+ if (geometry == null) {
+ throw new IllegalStateException();
+ }
+ return geometry;
+ }
+
+ /**
+ * Get the symbol feature properties.
+ *
+ * @return the symbol feature properties
+ */
+ JsonObject getFeature() {
+ return jsonObject;
+ }
+
+ /**
+ * Set the LatLng of the symbol, which represents the location of the symbol on the map
+ *
+ * @param latLng the location of the symbol in a longitude and latitude pair
+ */
+ public void setLatLng(LatLng latLng) {
+ geometry = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude());
+ symbolManager.updateSource();
+ }
+
+ // Property accessors
+<% for (const property of properties) { -%>
+<% if (supportsPropertyFunction(property)) { -%>
+<% if (propertyType(property).endsWith("[]")) { -%>
+ /**
+ * Get the <%- camelize(property.name) %> property
+ *
+ * @return property wrapper value around <%- propertyType(property) %>
+ */
+ public <%- propertyType(property) %> get<%- camelize(property.name) %>() {
+ JsonArray jsonArray = jsonObject.getAsJsonArray("<%-property.name %>");
+ <%- propertyType(property) %> value = new <%- propertyType(property).substring(0, propertyType(property).length-1) %>jsonArray.size()];
+ for (int i = 0; i < jsonArray.size(); i++) {
+ value[i] = jsonArray.get(i).getAs<%- propertyType(property).substring(0, propertyType(property).length-2) %>();
+ }
+ return value;
+ }
+
+ /**
+ * Set the <%- camelize(property.name) %> property
+ *
+ * @return property wrapper value around <%- propertyType(property) %>
+ */
+ public void set<%- camelize(property.name) %>(<%- propertyType(property) %> value) {
+ JsonArray jsonArray = new JsonArray();
+ for (<%- propertyType(property).substring(0, propertyType(property).length-2) %> element : value) {
+ jsonArray.add(element);
+ }
+ jsonObject.add("<%-property.name %>", jsonArray);
+ symbolManager.updateSource();
+ }
+
+<% } else { -%>
+ /**
+ * Get the <%- camelize(property.name) %> property
+ *
+ * @return property wrapper value around <%- propertyType(property) %>
+ */
+ public <%- propertyType(property) %> get<%- camelize(property.name) %>() {
+ return jsonObject.get("<%- property.name %>").getAs<%- propertyType(property) %>();
+ }
+
+ /**
+ * Set the <%- camelize(property.name) %> property
+ *
+ * @return property wrapper value around <%- propertyType(property) %>
+ */
+ public void set<%- camelize(property.name) %>(<%- propertyType(property) %> value) {
+ jsonObject.addProperty("<%- property.name %>", value);
+ symbolManager.updateSource();
+ }
+
+<% } -%>
+<% } -%>
+<% } -%>
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/symbolManager.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/symbolManager.java.ejs
new file mode 100644
index 0000000000..6beb700241
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/symbolManager.java.ejs
@@ -0,0 +1,153 @@
+<%
+ const type = locals.type;
+ const properties = locals.properties;
+ const doc = locals.doc;
+-%>
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
+
+package com.mapbox.mapboxsdk.symbol;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.UiThread;
+import android.support.annotation.VisibleForTesting;
+import com.mapbox.geojson.Feature;
+import com.mapbox.geojson.FeatureCollection;
+import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.style.layers.PropertyValue;
+import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
+import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
+import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
+
+/**
+ * The symbol manager allows to add symbols to a map.
+ */
+public class SymbolManager {
+
+ public static final String ID_GEOJSON_SOURCE = "mapbox-android-symbol-source";
+ public static final String ID_GEOJSON_LAYER = "mapbox-android-symbol-layer";
+
+ // map integration components
+ private GeoJsonSource geoJsonSource;
+ private SymbolLayer symbolLayer;
+
+ // internal data set
+ private List<Symbol> symbolList = new ArrayList<>();
+ private long currentMarkerId;
+
+ /**
+ * Create a symbol manager, used to manage symbols.
+ *
+ * @param mapboxMap the map object to add symbols to
+ */
+ @UiThread
+ public SymbolManager(@NonNull MapboxMap mapboxMap) {
+ this(mapboxMap, new GeoJsonSource(ID_GEOJSON_SOURCE), new SymbolLayer(ID_GEOJSON_LAYER, ID_GEOJSON_SOURCE)
+ .withProperties(
+ getLayerDefinition()
+ )
+ );
+ }
+
+ /**
+ * Create a symbol manager, used to manage symbols.
+ *
+ * @param mapboxMap the map object to add symbols to
+ * @param geoJsonSource the geojson source to add symbols to
+ * @param symbolLayer the sybol layer to visualise symbols with
+ */
+ @VisibleForTesting
+ public SymbolManager(MapboxMap mapboxMap, @NonNull GeoJsonSource geoJsonSource, SymbolLayer symbolLayer) {
+ this.geoJsonSource = geoJsonSource;
+ this.symbolLayer = symbolLayer;
+ mapboxMap.addSource(geoJsonSource);
+ mapboxMap.addLayer(symbolLayer);
+ }
+
+ /**
+ * Create a symbol on the map from a LatLng coordinate.
+ *
+ * @param latLng place to layout the symbol on the map
+ * @return the newly created symbol
+ */
+ @UiThread
+ public Symbol createSymbol(@NonNull LatLng latLng) {
+ Symbol symbol = new Symbol(this, currentMarkerId);
+ symbol.setLatLng(latLng);
+ currentMarkerId++;
+ symbolList.add(symbol);
+ return symbol;
+ }
+
+ /**
+ * Delete a symbol from the map.
+ *
+ * @param symbol to be deleted
+ */
+ @UiThread
+ public void deleteSymbol(@NonNull Symbol symbol) {
+ symbolList.remove(symbol);
+ updateSource();
+ }
+
+ /**
+ * Get a list of current symbols.
+ *
+ * @return list of symbols
+ */
+ @UiThread
+ public List<Symbol> getSymbols() {
+ return symbolList;
+ }
+
+ /**
+ * Trigger an update to the underlying source
+ */
+ public void updateSource() {
+ // todo move feature creation to a background thread?
+ List<Feature> features = new ArrayList<>();
+ for (Symbol symbol : symbolList) {
+ features.add(Feature.fromGeometry(symbol.getGeometry(), symbol.getFeature()));
+ }
+ geoJsonSource.setGeoJson(FeatureCollection.fromFeatures(features));
+ }
+
+
+ private static PropertyValue<?>[] getLayerDefinition() {
+ return new PropertyValue[]{
+<% for (const property of properties) { -%>
+<% if (supportsPropertyFunction(property)) { -%>
+ <%- camelizeWithLeadingLowercase(property.name) %>(get("<%- property.name %>")),
+<% } -%><% } -%>
+ };
+ }
+
+ // Property accessors
+<% for (const property of properties) { -%>
+<% if (!supportsPropertyFunction(property)) { -%>
+ /**
+ * Get the <%- camelize(property.name) %> property
+ *
+ * @return property wrapper value around <%- propertyType(property) %>
+ */
+ public <%- propertyType(property) %> get<%- camelize(property.name) %>() {
+ return symbolLayer.get<%- camelize(property.name) %>().value;
+ }
+
+ /**
+ * Set the <%- camelize(property.name) %> property
+ *
+ * @param value property wrapper value around <%- propertyType(property) %>
+ */
+ public void set<%- camelize(property.name) %>(<%- propertyType(property) %> value) {
+ symbolLayer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(value));
+ }
+
+<% } -%>
+<% } -%>
+}