Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[android] - using bearing clockwise versus counterclockwise #6917

Merged
merged 2 commits into from
Nov 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ public void onSensorChanged(SensorEvent event) {

private void rotateCamera(float rotation) {
CameraPosition.Builder builder = new CameraPosition.Builder();
builder.bearing(-rotation);
builder.bearing(rotation);
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), COMPASS_UPDATE_RATE_MS, false /*linear interpolator*/, false /*do not disable tracking*/, null);
}

Expand Down Expand Up @@ -694,7 +694,7 @@ void updateLatLng(@NonNull Location location) {
// add direction
if (myBearingTrackingMode == MyBearingTracking.GPS) {
if (location.hasBearing()) {
builder.bearing(-location.getBearing());
builder.bearing(location.getBearing());
}
setCompass(0);
}
Expand Down
8 changes: 4 additions & 4 deletions platform/android/src/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ jdoubleArray nativeGetCameraValues(JNIEnv *env, jni::jobject* obj, jlong nativeM
jdouble buf[5];
buf[0] = latLng.latitude;
buf[1] = latLng.longitude;
buf[2] = -(nativeMapView->getMap().getBearing()-360);
buf[2] = -nativeMapView->getMap().getBearing();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit; spaces

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the brackets

buf[3] = nativeMapView->getMap().getPitch();
buf[4] = nativeMapView->getMap().getZoom();
env->SetDoubleArrayRegion(output, start, leng, buf);
Expand Down Expand Up @@ -1007,7 +1007,7 @@ void nativeJumpTo(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdoubl

mbgl::CameraOptions options;
if (angle != -1) {
options.angle = angle * M_PI / 180;
options.angle = (-angle * M_PI) / 180;
}
options.center = mbgl::LatLng(latitude, longitude);
options.padding = nativeMapView->getInsets();
Expand All @@ -1027,7 +1027,7 @@ void nativeEaseTo(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdoubl

mbgl::CameraOptions cameraOptions;
if (angle != -1) {
cameraOptions.angle = angle * M_PI / 180;
cameraOptions.angle = (-angle * M_PI) / 180;
}
cameraOptions.center = mbgl::LatLng(latitude, longitude);
cameraOptions.padding = nativeMapView->getInsets();
Expand Down Expand Up @@ -1060,7 +1060,7 @@ void nativeFlyTo(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdouble

mbgl::CameraOptions cameraOptions;
if (angle != -1) {
cameraOptions.angle = angle * M_PI / 180 ;
cameraOptions.angle = (-angle * M_PI) / 180 ;
}
cameraOptions.center = mbgl::LatLng(latitude, longitude);
cameraOptions.padding = nativeMapView->getInsets();
Expand Down