add setSetVisibleCoordinateBounds api as already in iOS

This commit is contained in:
Manabu-GT
2015-10-05 02:57:26 +09:00
committed by Manabu Shimobe
parent 927b4c6dbe
commit 84c8d1fd6e
9 changed files with 257 additions and 21 deletions

View File

@@ -0,0 +1,31 @@
package com.mapbox.mapboxsdk.geometry;
/**
* Implementation of iOS MGLCoordinateBounds
*/
public class CoordinateBounds {
private LatLng sw;
private LatLng ne;
public CoordinateBounds(LatLng sw, LatLng ne) {
this.sw = sw;
this.ne = ne;
}
public LatLng getSw() {
return sw;
}
public void setSw(LatLng sw) {
this.sw = sw;
}
public LatLng getNe() {
return ne;
}
public void setNe(LatLng ne) {
this.ne = ne;
}
}

View File

@@ -68,6 +68,7 @@ import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.exceptions.InvalidAccessTokenException;
import com.mapbox.mapboxsdk.exceptions.SpriteBitmapChangedException;
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.utils.ApiAccess;
@@ -1981,6 +1982,42 @@ public final class MapView extends FrameLayout {
}
}
}
//
// Camera
//
public void setVisibleCoordinateBounds(@NonNull CoordinateBounds bounds) {
setVisibleCoordinateBounds(bounds, false);
}
public void setVisibleCoordinateBounds(@NonNull CoordinateBounds bounds, boolean animated) {
setVisibleCoordinateBounds(bounds, new RectF(), animated);
}
public void setVisibleCoordinateBounds(@NonNull CoordinateBounds bounds, @NonNull RectF padding, boolean animated) {
LatLng[] coordinates = {
new LatLng(bounds.getNe().getLatitude(), bounds.getSw().getLongitude()),
bounds.getSw(),
new LatLng(bounds.getSw().getLatitude(), bounds.getNe().getLongitude()),
bounds.getNe()
};
setVisibleCoordinateBounds(coordinates, padding, animated);
}
public void setVisibleCoordinateBounds(@NonNull LatLng[] coordinates, @NonNull RectF padding, boolean animated) {
setVisibleCoordinateBounds(coordinates, padding, getDirection(), animated);
}
private void setVisibleCoordinateBounds(LatLng[] coordinates, RectF padding, double direction, boolean animated) {
setVisibleCoordinateBounds(coordinates, padding, direction, animated ? ANIMATION_DURATION : 0l);
}
private void setVisibleCoordinateBounds(LatLng[] coordinates, RectF padding, double direction, long duration) {
mNativeMapView.setVisibleCoordinateBounds(coordinates, new RectF(padding.left / mScreenDensity,
padding.top / mScreenDensity, padding.right / mScreenDensity, padding.bottom / mScreenDensity),
direction, duration);
}
/**
* Gets the currently selected marker.

View File

@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.views;
import android.graphics.PointF;
import android.graphics.RectF;
import android.view.Surface;
import com.mapbox.mapboxsdk.annotations.Marker;
@@ -384,6 +385,10 @@ final class NativeMapView {
nativeSetSprite(mNativeMapViewPtr, symbol, width, height, scale, pixels);
}
public void setVisibleCoordinateBounds(LatLng[] coordinates, RectF padding, double direction, long duration) {
nativeSetVisibleCoordinateBounds(mNativeMapViewPtr, coordinates, padding, direction, duration);
}
public void onLowMemory() {
nativeOnLowMemory(mNativeMapViewPtr);
}
@@ -477,7 +482,7 @@ final class NativeMapView {
private native void nativeTerminateContext(long nativeMapViewPtr);
private native void nativeCreateSurface(long nativeMapViewPtr,
Surface surface);
Surface surface);
private native void nativeDestroySurface(long nativeMapViewPtr);
@@ -502,7 +507,7 @@ final class NativeMapView {
private native boolean nativeHasClass(long nativeMapViewPtr, String clazz);
private native void nativeSetClasses(long nativeMapViewPtr,
List<String> classes);
List<String> classes);
private native List<String> nativeGetClasses(long nativeMapViewPtr);
@@ -514,7 +519,7 @@ final class NativeMapView {
private native void nativeSetStyleUrl(long nativeMapViewPtr, String url);
private native void nativeSetStyleJson(long nativeMapViewPtr,
String newStyleJson, String base);
String newStyleJson, String base);
private native String nativeGetStyleJson(long nativeMapViewPtr);
@@ -527,7 +532,7 @@ final class NativeMapView {
private native void nativeSetGestureInProgress(long nativeMapViewPtr, boolean inProgress);
private native void nativeMoveBy(long nativeMapViewPtr, double dx,
double dy, long duration);
double dy, long duration);
private native void nativeSetLatLng(long nativeMapViewPtr, LatLng latLng,
long duration);
@@ -537,10 +542,10 @@ final class NativeMapView {
private native void nativeResetPosition(long nativeMapViewPtr);
private native void nativeScaleBy(long nativeMapViewPtr, double ds,
double cx, double cy, long duration);
double cx, double cy, long duration);
private native void nativeSetScale(long nativeMapViewPtr, double scale,
double cx, double cy, long duration);
double cx, double cy, long duration);
private native double nativeGetScale(long nativeMapViewPtr);
@@ -550,7 +555,7 @@ final class NativeMapView {
private native double nativeGetZoom(long nativeMapViewPtr);
private native void nativeSetLatLngZoom(long nativeMapViewPtr,
LatLngZoom lonLatZoom, long duration);
LatLngZoom lonLatZoom, long duration);
private native LatLngZoom nativeGetLatLngZoom(long nativeMapViewPtr);
@@ -561,13 +566,13 @@ final class NativeMapView {
private native double nativeGetMaxZoom(long nativeMapViewPtr);
private native void nativeRotateBy(long nativeMapViewPtr, double sx,
double sy, double ex, double ey, long duration);
double sy, double ex, double ey, long duration);
private native void nativeSetBearing(long nativeMapViewPtr, double degrees,
long duration);
long duration);
private native void nativeSetBearing(long nativeMapViewPtr, double degrees,
double cx, double cy);
double cx, double cy);
private native double nativeGetBearing(long nativeMapViewPtr);
@@ -592,6 +597,8 @@ final class NativeMapView {
private native void nativeSetSprite(long nativeMapViewPtr, String symbol,
int width, int height, float scale, byte[] pixels);
private native void nativeSetVisibleCoordinateBounds(long mNativeMapViewPtr, LatLng[] coordinates, RectF padding, double direction, long duration);
private native void nativeOnLowMemory(long nativeMapViewPtr);
private native void nativeSetDebug(long nativeMapViewPtr, boolean debug);