use of com.peterlaurence.trekadvisor.menu.mapview.components.DistanceView in project TrekAdvisor by peterLaurence.
the class DistanceLayer method show.
/**
* Shows the two {@link DistanceMarker} and the {@link DistanceView}.<br>
* {@link #init(Map, TileViewExtended)} must have been called before.
*/
public void show() {
/* Create the DistanceView (the line between the two markers) */
mDistanceView = new DistanceView(mContext, mTileView.getScale());
mTileView.addScaleChangeListener(mDistanceView);
mTileView.addView(mDistanceView);
/* Setup the first marker */
mDistanceMarkerFirst = new DistanceMarker(mContext);
MarkerTouchMoveListener.MarkerMoveCallback firstMarkerMoveCallback = new MarkerTouchMoveListener.MarkerMoveCallback() {
@Override
public void onMarkerMove(TileView tileView, View view, double x, double y) {
mFirstMarkerRelativeX = x;
mFirstMarkerRelativeY = y;
tileView.moveMarker(mDistanceMarkerFirst, x, y);
onMarkerMoved();
}
};
MarkerTouchMoveListener firstMarkerTouchMoveListener = new MarkerTouchMoveListener(mTileView, firstMarkerMoveCallback);
mDistanceMarkerFirst.setOnTouchListener(firstMarkerTouchMoveListener);
/* Setup the second marker*/
mDistanceMarkerSecond = new DistanceMarker(mContext);
MarkerTouchMoveListener.MarkerMoveCallback secondMarkerMoveCallback = new MarkerTouchMoveListener.MarkerMoveCallback() {
@Override
public void onMarkerMove(TileView tileView, View view, double x, double y) {
mSecondMarkerRelativeX = x;
mSecondMarkerRelativeY = y;
tileView.moveMarker(mDistanceMarkerSecond, x, y);
onMarkerMoved();
}
};
MarkerTouchMoveListener secondMarkerTouchMoveListener = new MarkerTouchMoveListener(mTileView, secondMarkerMoveCallback);
mDistanceMarkerSecond.setOnTouchListener(secondMarkerTouchMoveListener);
/* Set their positions */
initDistanceMarkers();
onMarkerMoved();
/* ..and add them to the TileView */
mTileView.addMarker(mDistanceMarkerFirst, mFirstMarkerRelativeX, mFirstMarkerRelativeY, -0.5f, -0.5f);
mTileView.addMarker(mDistanceMarkerSecond, mSecondMarkerRelativeX, mSecondMarkerRelativeY, -0.5f, -0.5f);
mVisible = true;
/* Start the thread that will process distance calculations */
prepareDistanceCalculation();
}
Aggregations