diff options
5 files changed, 128 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index fc10a01356..9ede763533 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -459,6 +459,17 @@ android:value=".activity.FeatureOverviewActivity"/> </activity> <activity + android:name=".activity.style.BuildingFillExtrusionActivity" + android:description="@string/description_building_fill_extrusion_layer" + android:label="@string/activity_building_fill_extrusion_layer"> + <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.SymbolLayerActivity" android:description="@string/description_symbol_layer" android:label="@string/activity_symbol_layer"> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/BuildingFillExtrusionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/BuildingFillExtrusionActivity.java new file mode 100644 index 0000000000..f444aa40f0 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/BuildingFillExtrusionActivity.java @@ -0,0 +1,95 @@ +package com.mapbox.mapboxsdk.testapp.activity.style; + +import android.graphics.Color; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v7.app.AppCompatActivity; + +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; +import com.mapbox.mapboxsdk.style.functions.Function; +import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops; +import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer; +import com.mapbox.mapboxsdk.testapp.R; + +import static com.mapbox.mapboxsdk.style.layers.Filter.eq; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBase; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity; + +/** + * Test activity showing 3D buildings with a FillExtrusion Layer + */ +public class BuildingFillExtrusionActivity extends AppCompatActivity { + + private MapView mapView; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_building_layer); + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(@NonNull final MapboxMap map) { + FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite"); + fillExtrusionLayer.setSourceLayer("building"); + fillExtrusionLayer.setFilter(eq("extrude", "true")); + fillExtrusionLayer.setMinZoom(15); + fillExtrusionLayer.setProperties( + fillExtrusionColor(Color.LTGRAY), + fillExtrusionHeight(Function.property("height", new IdentityStops<Float>())), + fillExtrusionBase(Function.property("min_height", new IdentityStops<Float>())), + fillExtrusionOpacity(0.6f) + ); + map.addLayer(fillExtrusionLayer); + } + }); + } + + @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 + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_building_layer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_building_layer.xml new file mode 100644 index 0000000000..d9a10871b5 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_building_layer.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <com.mapbox.mapboxsdk.maps.MapView + android:id="@id/mapView" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:mapbox_cameraTargetLat="40.7135" + app:mapbox_cameraTargetLng="-74.0066" + app:mapbox_cameraTilt="45" + app:mapbox_cameraZoom="15" + app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/> + +</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index 6270eac72d..5b6cbb8c42 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -58,6 +58,7 @@ <string name="activity_url_transform">Url transform</string> <string name="activity_restricted_bounds">Restrict camera to a bounds</string> <string name="activity_fill_extrusion_layer">Fill extrusions</string> + <string name="activity_building_fill_extrusion_layer">Building layer</string> <!--Description--> <string name="description_user_location_tracking">Tracks the location of the user</string> @@ -115,6 +116,7 @@ <string name="description_url_transform">Transform urls on the fly</string> <string name="description_restricted_bounds">Limit viewport to Iceland</string> <string name="description_fill_extrusion_layer">Shows how to add 3D extruded shapes</string> + <string name="description_building_fill_extrusion_layer">Shows how to show 3D extruded buildings</string> <!--Categories--> <string name="category">category</string> diff --git a/platform/android/src/style/layers/layer.cpp b/platform/android/src/style/layers/layer.cpp index 1ebad19a87..d571c3fd2e 100644 --- a/platform/android/src/style/layers/layer.cpp +++ b/platform/android/src/style/layers/layer.cpp @@ -121,6 +121,8 @@ namespace android { layer.as<SymbolLayer>()->setFilter(filter); } else if (layer.is<CircleLayer>()) { layer.as<CircleLayer>()->setFilter(filter); + } else if (layer.is<FillExtrusionLayer>()){ + layer.as<FillExtrusionLayer>()->setFilter(filter); } else { mbgl::Log::Warning(mbgl::Event::JNI, "Layer doesn't support filters"); } |