diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-09-08 16:13:39 +0300 |
---|---|---|
committer | Ivo van Dongen <info@ivovandongen.nl> | 2017-09-08 16:13:39 +0300 |
commit | be955ac38169ab745ad5c3ccf5cbbb25813c71f2 (patch) | |
tree | 03b3cea39b2694dc0d118c23ffc980200c4e2cd9 | |
parent | f8a53234ffa6ff3fd1d8fc8e3aa8b10b16c815fd (diff) | |
download | qtlocation-mapboxgl-be955ac38169ab745ad5c3ccf5cbbb25813c71f2.tar.gz |
[android] test app - fix highlight buildings exampleupstream/ivd-fix-highlight-buildings
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java index a909bb7151..480e48437a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java @@ -46,6 +46,15 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity @Override public void onMapReady(final MapboxMap mapboxMap) { QueryRenderedFeaturesBoxHighlightActivity.this.mapboxMap = mapboxMap; + + // Add layer / source + final GeoJsonSource source = new GeoJsonSource("highlighted-shapes-source"); + mapboxMap.addSource(source); + mapboxMap.addLayer( + new FillLayer("highlighted-shapes-layer", "highlighted-shapes-source") + .withProperties(fillColor(Color.RED)) + ); + selectionBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -62,17 +71,8 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity String.format("%s features in box", features.size()), Toast.LENGTH_SHORT).show(); - // remove layer / source if already added - mapboxMap.removeSource("highlighted-shapes-source"); - mapboxMap.removeLayer("highlighted-shapes-layer"); - - // Add layer / source - mapboxMap.addSource( - new GeoJsonSource("highlighted-shapes-source", - FeatureCollection.fromFeatures(features)) - ); - mapboxMap.addLayer(new FillLayer("highlighted-shapes-layer", "highlighted-shapes-source") - .withProperties(fillColor(Color.RED))); + // Update source data + source.setGeoJson(FeatureCollection.fromFeatures(features)); } }); } |