diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2018-12-10 10:40:17 +0100 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-12-11 18:08:16 +0100 |
commit | 75914acb6b66402539fd0913aed0aebe722b2faa (patch) | |
tree | 207203400ca38a8a7b101357a52773fbea824f11 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk | |
parent | 5a4a7e7ea87532894aea0b21f58bcc807060d0e4 (diff) | |
download | qtlocation-mapboxgl-75914acb6b66402539fd0913aed0aebe722b2faa.tar.gz |
[android] - add more tests, refactor map padding
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk')
2 files changed, 28 insertions, 8 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 891b040d6b..bdbca4fbca 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 @@ -387,10 +387,11 @@ final class NativeMapView { nativeRotateBy(sx / pixelRatio, sy / pixelRatio, ex, ey, duration); } - public void setContentPadding(int[] padding) { + public void setContentPadding(float[] padding) { if (checkState("setContentPadding")) { return; } + // TopLeftBottomRight nativeSetContentPadding( padding[1] / pixelRatio, padding[0] / pixelRatio, @@ -398,6 +399,19 @@ final class NativeMapView { padding[2] / pixelRatio); } + public float[] getContentPadding() { + if (checkState("getContentPadding")) { + return new float[] {0, 0, 0, 0}; + } + float[] topLeftBottomRight = nativeGetContentPadding(); + return new float[]{ + topLeftBottomRight[1] * pixelRatio, + topLeftBottomRight[0] * pixelRatio, + topLeftBottomRight[3] * pixelRatio, + topLeftBottomRight[2] * pixelRatio + }; + } + public void setBearing(double degrees) { if (checkState("setBearing")) { return; @@ -1115,7 +1129,10 @@ final class NativeMapView { private native void nativeRotateBy(double sx, double sy, double ex, double ey, long duration); @Keep - private native void nativeSetContentPadding(double top, double left, double bottom, double right); + private native void nativeSetContentPadding(float top, float left, float bottom, float right); + + @Keep + private native float[] nativeGetContentPadding(); @Keep private native void nativeSetBearing(double degrees, long duration); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java index 8e3092ae1d..c455ae606f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java @@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.PointF; import android.support.annotation.FloatRange; import android.support.annotation.NonNull; - import com.mapbox.geojson.Point; import com.mapbox.mapboxsdk.constants.GeometryConstants; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -32,7 +31,11 @@ public class Projection { void setContentPadding(int[] contentPadding) { this.contentPadding = contentPadding; - nativeMapView.setContentPadding(contentPadding); + float[] output = new float[contentPadding.length]; + for (int i = 0; i < contentPadding.length; i++) { + output[i] = contentPadding[i]; + } + nativeMapView.setContentPadding(output); } int[] getContentPadding() { @@ -121,10 +124,10 @@ public class Projection { top = 0; bottom = nativeMapView.getHeight(); } else { - left = contentPadding[0]; - right = nativeMapView.getWidth() - contentPadding[2]; - top = contentPadding[1]; - bottom = nativeMapView.getHeight() - contentPadding[3]; + left = (float) contentPadding[0]; + right = (float) (nativeMapView.getWidth() - contentPadding[2]); + top = (float) contentPadding[1]; + bottom = (float) (nativeMapView.getHeight() - contentPadding[3]); } LatLng center = fromScreenLocation(new PointF(left + (right - left) / 2, top + (bottom - top) / 2)); |