diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2019-04-04 11:09:28 +0200 |
---|---|---|
committer | tobrun <tobrun.van.nuland@gmail.com> | 2019-04-04 11:09:28 +0200 |
commit | 2d91a8f17b39bfcf1f72b78602e59b3fe7581c4f (patch) | |
tree | 5d6bf113d609b1106b7db0e7485497239231c979 | |
parent | f3c3dc49e231208e75db64b53c5e92bb9647a661 (diff) | |
download | qtlocation-mapboxgl-upstream/tvn-min-rep-line.tar.gz |
[android] - minimal reproducible example, line pattern empty valueupstream/tvn-min-rep-line
4 files changed, 159 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 017fe3ddca..e9dfc61e9a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -462,6 +462,17 @@ android:value=".activity.FeatureOverviewActivity" /> </activity> <activity + android:name=".activity.style.LineActivity" + android:description="@string/description_line" + android:label="@string/activity_line"> + <meta-data + android:name="@string/category" + android:value="@string/category_style" /> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity" /> + </activity> + <activity android:name=".activity.style.DataDrivenStyleActivity" android:description="@string/description_data_driven_style" android:label="@string/activity_data_driven_style"> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/LineActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/LineActivity.kt new file mode 100644 index 0000000000..700c0bb188 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/LineActivity.kt @@ -0,0 +1,146 @@ +package com.mapbox.mapboxsdk.testapp.activity.style + +import android.graphics.Camera +import android.os.Bundle +import android.support.v7.app.AppCompatActivity +import com.mapbox.mapboxsdk.camera.CameraPosition +import com.mapbox.mapboxsdk.maps.MapView +import com.mapbox.mapboxsdk.maps.MapboxMap +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback +import com.mapbox.mapboxsdk.maps.Style +import com.mapbox.mapboxsdk.style.expressions.Expression.get +import com.mapbox.mapboxsdk.style.layers.LineLayer +import com.mapbox.mapboxsdk.style.layers.PropertyFactory.* +import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions +import com.mapbox.mapboxsdk.style.sources.GeoJsonSource +import com.mapbox.mapboxsdk.testapp.R +import timber.log.Timber +import java.io.IOException + +/** + * Activity showcasing applying a gradient coloring to a line layer. + */ +class LineActivity : AppCompatActivity(), OnMapReadyCallback { + private var mapView: MapView? = null + + public override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_gradient_line) + + mapView = findViewById(R.id.mapView) + mapView!!.onCreate(savedInstanceState) + mapView!!.getMapAsync(this) + } + + override fun onMapReady(mapboxMap: MapboxMap) { + try { + mapboxMap.cameraPosition = CameraPosition.DEFAULT + mapboxMap.setStyle(Style.Builder() + .fromUrl(Style.MAPBOX_STREETS) + .withSource(GeoJsonSource(LINE_SOURCE, GEOJSON, GeoJsonOptions())) + .withLayer(LineLayer("line", LINE_SOURCE) + .withProperties( + lineColor(get("line-color")), + lineWidth(get("line-width")), + linePattern(get("line-pattern")) + ) + ) + ) + } catch (exception: IOException) { + Timber.e(exception) + } + + } + + override fun onStart() { + super.onStart() + mapView!!.onStart() + } + + override fun onResume() { + super.onResume() + mapView!!.onResume() + } + + override fun onPause() { + super.onPause() + mapView!!.onPause() + } + + override fun onStop() { + super.onStop() + mapView!!.onStop() + } + + public override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + mapView!!.onSaveInstanceState(outState) + } + + override fun onLowMemory() { + super.onLowMemory() + mapView!!.onLowMemory() + } + + public override fun onDestroy() { + super.onDestroy() + mapView!!.onDestroy() + } + + companion object { + + val LINE_SOURCE = "gradient" + + val GEOJSON = + """ +{ + "type": "FeatureCollection", + "features": [{ + "type": "Feature", + "properties": { + "line-pattern": "airfield-11", + "line-color": "#ff0", + "line-width": 5.0 + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 0, + 90 + ], + [ + 0, + -90 + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "line-pattern": "", + "line-color": "#ff0", + "line-width": 5.0 + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 15, + 90 + ], + [ + 15, + -90 + ] + ] + } + } + ] +} + """ + + + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml index 778805b3b3..df249d8c73 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml @@ -31,6 +31,7 @@ <string name="description_viewpager">Use SupportMapFragments in a ViewPager</string> <string name="description_runtime_style">Adopt the map style on the fly</string> <string name="description_gradient_line">Show a gradient line layer from a geojson source</string> + <string name="description_line">Show a line layer from a geojson source</string> <string name="description_data_driven_style">Use functions to change the map appearance</string> <string name="description_symbol_layer">Manipulate symbols at runtime</string> <string name="description_custom_sprite">Use a custom sprite in a Symbol Layer</string> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml index 12c82bf21a..4b058245aa 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml @@ -32,6 +32,7 @@ <string name="activity_viewpager">ViewPager</string> <string name="activity_runtime_style">Runtime Style</string> <string name="activity_gradient_line">Gradient line layer</string> + <string name="activity_line">Line layer</string> <string name="activity_data_driven_style">Data Driven Style</string> <string name="activity_circle_layer">Circle layer</string> <string name="activity_style_file">Local Style file</string> |