[android] #2805 - Basic wiring up of Android Tilt methods to Core GL Pitch methods
This commit is contained in:
@@ -1102,6 +1102,25 @@ public final class MapView extends FrameLayout {
|
||||
this.mScrollEnabled = scrollEnabled;
|
||||
}
|
||||
|
||||
//
|
||||
// Pitch / Tilt
|
||||
//
|
||||
|
||||
/**
|
||||
* Gets the current Tilt in degrees of the MapView
|
||||
* @return tilt in degrees
|
||||
*/
|
||||
public double getTilt() {
|
||||
return mNativeMapView.getPitch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Tilt in degrees of the MapView
|
||||
* @param pitch New tilt in degrees
|
||||
*/
|
||||
public void setTilt(double pitch) {
|
||||
mNativeMapView.setPitch(pitch);
|
||||
}
|
||||
|
||||
//
|
||||
// Mirrored Google Map's Camera API
|
||||
@@ -1120,8 +1139,7 @@ public final class MapView extends FrameLayout {
|
||||
|
||||
setBearing(update.getBearing());
|
||||
|
||||
// TODO - Set tilt
|
||||
|
||||
setTilt(update.getTilt());
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -256,6 +256,14 @@ final class NativeMapView {
|
||||
nativeResetPosition(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public double getPitch() {
|
||||
return nativeGetPitch(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void setPitch(double pitch) {
|
||||
nativeSetPitch(mNativeMapViewPtr, pitch);
|
||||
}
|
||||
|
||||
public void scaleBy(double ds) {
|
||||
scaleBy(ds, -1.0, -1.0);
|
||||
}
|
||||
@@ -533,6 +541,10 @@ final class NativeMapView {
|
||||
|
||||
private native void nativeResetPosition(long nativeMapViewPtr);
|
||||
|
||||
private native double nativeGetPitch(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeSetPitch(long nativeMapViewPtr, double pitch);
|
||||
|
||||
private native void nativeScaleBy(long nativeMapViewPtr, double ds,
|
||||
double cx, double cy, long duration);
|
||||
|
||||
|
||||
@@ -664,6 +664,20 @@ void JNICALL nativeResetPosition(JNIEnv *env, jobject obj, jlong nativeMapViewPt
|
||||
nativeMapView->getMap().resetPosition();
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetPitch(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetPitch");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
return nativeMapView->getMap().getPitch();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetPitch(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble pitch) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetPitch");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
nativeMapView->getMap().setPitch(pitch, std::chrono::milliseconds(0));
|
||||
}
|
||||
|
||||
void JNICALL nativeScaleBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble ds, jdouble cx,
|
||||
jdouble cy, jlong duration) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeScaleBy");
|
||||
@@ -1888,6 +1902,8 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
{"nativeGetLatLng", "(J)Lcom/mapbox/mapboxsdk/geometry/LatLng;",
|
||||
reinterpret_cast<void *>(&nativeGetLatLng)},
|
||||
{"nativeResetPosition", "(J)V", reinterpret_cast<void *>(&nativeResetPosition)},
|
||||
{"nativeGetPitch", "(J)D", reinterpret_cast<void *>(&nativeGetPitch)},
|
||||
{"nativeSetPitch", "(JD)V", reinterpret_cast<void *>(&nativeSetPitch)},
|
||||
{"nativeScaleBy", "(JDDDJ)V", reinterpret_cast<void *>(&nativeScaleBy)},
|
||||
{"nativeSetScale", "(JDDDJ)V", reinterpret_cast<void *>(&nativeSetScale)},
|
||||
{"nativeGetScale", "(J)D", reinterpret_cast<void *>(&nativeGetScale)},
|
||||
|
||||
Reference in New Issue
Block a user