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

[android] - remove duplicate bearing/direction API from MapView #5643

Merged
merged 1 commit into from
Jul 11, 2016
Merged
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 @@ -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