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

Commit

Permalink
[android] #3244 - Cleaning up getter and setter bearing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bleege committed Dec 11, 2015
1 parent 8f6d08a commit 08b5c17
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngZoom;
import com.mapbox.mapboxsdk.utils.ApiAccess;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -1448,6 +1447,7 @@ public final CameraPosition getCameraPosition () {
*/
public final void animateCamera (CameraUpdate update) {

// Order Matters! Otherwise Core GL will stomp on things
setCenterCoordinate(update.getTarget());
setZoomLevel(update.getZoom());
setTilt(new Double(update.getTilt()), 0L);
Expand Down Expand Up @@ -2474,20 +2474,33 @@ void update() {
}
}

double getBearing() {
/**
* Get Bearing in degrees
* @return Bearing in degrees
*/
public double getBearing() {
return mNativeMapView.getBearing();
}

// Used by UserLocationView
void setBearing(float bearing) {
mNativeMapView.setBearing(bearing, 100);
}

/*
/**
* Set Bearing in degrees
* @param bearing Bearing in degrees
*/
public void setBearing(float bearing) {
mNativeMapView.setBearing(bearing);
}
*/

/**
* Sets Bearing in degrees
*
* NOTE: Used by UserLocationView
*
* @param bearing Bearing in degrees
* @param duration Length of time to rotate
*/
public void setBearing(float bearing, long duration) {
mNativeMapView.setBearing(bearing, duration);
}

//
// View events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ final class UserLocationView extends View implements LocationListener {

// Compass data
private MyBearingListener mBearingChangeListener;
private static final long BEARING_DURATION = 100;

public UserLocationView(Context context) {
super(context);
Expand Down Expand Up @@ -553,7 +554,7 @@ previousCoordinate, new LatLng(location)
mShowDirection = true;
mGpsMarkerDirection = 0;
if (location.hasBearing()) {
mMapView.setBearing(location.getBearing());
mMapView.setBearing(location.getBearing(), BEARING_DURATION);
}
}

Expand Down Expand Up @@ -600,7 +601,7 @@ private void setCompass(float bearing) {
mShowDirection = true;
mGpsMarkerDirection = 0;
mCompassMarkerDirection = 0;
mMapView.setBearing(bearing);
mMapView.setBearing(bearing, BEARING_DURATION);
}
}
}
Expand Down

0 comments on commit 08b5c17

Please sign in to comment.