[android] Custom layer bindings

This commit is contained in:
John Firebaugh
2015-12-11 16:04:40 -08:00
parent e304033552
commit 8a17d30c50
12 changed files with 272 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -0,0 +1,4 @@
/**
* This package contains classes to add and manage layers in your map.
*/
package com.mapbox.mapboxsdk.layers;

View File

@@ -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;

View File

@@ -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);
}