diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
index 3b2cd99ce..c72dc63fb 100644
--- a/gradle/dependencies.gradle
+++ b/gradle/dependencies.gradle
@@ -31,7 +31,7 @@
pluginVersion = [
checkstyle: '8.10.1',
gradle : '3.4.0',
- kotlin : '1.3.20',
+ kotlin : '1.3.31',
dokka : '0.9.17'
]
diff --git a/plugin-stylejson/.gitignore b/plugin-stylejson/.gitignore
new file mode 100644
index 000000000..796b96d1c
--- /dev/null
+++ b/plugin-stylejson/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/plugin-stylejson/build.gradle b/plugin-stylejson/build.gradle
new file mode 100644
index 000000000..445ec091b
--- /dev/null
+++ b/plugin-stylejson/build.gradle
@@ -0,0 +1,37 @@
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android-extensions'
+apply plugin: 'kotlin-android'
+
+android {
+ compileSdkVersion androidVersions.compileSdkVersion
+
+ defaultConfig {
+ minSdkVersion androidVersions.minSdkVersion
+ targetSdkVersion androidVersions.targetSdkVersion
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+
+ configurations {
+ javadocDeps
+ }
+
+ lintOptions {
+ abortOnError false
+ }
+
+ testOptions {
+ unitTests.returnDefaultValues true
+ }
+}
+
+dependencies {
+ implementation dependenciesList.kotlin
+ implementation dependenciesList.mapboxMapSdk
+ javadocDeps dependenciesList.mapboxMapSdk
+ testImplementation dependenciesList.junit
+ testImplementation dependenciesList.mockito
+}
+
+apply from: "${rootDir}/gradle/javadoc.gradle"
+apply from: "${rootDir}/gradle/publish.gradle"
+apply from: "${rootDir}/gradle/checkstyle.gradle"
\ No newline at end of file
diff --git a/plugin-stylejson/gradle.properties b/plugin-stylejson/gradle.properties
new file mode 100644
index 000000000..e7623ba4d
--- /dev/null
+++ b/plugin-stylejson/gradle.properties
@@ -0,0 +1,5 @@
+VERSION_NAME=0.1.0-SNAPSHOT
+POM_ARTIFACT_ID=mapbox-android-plugin-stylejson
+POM_NAME=Mapbox Android StyleJson Plugin
+POM_DESCRIPTION=Mapbox Android StyleJson Plugin
+POM_PACKAGING=aar
\ No newline at end of file
diff --git a/plugin-stylejson/proguard-rules.pro b/plugin-stylejson/proguard-rules.pro
new file mode 100644
index 000000000..f1b424510
--- /dev/null
+++ b/plugin-stylejson/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/plugin-stylejson/src/main/AndroidManifest.xml b/plugin-stylejson/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..aba05813e
--- /dev/null
+++ b/plugin-stylejson/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+
diff --git a/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/LayerJsonParser.kt b/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/LayerJsonParser.kt
new file mode 100644
index 000000000..9be45a804
--- /dev/null
+++ b/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/LayerJsonParser.kt
@@ -0,0 +1,48 @@
+package com.mapbox.pluginstylejson
+
+import com.google.gson.JsonObject
+import com.mapbox.mapboxsdk.style.layers.*
+
+class LayerJsonParser {
+
+ internal fun parserBackgroundLayer(id: String, json: JsonObject): BackgroundLayer {
+ return BackgroundLayer(id)
+ }
+
+ internal fun parserCircleLayer(id: String, json: JsonObject): CircleLayer {
+ return CircleLayer(id, "")
+ }
+
+ internal fun parserCustomLayer(id: String, json: JsonObject): CustomLayer {
+ return CustomLayer(id, 0)
+ }
+
+ internal fun parserFillExtrusionLayer(id: String, json: JsonObject): FillExtrusionLayer {
+ return FillExtrusionLayer(id, "")
+ }
+
+ internal fun parserFillLayer(id: String, json: JsonObject): FillLayer {
+ return FillLayer(id, "")
+ }
+
+ internal fun parserHeatmapLayer(id: String, json: JsonObject): HeatmapLayer {
+ return HeatmapLayer(id, "")
+ }
+
+ internal fun parserHillshadeLayer(id: String, json: JsonObject): HillshadeLayer {
+ return HillshadeLayer(id, "")
+ }
+
+ internal fun parserLineLayer(id: String, json: JsonObject): LineLayer {
+ return LineLayer(id, "")
+ }
+
+ internal fun parserRasterLayer(id: String, json: JsonObject): RasterLayer {
+ return RasterLayer(id, "")
+ }
+
+ internal fun parserSymbolLayer(id: String, json: JsonObject): SymbolLayer {
+ return SymbolLayer(id, "")
+ }
+
+}
\ No newline at end of file
diff --git a/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/SourceJsonParser.kt b/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/SourceJsonParser.kt
new file mode 100644
index 000000000..13ed83570
--- /dev/null
+++ b/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/SourceJsonParser.kt
@@ -0,0 +1,63 @@
+package com.mapbox.pluginstylejson
+
+import com.google.gson.JsonObject
+import com.mapbox.geojson.*
+import com.mapbox.mapboxsdk.style.sources.*
+import com.mapbox.pluginstylejson.StyleJsonContants.GEO_JSON_FEATURE
+import com.mapbox.pluginstylejson.StyleJsonContants.GEO_JSON_FEATURE_COLLECTION
+import com.mapbox.pluginstylejson.StyleJsonContants.GEO_JSON_GEOMETRY_COLLECTION
+import com.mapbox.pluginstylejson.StyleJsonContants.GEO_JSON_LINE_STRING
+import com.mapbox.pluginstylejson.StyleJsonContants.GEO_JSON_MULTI_POINT
+import com.mapbox.pluginstylejson.StyleJsonContants.GEO_JSON_MULTI_POLYGON
+import com.mapbox.pluginstylejson.StyleJsonContants.GEO_JSON_NULTI_LINE_STRING
+import com.mapbox.pluginstylejson.StyleJsonContants.GEO_JSON_POINT
+import com.mapbox.pluginstylejson.StyleJsonContants.GEO_JSON_POLYGON
+
+class SourceJsonParser {
+
+ internal fun parserGeoJsonSource(id: String, json: JsonObject): GeoJsonSource {
+ val geoJsonSource = GeoJsonSource(id)
+ if (json.has("data")) {
+ val data = json.getAsJsonObject("data")
+ val dataString = data.asString
+ if (dataString.startsWith("http")) {
+ geoJsonSource.url = dataString
+ } else {
+ val type = data.get("type").asString
+ when (type) {
+ GEO_JSON_FEATURE -> geoJsonSource.setGeoJson(Feature.fromJson(dataString))
+ GEO_JSON_FEATURE_COLLECTION -> geoJsonSource.setGeoJson(FeatureCollection.fromJson(dataString))
+ GEO_JSON_GEOMETRY_COLLECTION -> geoJsonSource.setGeoJson(GeometryCollection.fromJson(dataString))
+ GEO_JSON_LINE_STRING -> geoJsonSource.setGeoJson(LineString.fromJson(dataString))
+ GEO_JSON_NULTI_LINE_STRING -> geoJsonSource.setGeoJson(MultiLineString.fromJson(dataString))
+ GEO_JSON_MULTI_POINT -> geoJsonSource.setGeoJson(MultiPoint.fromJson(dataString))
+ GEO_JSON_MULTI_POLYGON -> geoJsonSource.setGeoJson(MultiPolygon.fromJson(dataString))
+ GEO_JSON_POINT -> geoJsonSource.setGeoJson(Point.fromJson(dataString))
+ GEO_JSON_POLYGON -> geoJsonSource.setGeoJson(Polygon.fromJson(dataString))
+ }
+ }
+ }
+
+ return geoJsonSource
+ }
+
+ internal fun parserVectorSource(id: String, json: JsonObject): VectorSource {
+ return VectorSource(id, "")
+ }
+
+ internal fun parserCustomGeometrySource(id: String, json: JsonObject): CustomGeometrySource {
+ return CustomGeometrySource(id, null)
+ }
+
+ internal fun parserImageSource(id: String, json: JsonObject): ImageSource {
+ return ImageSource(id, null, 0)
+ }
+
+ internal fun parserRasterDemSource(id: String, json: JsonObject): RasterDemSource {
+ return RasterDemSource(id, "")
+ }
+
+ internal fun parserRasterSource(id: String, json: JsonObject): RasterSource {
+ return RasterSource(id, "")
+ }
+}
diff --git a/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/StyleJsonContants.kt b/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/StyleJsonContants.kt
new file mode 100644
index 000000000..bce3a1823
--- /dev/null
+++ b/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/StyleJsonContants.kt
@@ -0,0 +1,30 @@
+package com.mapbox.pluginstylejson
+
+object StyleJsonContants {
+ val LAYER_BACKGROUND = "background"
+ val LAYER_CYCLE = "cycle"
+ val LAYER_CUSTOM = "custom"
+ val LAYER_FILL_EXTRUSION = "fillextrusion"
+ val LAYER_FILL = "fill"
+ val LAYER_HEATMAP = "heatmap"
+ val LAYER_HILLSHADE = "hillshade"
+ val LAYER_LINE = "line"
+ val LAYER_RASTER = "raster"
+ val LAYER_SYMBOL = "symbol"
+ val SOURCE_CUSTOM_GEOMETRY = "custom geometry"
+ val SOURCE_GEO_JSON = "geojson"
+ val SOURCE_IMAGE = "image"
+ val SOURCE_RASTER_DEM = "rasterdem"
+ val SOURCE_RASTER = "raster"
+ val SOURCE_VECTOR = "vector"
+
+ const val GEO_JSON_FEATURE = "Feature"
+ const val GEO_JSON_FEATURE_COLLECTION = "FeatureCollection"
+ const val GEO_JSON_GEOMETRY_COLLECTION = "GeometryCollection"
+ const val GEO_JSON_LINE_STRING = "LineString"
+ const val GEO_JSON_NULTI_LINE_STRING = "MultiLineString"
+ const val GEO_JSON_MULTI_POINT = "MultiPoint"
+ const val GEO_JSON_MULTI_POLYGON = "MultiPolygon"
+ const val GEO_JSON_POINT = "Point"
+ const val GEO_JSON_POLYGON = "Polygon"
+}
diff --git a/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/StyleJsonPlugin.kt b/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/StyleJsonPlugin.kt
new file mode 100644
index 000000000..cb7cec68a
--- /dev/null
+++ b/plugin-stylejson/src/main/java/com/mapbox/pluginstylejson/StyleJsonPlugin.kt
@@ -0,0 +1,70 @@
+package com.mapbox.pluginstylejson
+
+import com.google.gson.Gson
+import com.google.gson.JsonObject
+import com.mapbox.mapboxsdk.style.layers.Layer
+import com.mapbox.mapboxsdk.style.sources.Source
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_BACKGROUND
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_CUSTOM
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_CYCLE
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_FILL
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_FILL_EXTRUSION
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_HEATMAP
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_HILLSHADE
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_LINE
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_RASTER
+import com.mapbox.pluginstylejson.StyleJsonContants.LAYER_SYMBOL
+import com.mapbox.pluginstylejson.StyleJsonContants.SOURCE_CUSTOM_GEOMETRY
+import com.mapbox.pluginstylejson.StyleJsonContants.SOURCE_GEO_JSON
+import com.mapbox.pluginstylejson.StyleJsonContants.SOURCE_IMAGE
+import com.mapbox.pluginstylejson.StyleJsonContants.SOURCE_RASTER
+import com.mapbox.pluginstylejson.StyleJsonContants.SOURCE_RASTER_DEM
+import com.mapbox.pluginstylejson.StyleJsonContants.SOURCE_VECTOR
+
+class StyleJsonPlugin {
+ private val gson = Gson()
+ private val layerJsonParser = LayerJsonParser()
+ private val sourceJsonParser = SourceJsonParser()
+
+ fun parserLayer(content: String): Layer? {
+ val source = gson.fromJson(content, JsonObject::class.java)
+ val id = source.get("id")
+ id?.let {
+ val type = source.get("type")
+ type?.let {
+ return when (type.asString) {
+ LAYER_BACKGROUND -> layerJsonParser.parserBackgroundLayer(id.asString, source)
+ LAYER_CYCLE -> layerJsonParser.parserCircleLayer(id.asString, source)
+ LAYER_CUSTOM -> layerJsonParser.parserCustomLayer(id.asString, source)
+ LAYER_FILL_EXTRUSION -> layerJsonParser.parserFillExtrusionLayer(id.asString, source)
+ LAYER_FILL -> layerJsonParser.parserFillLayer(id.asString, source)
+ LAYER_HEATMAP -> layerJsonParser.parserHeatmapLayer(id.asString, source)
+ LAYER_HILLSHADE -> layerJsonParser.parserHillshadeLayer(id.asString, source)
+ LAYER_LINE -> layerJsonParser.parserLineLayer(id.asString, source)
+ LAYER_RASTER -> layerJsonParser.parserRasterLayer(id.asString, source)
+ LAYER_SYMBOL -> layerJsonParser.parserSymbolLayer(id.asString, source)
+ else -> null
+ }
+ }
+ }
+ return null
+ }
+
+ fun parserSource(id: String, content: String): Source? {
+ val source = gson.fromJson(content, JsonObject::class.java)
+ val type = source.get("type")
+ type?.let {
+ return when (type.asString) {
+ SOURCE_CUSTOM_GEOMETRY -> sourceJsonParser.parserCustomGeometrySource(id, source)
+ SOURCE_GEO_JSON -> sourceJsonParser.parserGeoJsonSource(id, source)
+ SOURCE_IMAGE -> sourceJsonParser.parserImageSource(id, source)
+ SOURCE_RASTER_DEM -> sourceJsonParser.parserRasterDemSource(id, source)
+ SOURCE_RASTER -> sourceJsonParser.parserRasterSource(id, source)
+ SOURCE_VECTOR -> sourceJsonParser.parserVectorSource(id, source)
+ else -> null
+ }
+ }
+ return null
+ }
+
+}
\ No newline at end of file
diff --git a/plugin-stylejson/src/main/res/values/strings.xml b/plugin-stylejson/src/main/res/values/strings.xml
new file mode 100644
index 000000000..9c3595fee
--- /dev/null
+++ b/plugin-stylejson/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ pluginstylejson
+
diff --git a/plugin-stylejson/src/test/java/com/mapbox/pluginstylejson/ExampleUnitTest.java b/plugin-stylejson/src/test/java/com/mapbox/pluginstylejson/ExampleUnitTest.java
new file mode 100644
index 000000000..2ee114f4d
--- /dev/null
+++ b/plugin-stylejson/src/test/java/com/mapbox/pluginstylejson/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.mapbox.pluginstylejson;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 07e316702..873225790 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -7,4 +7,5 @@ include ':plugin-localization'
include ':plugin-annotation'
include ':plugin-markerview'
include ':ktx-mapbox-maps'
-include ':plugin-scalebar'
\ No newline at end of file
+include ':plugin-scalebar'
+include ':plugin-stylejson'
\ No newline at end of file