diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java index 20174daeaa..70d5b53428 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java @@ -9,7 +9,6 @@ import android.widget.Toast; import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.services.commons.geojson.Feature; @@ -36,32 +35,25 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity { // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); - mapView.getMapAsync(new OnMapReadyCallback() { - @SuppressWarnings("ConstantConditions") - @Override - public void onMapReady(final MapboxMap mapboxMap) { - QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap; - selectionBox.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - // Query - int top = selectionBox.getTop() - mapView.getTop(); - int left = selectionBox.getLeft() - mapView.getLeft(); - RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight()); - Timber.i("Querying box %s", box); - List<Feature> features = mapboxMap.queryRenderedFeatures(box); - - // Show count - Toast.makeText( - QueryRenderedFeaturesBoxCountActivity.this, - String.format("%s features in box", features.size()), - Toast.LENGTH_SHORT).show(); - - // Debug output - debugOutput(features); - } - }); - } + mapView.getMapAsync(mapboxMap -> { + QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap; + selectionBox.setOnClickListener(view -> { + // Query + int top = selectionBox.getTop() - mapView.getTop(); + int left = selectionBox.getLeft() - mapView.getLeft(); + RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight()); + Timber.i("Querying box %s", box); + List<Feature> features = mapboxMap.queryRenderedFeatures(box); + + // Show count + Toast.makeText( + QueryRenderedFeaturesBoxCountActivity.this, + String.format("%s features in box", features.size()), + Toast.LENGTH_SHORT).show(); + + // Debug output + debugOutput(features); + }); }); } |