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

Commit

Permalink
[android] - remove duplicate bearing/direction API from MapView
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Jul 11, 2016
1 parent 5d64cde commit caba8c1
Showing 1 changed file with 21 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public void onMapChanged(@MapChange int change) {
} else if (change == REGION_IS_CHANGING || change == REGION_DID_CHANGE || change == DID_FINISH_LOADING_MAP) {
mMapboxMap.getMarkerViewManager().scheduleViewMarkerInvalidation();

mCompassView.update(getDirection());
mCompassView.update(getBearing());
mMyLocationView.update();
mMapboxMap.getMarkerViewManager().update();

Expand Down Expand Up @@ -634,45 +634,6 @@ void setTilt(Double pitch) {
mNativeMapView.setPitch(pitch, 0);
}


//
// Direction
//

double getDirection() {
if (mDestroyed) {
return 0;
}

double direction = -mNativeMapView.getBearing();

while (direction > 360) {
direction -= 360;
}
while (direction < 0) {
direction += 360;
}

return direction;
}

void setDirection(@FloatRange(from = MapboxConstants.MINIMUM_DIRECTION, to = MapboxConstants.MAXIMUM_DIRECTION) double direction) {
if (mDestroyed) {
return;
}
setDirection(direction, false);
}

void setDirection(@FloatRange(from = MapboxConstants.MINIMUM_DIRECTION, to = MapboxConstants.MAXIMUM_DIRECTION) double direction, boolean animated) {
if (mDestroyed) {
return;
}
long duration = animated ? MapboxConstants.ANIMATION_DURATION : 0;
mNativeMapView.cancelTransitions();
// Out of range directions are normalised in setBearing
mNativeMapView.setBearing(-direction, duration);
}

void resetNorth() {
if (mDestroyed) {
return;
Expand Down Expand Up @@ -1405,7 +1366,17 @@ CameraPosition invalidateCameraPosition() {
if (mDestroyed) {
return 0;
}
return mNativeMapView.getBearing();

double direction = -mNativeMapView.getBearing();

while (direction > 360) {
direction -= 360;
}
while (direction < 0) {
direction += 360;
}

return direction;
}

void setBearing(float bearing) {
Expand All @@ -1422,6 +1393,13 @@ void setBearing(float bearing, long duration) {
mNativeMapView.setBearing(bearing, duration);
}

void setBearing(double bearing, float focalX, float focalY) {
if (mDestroyed) {
return;
}
mNativeMapView.setBearing(bearing, focalX, focalY);
}

//
// View events
//
Expand Down Expand Up @@ -1931,12 +1909,10 @@ public boolean onRotate(RotateGestureDetector detector) {
// Rotate the map
if (mFocalPoint != null) {
// User provided focal point
mNativeMapView.setBearing(bearing, mFocalPoint.x / mScreenDensity, mFocalPoint.y / mScreenDensity);
setBearing(bearing, mFocalPoint.x / mScreenDensity, mFocalPoint.y / mScreenDensity);
} else {
// around gesture
mNativeMapView.setBearing(bearing,
detector.getFocusX() / mScreenDensity,
detector.getFocusY() / mScreenDensity);
setBearing(bearing, detector.getFocusX() / mScreenDensity, detector.getFocusY() / mScreenDensity);
}
return true;
}
Expand Down

0 comments on commit caba8c1

Please sign in to comment.