diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2019-04-15 15:53:50 +0200 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2019-04-16 17:49:56 +0200 |
commit | 395f17f615b0b216e4cfd949d926451caceda489 (patch) | |
tree | 3b191f77b6e74089a9e3a99148346db49a849769 /platform | |
parent | 0adfddfbdadddf69bb78969c4c03e3b4cecb87f1 (diff) | |
download | qtlocation-mapboxgl-395f17f615b0b216e4cfd949d926451caceda489.tar.gz |
[android] - circle with radius expressed in physical measurement using turf.
Diffstat (limited to 'platform')
2 files changed, 15 insertions, 8 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/turf/PhysicalUnitCircleActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/turf/PhysicalUnitCircleActivity.kt index 00909be32d..e1a141433d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/turf/PhysicalUnitCircleActivity.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/turf/PhysicalUnitCircleActivity.kt @@ -8,9 +8,8 @@ import com.mapbox.geojson.Point import com.mapbox.mapboxsdk.camera.CameraPosition import com.mapbox.mapboxsdk.geometry.LatLng import com.mapbox.mapboxsdk.maps.Style -import com.mapbox.mapboxsdk.style.layers.BackgroundLayer +import com.mapbox.mapboxsdk.style.expressions.Expression.* import com.mapbox.mapboxsdk.style.layers.FillLayer -import com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor import com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor import com.mapbox.mapboxsdk.style.sources.GeoJsonSource import com.mapbox.mapboxsdk.testapp.R @@ -25,6 +24,9 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL companion object { const val LAYER_ID = "circle-id" const val SOURCE_ID = "circle-id" + const val LATITUDE = 22.928207 + const val LONGITUDE = 15.0155543 + const val ZOOM = 10.0 } private lateinit var source: GeoJsonSource @@ -38,12 +40,12 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL mapView.getMapAsync { mapboxMap -> mapboxMap.cameraPosition = CameraPosition.Builder() - .target(LatLng(22.928207, 15.011543)) - .zoom(10.0) + .target(LatLng(LATITUDE, LONGITUDE)) + .zoom(ZOOM) .build() source = GeoJsonSource(SOURCE_ID, TurfTransformation.circle( - Point.fromLngLat(0.0, 0.0), 9000.0, 10, "meters") + Point.fromLngLat(LONGITUDE, LATITUDE), 9000.0, 10, "meters") ) stepsBar.setOnSeekBarChangeListener(this) @@ -51,7 +53,12 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL mapboxMap.setStyle(Style.Builder() .fromUrl(Style.SATELLITE_STREETS) - .withLayer(FillLayer(LAYER_ID, SOURCE_ID).withProperties(fillColor(Color.RED))) + .withLayer(FillLayer(LAYER_ID, SOURCE_ID).withProperties(fillColor(interpolate( + exponential(0.5f), zoom(), + stop(8, color(Color.RED)), + stop(12, color(Color.BLUE)), + stop(16, color(Color.GREEN)) + )))) .withSource(source) ) } @@ -66,7 +73,7 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL } source.setGeoJson(TurfTransformation.circle( - Point.fromLngLat(0.0, 0.0), radius, steps, "meters") + Point.fromLngLat(LONGITUDE, LATITUDE), radius, steps, "meters") ) } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_physical_circle.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_physical_circle.xml index 83728b46a9..44132e91b1 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_physical_circle.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_physical_circle.xml @@ -24,7 +24,7 @@ android:id="@+id/radiusBar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="48dp" + android:layout_marginBottom="16dp" android:progress="9000" android:max="15000" android:layout_above="@id/stepsBar"/> |