summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-12-11 16:04:40 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-12-16 11:03:32 -0800
commit8a17d30c50f46b5c702807a840bbfb6395eb456e (patch)
tree94952de29122f9694ca07c032073697dcd0e0fc9 /android
parente304033552fd423db5324545216f9cf3a1e62150 (diff)
downloadqtlocation-mapboxgl-8a17d30c50f46b5c702807a840bbfb6395eb456e.tar.gz
[android] Custom layer bindings
Diffstat (limited to 'android')
-rw-r--r--android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/CustomLayer.java21
-rw-r--r--android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/package-info.java4
-rw-r--r--android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java6
-rw-r--r--android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java7
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/ExampleCustomLayer.java12
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java15
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml6
-rw-r--r--android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml1
8 files changed, 72 insertions, 0 deletions
diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/CustomLayer.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/CustomLayer.java
new file mode 100644
index 0000000000..f6fb297dc6
--- /dev/null
+++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/CustomLayer.java
@@ -0,0 +1,21 @@
+package com.mapbox.mapboxsdk.layers;
+
+public class CustomLayer {
+ public CustomLayer(String id,
+ long context,
+ long initializeFunction,
+ long renderFunction,
+ long deinitializeFunction) {
+ this.mID = id;
+ this.mContext = context;
+ this.mInitializeFunction = initializeFunction;
+ this.mRenderFunction = renderFunction;
+ this.mDeinitializeFunction = deinitializeFunction;
+ }
+
+ public String mID;
+ public long mContext;
+ public long mInitializeFunction;
+ public long mRenderFunction;
+ public long mDeinitializeFunction;
+}
diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/package-info.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/package-info.java
new file mode 100644
index 0000000000..fda1a493e2
--- /dev/null
+++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/layers/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * This package contains classes to add and manage layers in your map.
+ */
+package com.mapbox.mapboxsdk.layers;
diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
index 94cfe23f86..157f1ae955 100644
--- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
+++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
@@ -74,6 +74,7 @@ import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.CoordinateBounds;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngZoom;
+import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import java.lang.annotation.Retention;
@@ -3782,6 +3783,11 @@ public final class MapView extends FrameLayout {
mAttributionsView.setVisibility(visibility);
}
+ @UiThread
+ public void addCustomLayer(CustomLayer customLayer, String before) {
+ mNativeMapView.addCustomLayer(customLayer, before);
+ }
+
private void setWidgetGravity(@NonNull final View view, int gravity) {
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
layoutParams.gravity = gravity;
diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java
index f09d0e9027..c142670775 100644
--- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java
+++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java
@@ -11,6 +11,7 @@ import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngZoom;
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
+import com.mapbox.mapboxsdk.layers.CustomLayer;
import java.lang.ref.WeakReference;
import java.util.List;
@@ -449,6 +450,10 @@ final class NativeMapView {
return nativeGetTopOffsetPixelsForAnnotationSymbol(mNativeMapViewPtr, symbolName);
}
+ public void addCustomLayer(CustomLayer customLayer, String before) {
+ nativeAddCustomLayer(mNativeMapViewPtr, customLayer, before);
+ }
+
//
// Callbacks
//
@@ -629,4 +634,6 @@ final class NativeMapView {
private native LatLng nativeLatLngForPixel(long nativeMapViewPtr, PointF pixel);
private native double nativeGetTopOffsetPixelsForAnnotationSymbol(long nativeMapViewPtr, String symbolName);
+
+ private native void nativeAddCustomLayer(long nativeMapViewPtr, CustomLayer customLayer, String before);
}
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/ExampleCustomLayer.java b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/ExampleCustomLayer.java
new file mode 100644
index 0000000000..e6c7992145
--- /dev/null
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/ExampleCustomLayer.java
@@ -0,0 +1,12 @@
+package com.mapbox.mapboxsdk.testapp;
+
+public class ExampleCustomLayer {
+ static {
+ System.loadLibrary("example-custom-layer");
+ }
+
+ public native static long createContext();
+ public static long InitializeFunction;
+ public static long RenderFunction;
+ public static long DeinitializeFunction;
+}
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
index c303d94cdc..c6ec8cbd77 100644
--- a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
@@ -34,6 +34,7 @@ import com.mapbox.mapboxsdk.constants.MyBearingTracking;
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
@@ -395,6 +396,10 @@ public class MainActivity extends AppCompatActivity {
startActivity(new Intent(getApplicationContext(), PolylineActivity.class));
return true;
+ case R.id.action_custom_layer:
+ addCustomLayer();
+ return true;
+
default:
return changeMapStyle(menuItem.getItemId());
}
@@ -570,6 +575,16 @@ public class MainActivity extends AppCompatActivity {
mMapView.removeAllAnnotations();
}
+ private void addCustomLayer() {
+ mMapView.addCustomLayer(
+ new CustomLayer("custom",
+ ExampleCustomLayer.createContext(),
+ ExampleCustomLayer.InitializeFunction,
+ ExampleCustomLayer.RenderFunction,
+ ExampleCustomLayer.DeinitializeFunction),
+ null);
+ }
+
// Called when FPS changes
private class MyOnFpsChangedListener implements MapView.OnFpsChangedListener {
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml b/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
index bfd70a936f..9a81182837 100644
--- a/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
@@ -138,6 +138,12 @@
android:icon="@drawable/ic_trending_up_24dp"
android:title="@string/activity_polyline" />
+ <item
+ android:id="@+id/action_custom_layer"
+ android:checkable="false"
+ android:icon="@drawable/ic_trending_up_24dp"
+ android:title="@string/activity_custom_layer" />
+
</menu>
</item>
diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
index 8cc299e39f..10d622d38f 100644
--- a/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
+++ b/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
@@ -16,6 +16,7 @@
<string name="activity_user_tracking_mode">User tracking mode</string>
<string name="activity_polyline">Polyline Activity</string>
<string name="activity_animate_coordinate_change">Animate Coordinate Change</string>
+ <string name="activity_custom_layer">Custom Layer</string>
<string name="navdrawer_menu_title_mainactivity_controls">Main Activity Controls</string>
<string name="navdrawer_menu_title_mainactivity_styles">Main Activity Styles</string>