Search in sources :

Example 1 with DistanceMarker

use of com.peterlaurence.trekadvisor.menu.mapview.components.DistanceMarker 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();
}
Also used : DistanceMarker(com.peterlaurence.trekadvisor.menu.mapview.components.DistanceMarker) TileView(com.qozix.tileview.TileView) DistanceView(com.peterlaurence.trekadvisor.menu.mapview.components.DistanceView) TileView(com.qozix.tileview.TileView) View(android.view.View) DistanceView(com.peterlaurence.trekadvisor.menu.mapview.components.DistanceView) MarkerTouchMoveListener(com.peterlaurence.trekadvisor.menu.tools.MarkerTouchMoveListener)

Aggregations

View (android.view.View)1 DistanceMarker (com.peterlaurence.trekadvisor.menu.mapview.components.DistanceMarker)1 DistanceView (com.peterlaurence.trekadvisor.menu.mapview.components.DistanceView)1 MarkerTouchMoveListener (com.peterlaurence.trekadvisor.menu.tools.MarkerTouchMoveListener)1 TileView (com.qozix.tileview.TileView)1