summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java')
-rwxr-xr-xplatform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java1181
1 files changed, 627 insertions, 554 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index 4e0ce33c5b..95c0ae5327 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -9,14 +9,12 @@ import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.view.Surface;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.Polygon;
import com.mapbox.mapboxsdk.annotations.Polyline;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
import com.mapbox.mapboxsdk.offline.OfflineManager;
@@ -30,741 +28,816 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import timber.log.Timber;
// Class that wraps the native methods for convenience
final class NativeMapView {
- //
- // Static members
- //
+ // Flag to indicating destroy was called
+ private boolean destroyed = false;
- //
- // Instance members
- //
+ // Holds the pointer to JNI NativeMapView
+ private long nativeMapViewPtr = 0;
- boolean destroyed = false;
+ // Used for callbacks
+ private MapView mapView;
- // Holds the pointer to JNI NativeMapView
- private long nativeMapViewPtr = 0;
+ // Device density
+ private final float pixelRatio;
- // Used for callbacks
- private MapView mapView;
+ // Listeners for Map change events
+ private CopyOnWriteArrayList<MapView.OnMapChangedListener> onMapChangedListeners;
- private final float pixelRatio;
+ //
+ // Static methods
+ //
- //
- // Static methods
- //
+ static {
+ System.loadLibrary("mapbox-gl");
+ }
- static {
- System.loadLibrary("mapbox-gl");
- }
+ //
+ // Constructors
+ //
- //
- // Constructors
- //
-
- public NativeMapView(MapView mapView) {
- Context context = mapView.getContext();
- String dataPath = OfflineManager.getDatabasePath(context);
-
- // With the availability of offline, we're unifying the ambient (cache) and the offline
- // databases to be in the same folder, outside cache, to avoid automatic deletion from
- // the system
- String cachePath = dataPath;
-
- pixelRatio = context.getResources().getDisplayMetrics().density;
- String apkPath = context.getPackageCodePath();
- int availableProcessors = Runtime.getRuntime().availableProcessors();
- ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
- ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
- activityManager.getMemoryInfo(memoryInfo);
- long totalMemory = memoryInfo.availMem;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- totalMemory = memoryInfo.totalMem;
- }
-
- if (availableProcessors < 0) {
- throw new IllegalArgumentException("availableProcessors cannot be negative.");
- }
-
- if (totalMemory < 0) {
- throw new IllegalArgumentException("totalMemory cannot be negative.");
- }
-
- this.mapView = mapView;
- nativeMapViewPtr = nativeCreate(cachePath, dataPath, apkPath, pixelRatio, availableProcessors, totalMemory);
- }
+ public NativeMapView(MapView mapView) {
+ Context context = mapView.getContext();
+ String dataPath = OfflineManager.getDatabasePath(context);
- //
- // Methods
- //
+ // With the availability of offline, we're unifying the ambient (cache) and the offline
+ // databases to be in the same folder, outside cache, to avoid automatic deletion from
+ // the system
+ String cachePath = dataPath;
- public void destroy() {
- nativeDestroy(nativeMapViewPtr);
- nativeMapViewPtr = 0;
- mapView = null;
- destroyed = true;
+ pixelRatio = context.getResources().getDisplayMetrics().density;
+ String apkPath = context.getPackageCodePath();
+ int availableProcessors = Runtime.getRuntime().availableProcessors();
+ ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
+ ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ activityManager.getMemoryInfo(memoryInfo);
+ long totalMemory = memoryInfo.availMem;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ totalMemory = memoryInfo.totalMem;
}
- public boolean wasDestroyed() {
- return destroyed;
+ if (availableProcessors < 0) {
+ throw new IllegalArgumentException("availableProcessors cannot be negative.");
}
- public void initializeDisplay() {
- nativeInitializeDisplay(nativeMapViewPtr);
+ if (totalMemory < 0) {
+ throw new IllegalArgumentException("totalMemory cannot be negative.");
}
+ onMapChangedListeners = new CopyOnWriteArrayList<>();
+ this.mapView = mapView;
+ nativeMapViewPtr = nativeCreate(cachePath, dataPath, apkPath, pixelRatio, availableProcessors, totalMemory);
+ }
- public void terminateDisplay() {
- nativeTerminateDisplay(nativeMapViewPtr);
- }
+ //
+ // Methods
+ //
- public void initializeContext() {
- nativeInitializeContext(nativeMapViewPtr);
- }
+ public void destroy() {
+ nativeDestroy(nativeMapViewPtr);
+ nativeMapViewPtr = 0;
+ mapView = null;
+ destroyed = true;
+ }
- public void terminateContext() {
- nativeTerminateContext(nativeMapViewPtr);
- }
+ public boolean wasDestroyed() {
+ return destroyed;
+ }
- public void createSurface(Surface surface) {
- nativeCreateSurface(nativeMapViewPtr, surface);
- }
+ public void initializeDisplay() {
+ nativeInitializeDisplay(nativeMapViewPtr);
+ }
- public void destroySurface() {
- nativeDestroySurface(nativeMapViewPtr);
- }
+ public void terminateDisplay() {
+ nativeTerminateDisplay(nativeMapViewPtr);
+ }
- public void update() {
- nativeUpdate(nativeMapViewPtr);
- }
+ public void initializeContext() {
+ nativeInitializeContext(nativeMapViewPtr);
+ }
- public void render() {
- nativeRender(nativeMapViewPtr);
- }
+ public void terminateContext() {
+ nativeTerminateContext(nativeMapViewPtr);
+ }
- public void resizeView(int width, int height) {
- if (width < 0) {
- throw new IllegalArgumentException("width cannot be negative.");
- }
-
- if (height < 0) {
- throw new IllegalArgumentException("height cannot be negative.");
- }
-
- if (width > 65535) {
- // we have seen edge cases where devices return incorrect values #6111
- Log.e(MapboxConstants.TAG, "Device returned an out of range width size, " +
- "capping value at 65535 instead of " + width);
- width = 65535;
- }
-
- if (height > 65535) {
- // we have seen edge cases where devices return incorrect values #6111
- Log.e(MapboxConstants.TAG, "Device returned an out of range height size, " +
- "capping value at 65535 instead of " + height);
- height = 65535;
- }
- nativeViewResize(nativeMapViewPtr, width, height);
- }
+ public void createSurface(Surface surface) {
+ nativeCreateSurface(nativeMapViewPtr, surface);
+ }
- public void resizeFramebuffer(int fbWidth, int fbHeight) {
- if (fbWidth < 0) {
- throw new IllegalArgumentException("fbWidth cannot be negative.");
- }
-
- if (fbHeight < 0) {
- throw new IllegalArgumentException("fbHeight cannot be negative.");
- }
-
- if (fbWidth > 65535) {
- throw new IllegalArgumentException(
- "fbWidth cannot be greater than 65535.");
- }
-
- if (fbHeight > 65535) {
- throw new IllegalArgumentException(
- "fbHeight cannot be greater than 65535.");
- }
- nativeFramebufferResize(nativeMapViewPtr, fbWidth, fbHeight);
- }
+ public void destroySurface() {
+ nativeDestroySurface(nativeMapViewPtr);
+ }
- public void addClass(String clazz) {
- nativeAddClass(nativeMapViewPtr, clazz);
- }
+ public void update() {
+ nativeUpdate(nativeMapViewPtr);
+ }
- public void removeClass(String clazz) {
- nativeRemoveClass(nativeMapViewPtr, clazz);
- }
+ public void render() {
+ nativeRender(nativeMapViewPtr);
+ }
- public boolean hasClass(String clazz) {
- return nativeHasClass(nativeMapViewPtr, clazz);
- }
+ public void resizeView(int width, int height) {
+ width = (int) (width / pixelRatio);
+ height = (int) (height / pixelRatio);
- public void setClasses(List<String> classes) {
- nativeSetClasses(nativeMapViewPtr, classes);
+ if (width < 0) {
+ throw new IllegalArgumentException("width cannot be negative.");
}
- public List<String> getClasses() {
- return nativeGetClasses(nativeMapViewPtr);
+ if (height < 0) {
+ throw new IllegalArgumentException("height cannot be negative.");
}
- public void setStyleUrl(String url) {
- nativeSetStyleUrl(nativeMapViewPtr, url);
+ if (width > 65535) {
+ // we have seen edge cases where devices return incorrect values #6111
+ Timber.e("Device returned an out of range width size, "
+ + "capping value at 65535 instead of " + width);
+ width = 65535;
}
- public void setStyleJson(String newStyleJson) {
- nativeSetStyleJson(nativeMapViewPtr, newStyleJson);
+ if (height > 65535) {
+ // we have seen edge cases where devices return incorrect values #6111
+ Timber.e("Device returned an out of range height size, "
+ + "capping value at 65535 instead of " + height);
+ height = 65535;
}
+ nativeViewResize(nativeMapViewPtr, width, height);
+ }
- public String getStyleJson() {
- return nativeGetStyleJson(nativeMapViewPtr);
+ public void resizeFramebuffer(int fbWidth, int fbHeight) {
+ if (fbWidth < 0) {
+ throw new IllegalArgumentException("fbWidth cannot be negative.");
}
- public void setAccessToken(String accessToken) {
- nativeSetAccessToken(nativeMapViewPtr, accessToken);
+ if (fbHeight < 0) {
+ throw new IllegalArgumentException("fbHeight cannot be negative.");
}
- public String getAccessToken() {
- return nativeGetAccessToken(nativeMapViewPtr);
+ if (fbWidth > 65535) {
+ throw new IllegalArgumentException(
+ "fbWidth cannot be greater than 65535.");
}
- public void cancelTransitions() {
- nativeCancelTransitions(nativeMapViewPtr);
+ if (fbHeight > 65535) {
+ throw new IllegalArgumentException(
+ "fbHeight cannot be greater than 65535.");
}
+ nativeFramebufferResize(nativeMapViewPtr, fbWidth, fbHeight);
+ }
- public void setGestureInProgress(boolean inProgress) {
- nativeSetGestureInProgress(nativeMapViewPtr, inProgress);
- }
+ public void addClass(String clazz) {
+ nativeAddClass(nativeMapViewPtr, clazz);
+ }
- public void moveBy(double dx, double dy) {
- moveBy(dx, dy, 0);
- }
+ public void removeClass(String clazz) {
+ nativeRemoveClass(nativeMapViewPtr, clazz);
+ }
- public void moveBy(double dx, double dy, long duration) {
- nativeMoveBy(nativeMapViewPtr, dx, dy, duration);
- }
+ public boolean hasClass(String clazz) {
+ return nativeHasClass(nativeMapViewPtr, clazz);
+ }
- public void setLatLng(LatLng latLng) {
- setLatLng(latLng, 0);
- }
+ public void setClasses(List<String> classes) {
+ nativeSetClasses(nativeMapViewPtr, classes);
+ }
- public void setLatLng(LatLng latLng, long duration) {
- nativeSetLatLng(nativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude(), duration);
- }
+ public List<String> getClasses() {
+ return nativeGetClasses(nativeMapViewPtr);
+ }
- public LatLng getLatLng() {
- return nativeGetLatLng(nativeMapViewPtr);
- }
+ public void setStyleUrl(String url) {
+ nativeSetStyleUrl(nativeMapViewPtr, url);
+ }
- public void resetPosition() {
- nativeResetPosition(nativeMapViewPtr);
- }
+ public String getStyleUrl() {
+ return nativeGetStyleUrl(nativeMapViewPtr);
+ }
- public double getPitch() {
- return nativeGetPitch(nativeMapViewPtr);
- }
+ public void setStyleJson(String newStyleJson) {
+ nativeSetStyleJson(nativeMapViewPtr, newStyleJson);
+ }
- public void setPitch(double pitch, long duration) {
- nativeSetPitch(nativeMapViewPtr, pitch, duration);
- }
+ public String getStyleJson() {
+ return nativeGetStyleJson(nativeMapViewPtr);
+ }
- public void scaleBy(double ds) {
- scaleBy(ds, Double.NaN, Double.NaN);
- }
+ public void setAccessToken(String accessToken) {
+ nativeSetAccessToken(nativeMapViewPtr, accessToken);
+ }
- public void scaleBy(double ds, double cx, double cy) {
- scaleBy(ds, cx, cy, 0);
- }
+ public String getAccessToken() {
+ return nativeGetAccessToken(nativeMapViewPtr);
+ }
- public void scaleBy(double ds, double cx, double cy, long duration) {
- nativeScaleBy(nativeMapViewPtr, ds, cx, cy, duration);
- }
+ public void cancelTransitions() {
+ nativeCancelTransitions(nativeMapViewPtr);
+ }
- public void setScale(double scale) {
- setScale(scale, Double.NaN, Double.NaN);
- }
+ public void setGestureInProgress(boolean inProgress) {
+ nativeSetGestureInProgress(nativeMapViewPtr, inProgress);
+ }
- public void setScale(double scale, double cx, double cy) {
- setScale(scale, cx, cy, 0);
- }
+ public void moveBy(double dx, double dy) {
+ moveBy(dx, dy, 0);
+ }
- public void setScale(double scale, double cx, double cy, long duration) {
- nativeSetScale(nativeMapViewPtr, scale, cx, cy, duration);
- }
+ public void moveBy(double dx, double dy, long duration) {
+ nativeMoveBy(nativeMapViewPtr, dx / pixelRatio, dy / pixelRatio, duration);
+ }
- public double getScale() {
- return nativeGetScale(nativeMapViewPtr);
- }
+ public void setLatLng(LatLng latLng) {
+ setLatLng(latLng, 0);
+ }
- public void setZoom(double zoom) {
- setZoom(zoom, 0);
- }
+ public void setLatLng(LatLng latLng, long duration) {
+ nativeSetLatLng(nativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude(), duration);
+ }
- public void setZoom(double zoom, long duration) {
- nativeSetZoom(nativeMapViewPtr, zoom, duration);
- }
+ public LatLng getLatLng() {
+ return nativeGetLatLng(nativeMapViewPtr);
+ }
- public double getZoom() {
- return nativeGetZoom(nativeMapViewPtr);
- }
+ public void resetPosition() {
+ nativeResetPosition(nativeMapViewPtr);
+ }
- public void resetZoom() {
- nativeResetZoom(nativeMapViewPtr);
- }
+ public double getPitch() {
+ return nativeGetPitch(nativeMapViewPtr);
+ }
- public void setMinZoom(double zoom) {
- nativeSetMinZoom(nativeMapViewPtr, zoom);
- }
+ public void setPitch(double pitch, long duration) {
+ nativeSetPitch(nativeMapViewPtr, pitch, duration);
+ }
- public double getMinZoom() {
- return nativeGetMinZoom(nativeMapViewPtr);
- }
+ public void scaleBy(double ds) {
+ scaleBy(ds, Double.NaN, Double.NaN);
+ }
- public void setMaxZoom(double zoom) {
- nativeSetMaxZoom(nativeMapViewPtr, zoom);
- }
+ public void scaleBy(double ds, double cx, double cy) {
+ scaleBy(ds, cx, cy, 0);
+ }
- public double getMaxZoom() {
- return nativeGetMaxZoom(nativeMapViewPtr);
- }
+ public void scaleBy(double ds, double cx, double cy, long duration) {
+ nativeScaleBy(nativeMapViewPtr, ds, cx / pixelRatio, cy / pixelRatio, duration);
+ }
+
+ public void setScale(double scale) {
+ setScale(scale, Double.NaN, Double.NaN);
+ }
+
+ public void setScale(double scale, double cx, double cy) {
+ setScale(scale, cx, cy, 0);
+ }
+
+ public void setScale(double scale, double cx, double cy, long duration) {
+ nativeSetScale(nativeMapViewPtr, scale, cx / pixelRatio, cy / pixelRatio, duration);
+ }
+
+ public double getScale() {
+ return nativeGetScale(nativeMapViewPtr);
+ }
+
+ public void setZoom(double zoom) {
+ setZoom(zoom, 0);
+ }
+
+ public void setZoom(double zoom, long duration) {
+ nativeSetZoom(nativeMapViewPtr, zoom, duration);
+ }
+
+ public double getZoom() {
+ return nativeGetZoom(nativeMapViewPtr);
+ }
+
+ public void resetZoom() {
+ nativeResetZoom(nativeMapViewPtr);
+ }
+
+ public void setMinZoom(double zoom) {
+ nativeSetMinZoom(nativeMapViewPtr, zoom);
+ }
+
+ public double getMinZoom() {
+ return nativeGetMinZoom(nativeMapViewPtr);
+ }
+
+ public void setMaxZoom(double zoom) {
+ nativeSetMaxZoom(nativeMapViewPtr, zoom);
+ }
+
+ public double getMaxZoom() {
+ return nativeGetMaxZoom(nativeMapViewPtr);
+ }
+
+ public void rotateBy(double sx, double sy, double ex, double ey) {
+ rotateBy(sx, sy, ex, ey, 0);
+ }
+
+ public void rotateBy(double sx, double sy, double ex, double ey,
+ long duration) {
+ nativeRotateBy(nativeMapViewPtr, sx / pixelRatio, sy / pixelRatio, ex, ey, duration);
+ }
+
+ public void setContentPadding(int[] padding) {
+ nativeSetContentPadding(nativeMapViewPtr,
+ padding[1] / pixelRatio,
+ padding[0] / pixelRatio,
+ padding[3] / pixelRatio,
+ padding[2] / pixelRatio);
+ }
+
+ public void setBearing(double degrees) {
+ setBearing(degrees, 0);
+ }
+
+ public void setBearing(double degrees, long duration) {
+ nativeSetBearing(nativeMapViewPtr, degrees, duration);
+ }
+
+ public void setBearing(double degrees, double cx, double cy) {
+ nativeSetBearingXY(nativeMapViewPtr, degrees, cx / pixelRatio, cy / pixelRatio);
+ }
+
+ public double getBearing() {
+ return nativeGetBearing(nativeMapViewPtr);
+ }
+
+ public void resetNorth() {
+ nativeResetNorth(nativeMapViewPtr);
+ }
+
+ public long addMarker(Marker marker) {
+ Marker[] markers = {marker};
+ return nativeAddMarkers(nativeMapViewPtr, markers)[0];
+ }
+
+ public long[] addMarkers(List<Marker> markers) {
+ return nativeAddMarkers(nativeMapViewPtr, markers.toArray(new Marker[markers.size()]));
+ }
+
+ public long addPolyline(Polyline polyline) {
+ Polyline[] polylines = {polyline};
+ return nativeAddPolylines(nativeMapViewPtr, polylines)[0];
+ }
+
+ public long[] addPolylines(List<Polyline> polylines) {
+ return nativeAddPolylines(nativeMapViewPtr, polylines.toArray(new Polyline[polylines.size()]));
+ }
+
+ public long addPolygon(Polygon polygon) {
+ Polygon[] polygons = {polygon};
+ return nativeAddPolygons(nativeMapViewPtr, polygons)[0];
+ }
+
+ public long[] addPolygons(List<Polygon> polygons) {
+ return nativeAddPolygons(nativeMapViewPtr, polygons.toArray(new Polygon[polygons.size()]));
+ }
+
+ public void updateMarker(Marker marker) {
+ LatLng position = marker.getPosition();
+ Icon icon = marker.getIcon();
+ nativeUpdateMarker(nativeMapViewPtr, marker.getId(), position.getLatitude(), position.getLongitude(), icon.getId());
+ }
+
+ public void updatePolygon(Polygon polygon) {
+ nativeUpdatePolygon(nativeMapViewPtr, polygon.getId(), polygon);
+ }
+
+ public void updatePolyline(Polyline polyline) {
+ nativeUpdatePolyline(nativeMapViewPtr, polyline.getId(), polyline);
+ }
+
+ public void removeAnnotation(long id) {
+ long[] ids = {id};
+ removeAnnotations(ids);
+ }
+
+ public void removeAnnotations(long[] ids) {
+ nativeRemoveAnnotations(nativeMapViewPtr, ids);
+ }
+
+ public long[] queryPointAnnotations(RectF rect) {
+ return nativeQueryPointAnnotations(nativeMapViewPtr, rect);
+ }
+
+ public void addAnnotationIcon(String symbol, int width, int height, float scale, byte[] pixels) {
+ nativeAddAnnotationIcon(nativeMapViewPtr, symbol, width, height, scale, pixels);
+ }
+
+ public void setVisibleCoordinateBounds(LatLng[] coordinates, RectF padding, double direction, long duration) {
+ nativeSetVisibleCoordinateBounds(nativeMapViewPtr, coordinates, padding, direction, duration);
+ }
+
+ public void onLowMemory() {
+ nativeOnLowMemory(nativeMapViewPtr);
+ }
+
+ public void setDebug(boolean debug) {
+ nativeSetDebug(nativeMapViewPtr, debug);
+ }
+
+ public void cycleDebugOptions() {
+ nativeToggleDebug(nativeMapViewPtr);
+ }
+
+ public boolean getDebug() {
+ return nativeGetDebug(nativeMapViewPtr);
+ }
+
+ public boolean isFullyLoaded() {
+ return nativeIsFullyLoaded(nativeMapViewPtr);
+ }
+
+ public void setReachability(boolean status) {
+ nativeSetReachability(nativeMapViewPtr, status);
+ }
+
+ public double getMetersPerPixelAtLatitude(double lat) {
+ return nativeGetMetersPerPixelAtLatitude(nativeMapViewPtr, lat, getZoom());
+ }
+
+ public ProjectedMeters projectedMetersForLatLng(LatLng latLng) {
+ return nativeProjectedMetersForLatLng(nativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude());
+ }
+
+ public LatLng latLngForProjectedMeters(ProjectedMeters projectedMeters) {
+ return nativeLatLngForProjectedMeters(nativeMapViewPtr, projectedMeters.getNorthing(),
+ projectedMeters.getEasting());
+ }
+
+ public PointF pixelForLatLng(LatLng latLng) {
+ PointF pointF = nativePixelForLatLng(nativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude());
+ pointF.set(pointF.x * pixelRatio, pointF.y * pixelRatio);
+ return pointF;
+ }
+
+ public LatLng latLngForPixel(PointF pixel) {
+ return nativeLatLngForPixel(nativeMapViewPtr, pixel.x / pixelRatio, pixel.y / pixelRatio);
+ }
+
+ public double getTopOffsetPixelsForAnnotationSymbol(String symbolName) {
+ return nativeGetTopOffsetPixelsForAnnotationSymbol(nativeMapViewPtr, symbolName);
+ }
+
+ public void jumpTo(double angle, LatLng center, double pitch, double zoom) {
+ nativeJumpTo(nativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), pitch, zoom);
+ }
+
+ public void easeTo(double angle, LatLng center, long duration, double pitch, double zoom,
+ boolean easingInterpolator) {
+ nativeEaseTo(nativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom,
+ easingInterpolator);
+ }
+
+ public void flyTo(double angle, LatLng center, long duration, double pitch, double zoom) {
+ nativeFlyTo(nativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom);
+ }
+
+ public double[] getCameraValues() {
+ return nativeGetCameraValues(nativeMapViewPtr);
+ }
+
+ // Runtime style Api
+
+ public Layer getLayer(String layerId) {
+ return nativeGetLayer(nativeMapViewPtr, layerId);
+ }
+
+ public void addLayer(@NonNull Layer layer, @Nullable String before) {
+ nativeAddLayer(nativeMapViewPtr, layer.getNativePtr(), before);
+ }
+
+ public void removeLayer(@NonNull String layerId) throws NoSuchLayerException {
+ nativeRemoveLayerById(nativeMapViewPtr, layerId);
+ }
+
+ public void removeLayer(@NonNull Layer layer) throws NoSuchLayerException {
+ nativeRemoveLayer(nativeMapViewPtr, layer.getNativePtr());
+ }
+
+ public Source getSource(@NonNull String sourceId) {
+ return nativeGetSource(nativeMapViewPtr, sourceId);
+ }
+
+ public void addSource(@NonNull Source source) {
+ nativeAddSource(nativeMapViewPtr, source.getNativePtr());
+ }
- public void rotateBy(double sx, double sy, double ex, double ey) {
- rotateBy(sx, sy, ex, ey, 0);
- }
+ public void removeSource(@NonNull String sourceId) throws NoSuchSourceException {
+ nativeRemoveSourceById(nativeMapViewPtr, sourceId);
+ }
- public void rotateBy(double sx, double sy, double ex, double ey,
- long duration) {
- nativeRotateBy(nativeMapViewPtr, sx, sy, ex, ey, duration);
- }
+ public void removeSource(@NonNull Source source) throws NoSuchSourceException {
+ nativeRemoveSource(nativeMapViewPtr, source.getNativePtr());
+ }
- public void setContentPadding(double top, double left, double bottom, double right) {
- nativeSetContentPadding(nativeMapViewPtr, top, left, bottom, right);
+ public void addImage(@NonNull String name, @NonNull Bitmap image) {
+ //Check/correct config
+ if (image.getConfig() != Bitmap.Config.ARGB_8888) {
+ image = image.copy(Bitmap.Config.ARGB_8888, false);
}
- public void setBearing(double degrees) {
- setBearing(degrees, 0);
- }
+ //Get pixels
+ ByteBuffer buffer = ByteBuffer.allocate(image.getByteCount());
+ image.copyPixelsToBuffer(buffer);
- public void setBearing(double degrees, long duration) {
- nativeSetBearing(nativeMapViewPtr, degrees, duration);
- }
+ //Determine pixel ratio
+ float density = image.getDensity() == Bitmap.DENSITY_NONE ? Bitmap.DENSITY_NONE : image.getDensity();
+ float pixelRatio = density / DisplayMetrics.DENSITY_DEFAULT;
- public void setBearing(double degrees, double cx, double cy) {
- nativeSetBearingXY(nativeMapViewPtr, degrees, cx, cy);
- }
+ nativeAddImage(nativeMapViewPtr, name, image.getWidth(), image.getHeight(), pixelRatio, buffer.array());
+ }
- public double getBearing() {
- return nativeGetBearing(nativeMapViewPtr);
- }
+ public void removeImage(String name) {
+ nativeRemoveImage(nativeMapViewPtr, name);
+ }
- public void resetNorth() {
- nativeResetNorth(nativeMapViewPtr);
- }
+ // Feature querying
- public long addMarker(Marker marker) {
- Marker[] markers = {marker};
- return nativeAddMarkers(nativeMapViewPtr, markers)[0];
- }
+ @NonNull
+ public List<Feature> queryRenderedFeatures(PointF coordinates, String... layerIds) {
+ Feature[] features = nativeQueryRenderedFeaturesForPoint(nativeMapViewPtr, coordinates.x / pixelRatio,
+ coordinates.y / pixelRatio, layerIds);
+ return features != null ? Arrays.asList(features) : new ArrayList<Feature>();
+ }
- public long[] addMarkers(List<Marker> markers) {
- return nativeAddMarkers(nativeMapViewPtr, markers.toArray(new Marker[markers.size()]));
- }
+ @NonNull
+ public List<Feature> queryRenderedFeatures(RectF coordinates, String... layerIds) {
+ Feature[] features = nativeQueryRenderedFeaturesForBox(
+ nativeMapViewPtr,
+ coordinates.left / pixelRatio,
+ coordinates.top / pixelRatio,
+ coordinates.right / pixelRatio,
+ coordinates.bottom / pixelRatio,
+ layerIds);
+ return features != null ? Arrays.asList(features) : new ArrayList<Feature>();
+ }
- public long addPolyline(Polyline polyline) {
- Polyline[] polylines = {polyline};
- return nativeAddPolylines(nativeMapViewPtr, polylines)[0];
- }
+ public void scheduleTakeSnapshot() {
+ nativeScheduleTakeSnapshot(nativeMapViewPtr);
+ }
- public long[] addPolylines(List<Polyline> polylines) {
- return nativeAddPolylines(nativeMapViewPtr, polylines.toArray(new Polyline[polylines.size()]));
- }
+ public void setApiBaseUrl(String baseUrl) {
+ nativeSetAPIBaseURL(nativeMapViewPtr, baseUrl);
+ }
- public long addPolygon(Polygon polygon) {
- Polygon[] polygons = {polygon};
- return nativeAddPolygons(nativeMapViewPtr, polygons)[0];
- }
+ public float getPixelRatio() {
+ return pixelRatio;
+ }
- public long[] addPolygons(List<Polygon> polygons) {
- return nativeAddPolygons(nativeMapViewPtr, polygons.toArray(new Polygon[polygons.size()]));
- }
+ public Context getContext() {
+ return mapView.getContext();
+ }
- public void updateMarker(Marker marker) {
- LatLng position = marker.getPosition();
- Icon icon = marker.getIcon();
- nativeUpdateMarker(nativeMapViewPtr, marker.getId(), position.getLatitude(), position.getLongitude(), icon.getId());
- }
+ //
+ // Callbacks
+ //
- public void updatePolygon(Polygon polygon) {
- nativeUpdatePolygon(nativeMapViewPtr, polygon.getId(), polygon);
- }
+ protected void onInvalidate() {
+ mapView.onInvalidate();
+ }
- public void updatePolyline(Polyline polyline) {
- nativeUpdatePolyline(nativeMapViewPtr, polyline.getId(), polyline);
- }
+ protected void onMapChanged(int rawChange) {
+ mapView.onMapChanged(rawChange);
+ }
- public void removeAnnotation(long id) {
- long[] ids = {id};
- removeAnnotations(ids);
- }
+ protected void onFpsChanged(double fps) {
+ mapView.onFpsChanged(fps);
+ }
- public void removeAnnotations(long[] ids) {
- nativeRemoveAnnotations(nativeMapViewPtr, ids);
- }
+ protected void onSnapshotReady(byte[] bytes) {
+ mapView.onSnapshotReady(bytes);
+ }
- public long[] queryPointAnnotations(RectF rect) {
- return nativeQueryPointAnnotations(nativeMapViewPtr, rect);
- }
+ //
+ // JNI methods
+ //
- public void addAnnotationIcon(String symbol, int width, int height, float scale, byte[] pixels) {
- nativeAddAnnotationIcon(nativeMapViewPtr, symbol, width, height, scale, pixels);
- }
+ private native long nativeCreate(String cachePath, String dataPath, String apkPath, float pixelRatio,
+ int availableProcessors, long totalMemory);
- public void setVisibleCoordinateBounds(LatLng[] coordinates, RectF padding, double direction, long duration) {
- nativeSetVisibleCoordinateBounds(nativeMapViewPtr, coordinates, padding, direction, duration);
- }
+ private native void nativeDestroy(long nativeMapViewPtr);
- public void onLowMemory() {
- nativeOnLowMemory(nativeMapViewPtr);
- }
+ private native void nativeInitializeDisplay(long nativeMapViewPtr);
- public void setDebug(boolean debug) {
- nativeSetDebug(nativeMapViewPtr, debug);
- }
+ private native void nativeTerminateDisplay(long nativeMapViewPtr);
- public void cycleDebugOptions() {
- nativeToggleDebug(nativeMapViewPtr);
- }
+ private native void nativeInitializeContext(long nativeMapViewPtr);
- public boolean getDebug() {
- return nativeGetDebug(nativeMapViewPtr);
- }
+ private native void nativeTerminateContext(long nativeMapViewPtr);
- public boolean isFullyLoaded() {
- return nativeIsFullyLoaded(nativeMapViewPtr);
- }
-
- public void setReachability(boolean status) {
- nativeSetReachability(nativeMapViewPtr, status);
- }
-
- public double getMetersPerPixelAtLatitude(double lat, double zoom) {
- return nativeGetMetersPerPixelAtLatitude(nativeMapViewPtr, lat, zoom);
- }
-
- public ProjectedMeters projectedMetersForLatLng(LatLng latLng) {
- return nativeProjectedMetersForLatLng(nativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude());
- }
-
- public LatLng latLngForProjectedMeters(ProjectedMeters projectedMeters) {
- return nativeLatLngForProjectedMeters(nativeMapViewPtr, projectedMeters.getNorthing(), projectedMeters.getEasting());
- }
-
- public PointF pixelForLatLng(LatLng latLng) {
- return nativePixelForLatLng(nativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude());
- }
-
- public LatLng latLngForPixel(PointF pixel) {
- return nativeLatLngForPixel(nativeMapViewPtr, pixel.x, pixel.y);
- }
-
- public double getTopOffsetPixelsForAnnotationSymbol(String symbolName) {
- return nativeGetTopOffsetPixelsForAnnotationSymbol(nativeMapViewPtr, symbolName);
- }
-
- public void jumpTo(double angle, LatLng center, double pitch, double zoom) {
- nativeJumpTo(nativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), pitch, zoom);
- }
+ private native void nativeCreateSurface(long nativeMapViewPtr,
+ Surface surface);
- public void easeTo(double angle, LatLng center, long duration, double pitch, double zoom, boolean easingInterpolator) {
- nativeEaseTo(nativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom, easingInterpolator);
- }
+ private native void nativeDestroySurface(long nativeMapViewPtr);
- public void flyTo(double angle, LatLng center, long duration, double pitch, double zoom) {
- nativeFlyTo(nativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom);
- }
+ private native void nativeUpdate(long nativeMapViewPtr);
- public double[] getCameraValues() {
- return nativeGetCameraValues(nativeMapViewPtr);
- }
+ private native void nativeRender(long nativeMapViewPtr);
- // Runtime style Api
+ private native void nativeViewResize(long nativeMapViewPtr, int width, int height);
- public Layer getLayer(String layerId) {
- return nativeGetLayer(nativeMapViewPtr, layerId);
- }
+ private native void nativeFramebufferResize(long nativeMapViewPtr, int fbWidth, int fbHeight);
- public void addLayer(@NonNull Layer layer, @Nullable String before) {
- nativeAddLayer(nativeMapViewPtr, layer.getNativePtr(), before);
- layer.invalidate();
- }
+ private native void nativeAddClass(long nativeMapViewPtr, String clazz);
- public void removeLayer(@NonNull String layerId) throws NoSuchLayerException {
- nativeRemoveLayer(nativeMapViewPtr, layerId);
- }
+ private native void nativeRemoveClass(long nativeMapViewPtr, String clazz);
- public Source getSource(@NonNull String sourceId) {
- return nativeGetSource(nativeMapViewPtr, sourceId);
- }
+ private native boolean nativeHasClass(long nativeMapViewPtr, String clazz);
- public void addSource(@NonNull Source source) {
- nativeAddSource(nativeMapViewPtr, source.getNativePtr());
- }
+ private native void nativeSetClasses(long nativeMapViewPtr,
+ List<String> classes);
- public void removeSource(@NonNull String sourceId) throws NoSuchSourceException {
- nativeRemoveSource(nativeMapViewPtr, sourceId);
- }
+ private native List<String> nativeGetClasses(long nativeMapViewPtr);
- public void addImage(@NonNull String name, @NonNull Bitmap image) {
- //Check/correct config
- if (image.getConfig() != Bitmap.Config.ARGB_8888) {
- image = image.copy(Bitmap.Config.ARGB_8888, false);
- }
+ private native void nativeSetStyleUrl(long nativeMapViewPtr, String url);
- //Get pixels
- ByteBuffer buffer = ByteBuffer.allocate(image.getByteCount());
- image.copyPixelsToBuffer(buffer);
+ private native String nativeGetStyleUrl(long nativeMapViewPtr);
- //Determine pixel ratio
- float density = image.getDensity() == Bitmap.DENSITY_NONE ? Bitmap.DENSITY_NONE : image.getDensity();
- float pixelRatio = density / DisplayMetrics.DENSITY_DEFAULT;
+ private native void nativeSetStyleJson(long nativeMapViewPtr, String newStyleJson);
- nativeAddImage(nativeMapViewPtr, name, image.getWidth(), image.getHeight(), pixelRatio, buffer.array());
- }
+ private native String nativeGetStyleJson(long nativeMapViewPtr);
- public void removeImage(String name) {
- nativeRemoveImage(nativeMapViewPtr, name);
- }
+ private native void nativeSetAccessToken(long nativeMapViewPtr, String accessToken);
- // Feature querying
+ private native String nativeGetAccessToken(long nativeMapViewPtr);
- @NonNull
- public List<Feature> queryRenderedFeatures(PointF coordinates, String... layerIds) {
- Feature[] features = nativeQueryRenderedFeaturesForPoint(nativeMapViewPtr, coordinates.x / pixelRatio, coordinates.y / pixelRatio, layerIds);
- return features != null ? Arrays.asList(features) : new ArrayList<Feature>();
- }
+ private native void nativeCancelTransitions(long nativeMapViewPtr);
- @NonNull
- public List<Feature> queryRenderedFeatures(RectF coordinates, String... layerIds) {
- Feature[] features = nativeQueryRenderedFeaturesForBox(
- nativeMapViewPtr,
- coordinates.left / pixelRatio,
- coordinates.top / pixelRatio,
- coordinates.right / pixelRatio,
- coordinates.bottom / pixelRatio,
- layerIds);
- return features != null ? Arrays.asList(features) : new ArrayList<Feature>();
- }
+ private native void nativeSetGestureInProgress(long nativeMapViewPtr, boolean inProgress);
- public void scheduleTakeSnapshot() {
- nativeScheduleTakeSnapshot(nativeMapViewPtr);
- }
+ private native void nativeMoveBy(long nativeMapViewPtr, double dx,
+ double dy, long duration);
- public void setApiBaseUrl(String baseUrl) {
- nativeSetAPIBaseURL(nativeMapViewPtr, baseUrl);
- }
-
- //
- // Callbacks
- //
-
- protected void onInvalidate() {
- mapView.onInvalidate();
- }
-
- protected void onMapChanged(int rawChange) {
- mapView.onMapChanged(rawChange);
- }
-
- protected void onFpsChanged(double fps) {
- mapView.onFpsChanged(fps);
- }
-
- protected void onSnapshotReady(byte[] bytes) {
- mapView.onSnapshotReady(bytes);
- }
-
- //
- // JNI methods
- //
-
- private native long nativeCreate(String cachePath, String dataPath, String apkPath, float pixelRatio, int availableProcessors, long totalMemory);
-
- private native void nativeDestroy(long nativeMapViewPtr);
-
- private native void nativeInitializeDisplay(long nativeMapViewPtr);
-
- private native void nativeTerminateDisplay(long nativeMapViewPtr);
-
- private native void nativeInitializeContext(long nativeMapViewPtr);
-
- private native void nativeTerminateContext(long nativeMapViewPtr);
-
- private native void nativeCreateSurface(long nativeMapViewPtr,
- Surface surface);
-
- private native void nativeDestroySurface(long nativeMapViewPtr);
-
- private native void nativeUpdate(long nativeMapViewPtr);
-
- private native void nativeRender(long nativeMapViewPtr);
-
- private native void nativeViewResize(long nativeMapViewPtr, int width, int height);
-
- private native void nativeFramebufferResize(long nativeMapViewPtr, int fbWidth, int fbHeight);
-
- private native void nativeAddClass(long nativeMapViewPtr, String clazz);
-
- private native void nativeRemoveClass(long nativeMapViewPtr, String clazz);
-
- private native boolean nativeHasClass(long nativeMapViewPtr, String clazz);
-
- private native void nativeSetClasses(long nativeMapViewPtr,
- List<String> classes);
-
- private native List<String> nativeGetClasses(long nativeMapViewPtr);
-
- private native void nativeSetStyleUrl(long nativeMapViewPtr, String url);
+ private native void nativeSetLatLng(long nativeMapViewPtr, double latitude, double longitude,
+ long duration);
- private native void nativeSetStyleJson(long nativeMapViewPtr, String newStyleJson);
+ private native LatLng nativeGetLatLng(long nativeMapViewPtr);
- private native String nativeGetStyleJson(long nativeMapViewPtr);
+ private native void nativeResetPosition(long nativeMapViewPtr);
- private native void nativeSetAccessToken(long nativeMapViewPtr, String accessToken);
+ private native double nativeGetPitch(long nativeMapViewPtr);
- private native String nativeGetAccessToken(long nativeMapViewPtr);
+ private native void nativeSetPitch(long nativeMapViewPtr, double pitch, long duration);
- private native void nativeCancelTransitions(long nativeMapViewPtr);
+ private native void nativeScaleBy(long nativeMapViewPtr, double ds,
+ double cx, double cy, long duration);
- private native void nativeSetGestureInProgress(long nativeMapViewPtr, boolean inProgress);
+ private native void nativeSetScale(long nativeMapViewPtr, double scale,
+ double cx, double cy, long duration);
- private native void nativeMoveBy(long nativeMapViewPtr, double dx,
- double dy, long duration);
+ private native double nativeGetScale(long nativeMapViewPtr);
- private native void nativeSetLatLng(long nativeMapViewPtr, double latitude, double longitude,
- long duration);
+ private native void nativeSetZoom(long nativeMapViewPtr, double zoom,
+ long duration);
- private native LatLng nativeGetLatLng(long nativeMapViewPtr);
+ private native double nativeGetZoom(long nativeMapViewPtr);
- private native void nativeResetPosition(long nativeMapViewPtr);
+ private native void nativeResetZoom(long nativeMapViewPtr);
- private native double nativeGetPitch(long nativeMapViewPtr);
+ private native void nativeSetMinZoom(long nativeMapViewPtr, double zoom);
- private native void nativeSetPitch(long nativeMapViewPtr, double pitch, long duration);
+ private native double nativeGetMinZoom(long nativeMapViewPtr);
- private native void nativeScaleBy(long nativeMapViewPtr, double ds,
- double cx, double cy, long duration);
+ private native void nativeSetMaxZoom(long nativeMapViewPtr, double zoom);
- private native void nativeSetScale(long nativeMapViewPtr, double scale,
- double cx, double cy, long duration);
+ private native double nativeGetMaxZoom(long nativeMapViewPtr);
- private native double nativeGetScale(long nativeMapViewPtr);
+ private native void nativeRotateBy(long nativeMapViewPtr, double sx,
+ double sy, double ex, double ey, long duration);
- private native void nativeSetZoom(long nativeMapViewPtr, double zoom,
- long duration);
+ private native void nativeSetContentPadding(long nativeMapViewPtr, double top, double left, double bottom,
+ double right);
- private native double nativeGetZoom(long nativeMapViewPtr);
+ private native void nativeSetBearing(long nativeMapViewPtr, double degrees,
+ long duration);
- private native void nativeResetZoom(long nativeMapViewPtr);
+ private native void nativeSetBearingXY(long nativeMapViewPtr, double degrees,
+ double cx, double cy);
- private native void nativeSetMinZoom(long nativeMapViewPtr, double zoom);
+ private native double nativeGetBearing(long nativeMapViewPtr);
- private native double nativeGetMinZoom(long nativeMapViewPtr);
+ private native void nativeResetNorth(long nativeMapViewPtr);
- private native void nativeSetMaxZoom(long nativeMapViewPtr, double zoom);
+ private native void nativeUpdateMarker(long nativeMapViewPtr, long markerId, double lat, double lon, String iconId);
- private native double nativeGetMaxZoom(long nativeMapViewPtr);
+ private native long[] nativeAddMarkers(long nativeMapViewPtr, Marker[] markers);
- private native void nativeRotateBy(long nativeMapViewPtr, double sx,
- double sy, double ex, double ey, long duration);
+ private native long[] nativeAddPolylines(long nativeMapViewPtr, Polyline[] polylines);
- private native void nativeSetContentPadding(long nativeMapViewPtr, double top, double left, double bottom, double right);
+ private native long[] nativeAddPolygons(long nativeMapViewPtr, Polygon[] polygons);
- private native void nativeSetBearing(long nativeMapViewPtr, double degrees,
- long duration);
+ private native void nativeRemoveAnnotations(long nativeMapViewPtr, long[] id);
- private native void nativeSetBearingXY(long nativeMapViewPtr, double degrees,
- double cx, double cy);
+ private native long[] nativeQueryPointAnnotations(long nativeMapViewPtr, RectF rect);
- private native double nativeGetBearing(long nativeMapViewPtr);
+ private native void nativeAddAnnotationIcon(long nativeMapViewPtr, String symbol,
+ int width, int height, float scale, byte[] pixels);
- private native void nativeResetNorth(long nativeMapViewPtr);
+ private native void nativeSetVisibleCoordinateBounds(long nativeMapViewPtr, LatLng[] coordinates,
+ RectF padding, double direction, long duration);
- private native void nativeUpdateMarker(long nativeMapViewPtr, long markerId, double lat, double lon, String iconId);
+ private native void nativeOnLowMemory(long nativeMapViewPtr);
- private native long[] nativeAddMarkers(long nativeMapViewPtr, Marker[] markers);
+ private native void nativeSetDebug(long nativeMapViewPtr, boolean debug);
- private native long[] nativeAddPolylines(long nativeMapViewPtr, Polyline[] polylines);
+ private native void nativeToggleDebug(long nativeMapViewPtr);
- private native long[] nativeAddPolygons(long nativeMapViewPtr, Polygon[] polygons);
+ private native boolean nativeGetDebug(long nativeMapViewPtr);
- private native void nativeRemoveAnnotations(long nativeMapViewPtr, long[] id);
+ private native boolean nativeIsFullyLoaded(long nativeMapViewPtr);
- private native long[] nativeQueryPointAnnotations(long nativeMapViewPtr, RectF rect);
+ private native void nativeSetReachability(long nativeMapViewPtr, boolean status);
- private native void nativeAddAnnotationIcon(long nativeMapViewPtr, String symbol,
- int width, int height, float scale, byte[] pixels);
+ private native double nativeGetMetersPerPixelAtLatitude(long nativeMapViewPtr, double lat, double zoom);
- private native void nativeSetVisibleCoordinateBounds(long nativeMapViewPtr, LatLng[] coordinates,
- RectF padding, double direction, long duration);
+ private native ProjectedMeters nativeProjectedMetersForLatLng(long nativeMapViewPtr, double latitude,
+ double longitude);
- private native void nativeOnLowMemory(long nativeMapViewPtr);
+ private native LatLng nativeLatLngForProjectedMeters(long nativeMapViewPtr, double northing, double easting);
- private native void nativeSetDebug(long nativeMapViewPtr, boolean debug);
+ private native PointF nativePixelForLatLng(long nativeMapViewPtr, double lat, double lon);
- private native void nativeToggleDebug(long nativeMapViewPtr);
+ private native LatLng nativeLatLngForPixel(long nativeMapViewPtr, float x, float y);
- private native boolean nativeGetDebug(long nativeMapViewPtr);
+ private native double nativeGetTopOffsetPixelsForAnnotationSymbol(long nativeMapViewPtr, String symbolName);
- private native boolean nativeIsFullyLoaded(long nativeMapViewPtr);
+ private native void nativeJumpTo(long nativeMapViewPtr, double angle, double latitude, double longitude,
+ double pitch, double zoom);
- private native void nativeSetReachability(long nativeMapViewPtr, boolean status);
+ private native void nativeEaseTo(long nativeMapViewPtr, double angle, double latitude, double longitude,
+ long duration, double pitch, double zoom, boolean easingInterpolator);
- private native double nativeGetMetersPerPixelAtLatitude(long nativeMapViewPtr, double lat, double zoom);
+ private native void nativeFlyTo(long nativeMapViewPtr, double angle, double latitude, double longitude,
+ long duration, double pitch, double zoom);
- private native ProjectedMeters nativeProjectedMetersForLatLng(long nativeMapViewPtr, double latitude, double longitude);
+ private native double[] nativeGetCameraValues(long nativeMapViewPtr);
- private native LatLng nativeLatLngForProjectedMeters(long nativeMapViewPtr, double northing, double easting);
+ private native Layer nativeGetLayer(long nativeMapViewPtr, String layerId);
- private native PointF nativePixelForLatLng(long nativeMapViewPtr, double lat, double lon);
+ private native void nativeAddLayer(long nativeMapViewPtr, long layerPtr, String before);
- private native LatLng nativeLatLngForPixel(long nativeMapViewPtr, float x, float y);
+ private native void nativeRemoveLayerById(long nativeMapViewPtr, String layerId) throws NoSuchLayerException;
- private native double nativeGetTopOffsetPixelsForAnnotationSymbol(long nativeMapViewPtr, String symbolName);
+ private native void nativeRemoveLayer(long nativeMapViewPtr, long layerId) throws NoSuchLayerException;
- private native void nativeJumpTo(long nativeMapViewPtr, double angle, double latitude, double longitude, double pitch, double zoom);
+ private native Source nativeGetSource(long nativeMapViewPtr, String sourceId);
- private native void nativeEaseTo(long nativeMapViewPtr, double angle, double latitude, double longitude, long duration, double pitch, double zoom, boolean easingInterpolator);
+ private native void nativeAddSource(long nativeMapViewPtr, long nativeSourcePtr);
- private native void nativeFlyTo(long nativeMapViewPtr, double angle, double latitude, double longitude, long duration, double pitch, double zoom);
+ private native void nativeRemoveSourceById(long nativeMapViewPtr, String sourceId) throws NoSuchSourceException;
- private native double[] nativeGetCameraValues(long nativeMapViewPtr);
+ private native void nativeRemoveSource(long nativeMapViewPtr, long sourcePtr) throws NoSuchSourceException;
- private native Layer nativeGetLayer(long nativeMapViewPtr, String layerId);
+ private native void nativeAddImage(long nativeMapViewPtr, String name, int width, int height, float pixelRatio,
+ byte[] array);
- private native void nativeAddLayer(long nativeMapViewPtr, long layerPtr, String before);
+ private native void nativeRemoveImage(long nativeMapViewPtr, String name);
- private native void nativeRemoveLayer(long nativeMapViewPtr, String layerId) throws NoSuchLayerException;
+ private native void nativeUpdatePolygon(long nativeMapViewPtr, long polygonId, Polygon polygon);
- private native Source nativeGetSource(long nativeMapViewPtr, String sourceId);
+ private native void nativeUpdatePolyline(long nativeMapviewPtr, long polylineId, Polyline polyline);
- private native void nativeAddSource(long nativeMapViewPtr, long nativeSourcePtr);
+ private native void nativeScheduleTakeSnapshot(long nativeMapViewPtr);
- private native void nativeRemoveSource(long nativeMapViewPtr, String sourceId) throws NoSuchSourceException;
+ private native Feature[] nativeQueryRenderedFeaturesForPoint(long nativeMapViewPtr, float x, float y, String[]
+ layerIds);
- private native void nativeAddImage(long nativeMapViewPtr, String name, int width, int height, float pixelRatio, byte[] array);
+ private native Feature[] nativeQueryRenderedFeaturesForBox(long nativeMapViewPtr, float left, float top, float right,
+ float bottom, String[] layerIds);
- private native void nativeRemoveImage(long nativeMapViewPtr, String name);
+ private native void nativeSetAPIBaseURL(long nativeMapViewPtr, String baseUrl);
- private native void nativeUpdatePolygon(long nativeMapViewPtr, long polygonId, Polygon polygon);
+ int getWidth() {
+ return mapView.getWidth();
+ }
- private native void nativeUpdatePolyline(long nativeMapviewPtr, long polylineId, Polyline polyline);
+ int getHeight() {
+ return mapView.getHeight();
+ }
- private native void nativeScheduleTakeSnapshot(long nativeMapViewPtr);
+ //
+ // MapChangeEvents
+ //
- private native Feature[] nativeQueryRenderedFeaturesForPoint(long nativeMapViewPtr, float x, float y, String[] layerIds);
+ void addOnMapChangedListener(@NonNull MapView.OnMapChangedListener listener) {
+ onMapChangedListeners.add(listener);
+ }
- private native Feature[] nativeQueryRenderedFeaturesForBox(long nativeMapViewPtr, float left, float top, float right, float bottom, String[] layerIds);
+ void removeOnMapChangedListener(@NonNull MapView.OnMapChangedListener listener) {
+ onMapChangedListeners.remove(listener);
+ }
- private native void nativeSetAPIBaseURL(long nativeMapViewPtr, String baseUrl);
+ void onMapChangedEventDispatch(int mapChange) {
+ if (onMapChangedListeners != null) {
+ for (MapView.OnMapChangedListener onMapChangedListener : onMapChangedListeners) {
+ onMapChangedListener.onMapChanged(mapChange);
+ }
+ }
+ }
}