diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index bcf16bb6297..5f69b0deecb 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -20,6 +20,7 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to * Expose source layer identifier [#8709](https://github.com/mapbox/mapbox-gl-native/pull/8709). * Ensure surface is created after display and context [#8759](https://github.com/mapbox/mapbox-gl-native/pull/8759) * Harden telemetry event dispatch [#8767](https://github.com/mapbox/mapbox-gl-native/pull/8767) +* Move LatLngBounds calculation for CameraUpdateFactory to core [#8765](https://github.com/mapbox/mapbox-gl-native/pull/8765) ## 5.0.2 - April 3, 2017 diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java index a8fc58d51c0..5e958ff5651 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java @@ -231,24 +231,6 @@ public Builder(CameraUpdateFactory.ZoomUpdate update) { } } - /** - * Create Builder from an existing array of doubles. - *

- * These values conform to map.ccp representation of a camera position. - *

- * - * @param nativeCameraValues Values containing target, bearing, tilt and zoom - */ - public Builder(double[] nativeCameraValues) { - super(); - if (nativeCameraValues != null && nativeCameraValues.length == 5) { - target(new LatLng(nativeCameraValues[0], nativeCameraValues[1]).wrap()); - bearing(MathUtils.convertNativeBearing(nativeCameraValues[2])); - tilt(nativeCameraValues[3]); - zoom(nativeCameraValues[4]); - } - } - /** * Sets the direction that the camera is pointing in, in degrees clockwise from north. * diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java index ef8a4d58e8b..64b86054a0c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java @@ -2,7 +2,6 @@ import android.graphics.Point; import android.graphics.PointF; -import android.graphics.RectF; import android.support.annotation.IntDef; import android.support.annotation.NonNull; @@ -11,7 +10,6 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.Projection; import com.mapbox.mapboxsdk.maps.UiSettings; -import com.mapbox.services.android.telemetry.utils.MathUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -199,17 +197,13 @@ public CameraPosition getCameraPosition(@NonNull MapboxMap mapboxMap) { static final class CameraBoundsUpdate implements CameraUpdate { private LatLngBounds bounds; - private RectF padding; + private int[] padding; - CameraBoundsUpdate(LatLngBounds bounds, RectF padding) { + CameraBoundsUpdate(LatLngBounds bounds, int[] padding) { this.bounds = bounds; this.padding = padding; } - CameraBoundsUpdate(LatLngBounds bounds, int[] padding) { - this(bounds, new RectF(padding[0], padding[1], padding[2], padding[3])); - } - CameraBoundsUpdate(LatLngBounds bounds, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) { this(bounds, new int[] {paddingLeft, paddingTop, paddingRight, paddingBottom}); } @@ -218,64 +212,13 @@ public LatLngBounds getBounds() { return bounds; } - public RectF getPadding() { + public int[] getPadding() { return padding; } @Override public CameraPosition getCameraPosition(@NonNull MapboxMap mapboxMap) { - // Get required objects - Projection projection = mapboxMap.getProjection(); - UiSettings uiSettings = mapboxMap.getUiSettings(); - - // calculate correct padding - int[] mapPadding = mapboxMap.getPadding(); - RectF latLngPadding = getPadding(); - RectF padding = new RectF(latLngPadding.left + mapPadding[0], - latLngPadding.top + mapPadding[1], - latLngPadding.right + mapPadding[2], - latLngPadding.bottom + mapPadding[3]); - - // Calculate the bounds of the possibly rotated shape with respect to the viewport - PointF nePixel = new PointF(-Float.MAX_VALUE, -Float.MAX_VALUE); - PointF swPixel = new PointF(Float.MAX_VALUE, Float.MAX_VALUE); - float viewportHeight = uiSettings.getHeight(); - for (LatLng latLng : getBounds().toLatLngs()) { - PointF pixel = projection.toScreenLocation(latLng); - swPixel.x = Math.min(swPixel.x, pixel.x); - nePixel.x = Math.max(nePixel.x, pixel.x); - swPixel.y = Math.min(swPixel.y, viewportHeight - pixel.y); - nePixel.y = Math.max(nePixel.y, viewportHeight - pixel.y); - } - - // Calculate width/height - float width = nePixel.x - swPixel.x; - float height = nePixel.y - swPixel.y; - - double zoom = 0; - float minScale = 1; - // Calculate the zoom level - if (padding != null) { - float scaleX = (uiSettings.getWidth() - padding.left - padding.right) / width; - float scaleY = (uiSettings.getHeight() - padding.top - padding.bottom) / height; - minScale = scaleX < scaleY ? scaleX : scaleY; - zoom = projection.calculateZoom(minScale); - zoom = MathUtils.clamp(zoom, mapboxMap.getMinZoomLevel(), mapboxMap.getMaxZoomLevel()); - } - - // Calculate the center point - PointF paddedNEPixel = new PointF(nePixel.x + padding.right / minScale, nePixel.y + padding.top / minScale); - PointF paddedSWPixel = new PointF(swPixel.x - padding.left / minScale, swPixel.y - padding.bottom / minScale); - PointF centerPixel = new PointF((paddedNEPixel.x + paddedSWPixel.x) / 2, (paddedNEPixel.y + paddedSWPixel.y) / 2); - centerPixel.y = viewportHeight - centerPixel.y; - LatLng center = projection.fromScreenLocation(centerPixel); - - return new CameraPosition.Builder() - .target(center) - .zoom(zoom) - .tilt(0) - .bearing(0) - .build(); + return mapboxMap.getCameraForLatLngBounds(bounds, padding); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 779f482693c..be301839eb7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -1521,6 +1521,27 @@ public void setLatLngBoundsForCameraTarget(@Nullable LatLngBounds latLngBounds) nativeMapView.setLatLngBounds(latLngBounds); } + /** + * Gets a camera position that would fit a bounds. + * + * @param latLngBounds the bounds to constrain the map with + */ + public CameraPosition getCameraForLatLngBounds(@Nullable LatLngBounds latLngBounds, int[] padding) { + // calculate and set additional bounds padding + int[] mapPadding = getPadding(); + for (int i = 0; i < padding.length; i++) { + padding[i] = mapPadding[i] + padding[i]; + } + projection.setContentPadding(padding, myLocationViewSettings.getPadding()); + + // get padded camera position from LatLngBounds + CameraPosition cameraPosition = nativeMapView.getCameraForLatLngBounds(latLngBounds); + + // reset map padding + setPadding(mapPadding); + return cameraPosition; + } + // // Padding // @@ -1544,7 +1565,11 @@ public void setLatLngBoundsForCameraTarget(@Nullable LatLngBounds latLngBounds) * @param bottom The bottom margin in pixels. */ public void setPadding(int left, int top, int right, int bottom) { - projection.setContentPadding(new int[] {left, top, right, bottom}, myLocationViewSettings.getPadding()); + setPadding(new int[] {left, top, right, bottom}); + } + + private void setPadding(int[] padding) { + projection.setContentPadding(padding, myLocationViewSettings.getPadding()); uiSettings.invalidate(); } 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 6fd86eba45d..cf8faa9012e 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 @@ -17,6 +17,7 @@ import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.Polygon; import com.mapbox.mapboxsdk.annotations.Polyline; +import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; @@ -317,6 +318,13 @@ public LatLng getLatLng() { return nativeGetLatLng().wrap(); } + public CameraPosition getCameraForLatLngBounds(LatLngBounds latLngBounds) { + if (isDestroyedOn("getCameraForLatLngBounds")) { + return null; + } + return nativeGetCameraForLatLngBounds(latLngBounds); + } + public void resetPosition() { if (isDestroyedOn("resetPosition")) { return; @@ -676,11 +684,11 @@ public void flyTo(double angle, LatLng center, long duration, double pitch, doub nativeFlyTo(angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom); } - public double[] getCameraValues() { + public CameraPosition getCameraPosition() { if (isDestroyedOn("getCameraValues")) { - return new double[] {}; + return new CameraPosition.Builder().build(); } - return nativeGetCameraValues(); + return nativeGetCameraPosition(); } // Runtime style Api @@ -970,6 +978,8 @@ private native void nativeInitialize(NativeMapView nativeMapView, private native LatLng nativeGetLatLng(); + private native CameraPosition nativeGetCameraForLatLngBounds(LatLngBounds latLngBounds); + private native void nativeResetPosition(); private native double nativeGetPitch(); @@ -1054,7 +1064,7 @@ private native void nativeEaseTo(double angle, double latitude, double longitude private native void nativeFlyTo(double angle, double latitude, double longitude, long duration, double pitch, double zoom); - private native double[] nativeGetCameraValues(); + private native CameraPosition nativeGetCameraPosition(); private native long nativeGetTransitionDuration(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java index 6bccf6204bd..e101340111b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java @@ -135,7 +135,7 @@ final void animateCamera(MapboxMap mapboxMap, CameraUpdate update, int durationM @Nullable CameraPosition invalidateCameraPosition() { if (mapView != null) { - cameraPosition = new CameraPosition.Builder(mapView.getCameraValues()).build(); + cameraPosition = mapView.getCameraPosition(); if (onCameraChangeListener != null) { onCameraChangeListener.onCameraChange(this.cameraPosition); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java index 5c33f3f1686..d81538f3230 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java @@ -1,9 +1,11 @@ package com.mapbox.mapboxsdk.testapp.activity.camera; import android.os.Bundle; +import android.os.Handler; import android.support.v7.app.AppCompatActivity; import com.mapbox.mapboxsdk.annotations.MarkerOptions; +import com.mapbox.mapboxsdk.camera.CameraUpdate; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -11,14 +13,8 @@ import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; -import java.util.ArrayList; -import java.util.List; - -import timber.log.Timber; - /** * Test activity showcasing using the LatLngBounds camera API. *

@@ -31,6 +27,9 @@ public class LatLngBoundsActivity extends AppCompatActivity implements OnMapRead private static final LatLng LOS_ANGELES = new LatLng(34.053940, -118.242622); private static final LatLng NEW_YORK = new LatLng(40.712730, -74.005953); + private final LatLng CHINA_BOTTOM_LEFT = new LatLng(15.68169, 73.499857); + private final LatLng CHINA_TOP_RIGHT = new LatLng(53.560711, 134.77281); + private MapView mapView; private MapboxMap mapboxMap; @@ -46,41 +45,31 @@ protected void onCreate(Bundle savedInstanceState) { } @Override - public void onMapReady(MapboxMap map) { + public void onMapReady(final MapboxMap map) { mapboxMap = map; - UiSettings uiSettings = mapboxMap.getUiSettings(); - uiSettings.setAllGesturesEnabled(false); - - mapboxMap.addMarker(new MarkerOptions() - .title("Los Angeles") - .snippet("City Hall") - .position(LOS_ANGELES)); - - mapboxMap.addMarker(new MarkerOptions() - .title("New York") - .snippet("City Hall") - .position(NEW_YORK)); - - List points = new ArrayList<>(); - points.add(NEW_YORK); - points.add(LOS_ANGELES); - - // Create Bounds - final LatLngBounds bounds = new LatLngBounds.Builder() - .includes(points) - .build(); - - // Add map padding - int mapPadding = (int) getResources().getDimension(R.dimen.fab_margin); - mapboxMap.setPadding(mapPadding, mapPadding, mapPadding, mapPadding); - - // Move camera to the bounds with added padding - int padding = (int) getResources().getDimension(R.dimen.coordinatebounds_margin); - mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding), 1500); - - // Log data - Timber.e("Move to bounds: " + bounds.toString()); - Timber.e("Resulting bounds:" + mapboxMap.getProjection().getVisibleRegion().latLngBounds.toString()); + moveToBounds(new LatLngBounds.Builder().include(NEW_YORK).include(LOS_ANGELES).build(), new int[] {0, 0, 0, 0}); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + moveToBounds(new LatLngBounds.Builder().include(CHINA_BOTTOM_LEFT).include(CHINA_TOP_RIGHT).build(), + new int[] {100, 100, 100, 100 }); + } + }, 5000); + } + + private void moveToBounds(LatLngBounds latLngBounds, int[] padding) { + mapboxMap.clear(); + mapboxMap.addMarker(new MarkerOptions().position(latLngBounds.getNorthEast())); + mapboxMap.addMarker(new MarkerOptions().position(latLngBounds.getSouthEast())); + mapboxMap.addMarker(new MarkerOptions().position(latLngBounds.getSouthWest())); + mapboxMap.addMarker(new MarkerOptions().position(latLngBounds.getNorthWest())); + CameraUpdate update = + CameraUpdateFactory.newLatLngBounds(latLngBounds, + padding[0], + padding[1], + padding[2], + padding[3]); + mapboxMap.moveCamera(update); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java index b3eace7856b..0c5f3a4be28 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java @@ -60,22 +60,6 @@ public void testTypedArrayBuilder() { assertEquals("zoom should match", zoom, cameraPosition.zoom, DELTA); } - @Test - public void testJniBuilder() { - double bearing = 180; - double zoom = 12; - double latitude = 10; - double longitude = 11; - double tilt = 44; - - double[] cameraVars = new double[]{latitude, longitude, bearing, tilt, zoom}; - CameraPosition cameraPosition = new CameraPosition.Builder(cameraVars).build(); - assertEquals("bearing should match", bearing, cameraPosition.bearing, DELTA); - assertEquals("latlng should match", new LatLng(latitude, longitude), cameraPosition.target); - assertEquals("tilt should match", tilt, cameraPosition.tilt, DELTA); - assertEquals("zoom should match", zoom, cameraPosition.zoom, DELTA); - } - @Test public void testToString() { LatLng latLng = new LatLng(1, 2); diff --git a/platform/android/config.cmake b/platform/android/config.cmake index de8d0bacb22..2e394371091 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -110,6 +110,8 @@ add_library(mbgl-android STATIC platform/android/src/style/conversion/property_value.hpp platform/android/src/style/conversion/types.hpp platform/android/src/style/conversion/types_string_values.hpp + platform/android/src/map/camera_position.cpp + platform/android/src/map/camera_position.hpp # Style conversion Java -> C++ platform/android/src/style/android_conversion.hpp diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp index 07e0ae2f202..53691acb392 100755 --- a/platform/android/src/jni.cpp +++ b/platform/android/src/jni.cpp @@ -159,6 +159,9 @@ void registerNatives(JavaVM *vm) { IdentityStops::registerNative(env); IntervalStops::registerNative(env); + // Map + CameraPosition::registerNative(env); + // Connectivity ConnectivityListener::registerNative(env); diff --git a/platform/android/src/map/camera_position.cpp b/platform/android/src/map/camera_position.cpp new file mode 100644 index 00000000000..6286047257a --- /dev/null +++ b/platform/android/src/map/camera_position.cpp @@ -0,0 +1,24 @@ +#include "camera_position.hpp" +#include "../geometry/lat_lng.hpp" + +namespace mbgl { +namespace android { + +jni::Object CameraPosition::New(jni::JNIEnv &env, mbgl::CameraOptions options) { + static auto constructor = CameraPosition::javaClass.GetConstructor, double, double, double>(env); + auto center = options.center.value(); + center.wrap(); + return CameraPosition::javaClass.New(env, constructor, LatLng::New(env, center), options.zoom.value_or(0), options.pitch.value_or(0), options.angle.value_or(0)); +} + +void CameraPosition::registerNative(jni::JNIEnv &env) { + // Lookup the class + CameraPosition::javaClass = *jni::Class::Find(env).NewGlobalRef(env).release(); +} + +jni::Class CameraPosition::javaClass; + + +} // namespace android +} // namespace mb + diff --git a/platform/android/src/map/camera_position.hpp b/platform/android/src/map/camera_position.hpp new file mode 100644 index 00000000000..b9f1646cc94 --- /dev/null +++ b/platform/android/src/map/camera_position.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +#include + +namespace mbgl { +namespace android { + +class CameraPosition : private mbgl::util::noncopyable { +public: + + static constexpr auto Name() { return "com/mapbox/mapboxsdk/camera/CameraPosition"; }; + + static jni::Object New(jni::JNIEnv&, mbgl::CameraOptions); + + static jni::Class javaClass; + + static void registerNative(jni::JNIEnv&); + +}; + + +} // namespace android +} // namespace mbgl \ No newline at end of file diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 537979bebc6..5418a9e42a8 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -45,6 +45,7 @@ #include "run_loop_impl.hpp" #include "java/util.hpp" #include "geometry/lat_lng_bounds.hpp" +#include "map/camera_position.hpp" namespace mbgl { namespace android { @@ -449,6 +450,10 @@ void NativeMapView::setLatLng(jni::JNIEnv&, jni::jdouble latitude, jni::jdouble map->setLatLng(mbgl::LatLng(latitude, longitude), insets, mbgl::AnimationOptions{mbgl::Milliseconds(duration)}); } +jni::Object NativeMapView::getCameraForLatLngBounds(jni::JNIEnv& env, jni::Object jBounds) { + return CameraPosition::New(env, map->cameraForLatLngBounds(mbgl::android::LatLngBounds::getLatLngBounds(env, jBounds), insets)); +} + void NativeMapView::setReachability(jni::JNIEnv&, jni::jboolean reachable) { if (reachable) { mbgl::NetworkStatus::Reachable(); @@ -562,21 +567,8 @@ void NativeMapView::enableFps(jni::JNIEnv&, jni::jboolean enable) { fpsEnabled = enable; } -jni::Array NativeMapView::getCameraValues(jni::JNIEnv& env) { - //Create buffer with values - jdouble buf[5]; - mbgl::LatLng latLng = map->getLatLng(insets); - buf[0] = latLng.latitude(); - buf[1] = latLng.longitude(); - buf[2] = -map->getBearing(); - buf[3] = map->getPitch(); - buf[4] = map->getZoom(); - - //Convert to Java array - auto output = jni::Array::New(env, 5); - jni::SetArrayRegion(env, *output, 0, 5, buf); - - return output; +jni::Object NativeMapView::getCameraPosition(jni::JNIEnv& env) { + return CameraPosition::New(env, map->getCameraOptions(insets)); } void NativeMapView::updateMarker(jni::JNIEnv& env, jni::jlong markerId, jni::jdouble lat, jni::jdouble lon, jni::String jid) { @@ -1493,6 +1485,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) { METHOD(&NativeMapView::flyTo, "nativeFlyTo"), METHOD(&NativeMapView::getLatLng, "nativeGetLatLng"), METHOD(&NativeMapView::setLatLng, "nativeSetLatLng"), + METHOD(&NativeMapView::getCameraForLatLngBounds, "nativeGetCameraForLatLngBounds"), METHOD(&NativeMapView::setReachability, "nativeSetReachability"), METHOD(&NativeMapView::resetPosition, "nativeResetPosition"), METHOD(&NativeMapView::getPitch, "nativeGetPitch"), @@ -1513,7 +1506,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) { METHOD(&NativeMapView::setContentPadding, "nativeSetContentPadding"), METHOD(&NativeMapView::scheduleSnapshot, "nativeTakeSnapshot"), METHOD(&NativeMapView::enableFps, "nativeSetEnableFps"), - METHOD(&NativeMapView::getCameraValues, "nativeGetCameraValues"), + METHOD(&NativeMapView::getCameraPosition, "nativeGetCameraPosition"), METHOD(&NativeMapView::updateMarker, "nativeUpdateMarker"), METHOD(&NativeMapView::addMarkers, "nativeAddMarkers"), METHOD(&NativeMapView::setDebug, "nativeSetDebug"), diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp index d1794b35161..e5fcb9badd0 100755 --- a/platform/android/src/native_map_view.hpp +++ b/platform/android/src/native_map_view.hpp @@ -23,6 +23,7 @@ #include "style/layers/layers.hpp" #include "style/sources/sources.hpp" #include "geometry/lat_lng_bounds.hpp" +#include "map/camera_position.hpp" #include #include @@ -129,6 +130,8 @@ class NativeMapView : public View, public Backend { void setLatLng(jni::JNIEnv&, jni::jdouble, jni::jdouble, jni::jlong); + jni::Object getCameraForLatLngBounds(jni::JNIEnv&, jni::Object); + void setReachability(jni::JNIEnv&, jni::jboolean); void resetPosition(jni::JNIEnv&); @@ -169,7 +172,7 @@ class NativeMapView : public View, public Backend { void enableFps(jni::JNIEnv&, jni::jboolean enable); - jni::Array getCameraValues(jni::JNIEnv&); + jni::Object getCameraPosition(jni::JNIEnv&); void updateMarker(jni::JNIEnv&, jni::jlong, jni::jdouble, jni::jdouble, jni::String);