diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index c8a0de982..92a8f0e48 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -405,6 +405,14 @@ android:name="@string/category" android:value="@string/category_features" /> + + + features = mapboxMap.queryRenderedFeatures(box, "symbols-layer"); + + //Show count + if (toast != null) { + toast.cancel(); + } + toast = Toast.makeText( + QueryRenderedFeaturesBoxSymbolCountActivity.this, + String.format("%s features in box", features.size()), + Toast.LENGTH_SHORT); + toast.show(); + + } + }); + + //Little taste of home + mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.0907, 5.1214), 16)); + } + }); + + } + + private String readRawResource(@RawRes int rawResource) throws IOException { + InputStream is = getResources().openRawResource(rawResource); + Writer writer = new StringWriter(); + char[] buffer = new char[1024]; + try { + Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); + int n; + while ((n = reader.read(buffer)) != -1) { + writer.write(buffer, 0, n); + } + } finally { + is.close(); + } + + return writer.toString(); + } + + public MapboxMap getMapboxMap() { + return mapboxMap; + } + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + private void setupActionBar() { + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + final ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + } + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/test_points_utrecht.geojson b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/test_points_utrecht.geojson new file mode 100644 index 000000000..d7b8ede72 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/test_points_utrecht.geojson @@ -0,0 +1,49 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [ + 5.12100, + 52.09082 + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [ + 5.12160, + 52.09082 + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [ + 5.12160, + 52.09056 + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [ + 5.12100, + 52.09056 + ] + } + } + ] +} \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index a4f19f1e0..a9f639d99 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -65,6 +65,7 @@ SurfaceView MediaOverlay Query feature properties Count features in box + Count symbols in box Highlight features in box Add Circle Add Custom Sprite @@ -120,6 +121,7 @@ Test overlaying SurfaceView Query rendered feature properties on click Count all rendered features in box + Count all rendered symbols in box Hightligh buildings in box MyLocationView follow map update example Android video view on top of the map view