Search in sources :

Example 1 with MarkerGrab

use of com.peterlaurence.trekadvisor.menu.mapview.components.MarkerGrab in project TrekAdvisor by peterLaurence.

the class MarkerLayer method attachMarkerGrab.

/**
 * A {@link MarkerGrab} is used along with a {@link MarkerTouchMoveListener} to reflect its
 * displacement to the marker passed as argument.
 */
private static void attachMarkerGrab(final MovableMarker movableMarker, TileView tileView, Map map, Context context) {
    /* Add a view as background, to move easily the marker */
    MarkerTouchMoveListener.MarkerMoveCallback markerMoveCallback = new MarkerTouchMoveListener.MarkerMoveCallback() {

        @Override
        public void onMarkerMove(TileView tileView, View view, double x, double y) {
            tileView.moveMarker(view, x, y);
            tileView.moveMarker(movableMarker, x, y);
            movableMarker.setRelativeX(x);
            movableMarker.setRelativeY(y);
        }
    };
    MarkerGrab markerGrab = new MarkerGrab(context);
    MarkerTouchMoveListener.MarkerClickCallback markerClickCallback = new MovableMarkerClickCallback(movableMarker, markerGrab, tileView, map);
    markerGrab.setOnTouchListener(new MarkerTouchMoveListener(tileView, markerMoveCallback, markerClickCallback));
    tileView.addMarker(markerGrab, movableMarker.getRelativeX(), movableMarker.getRelativeY(), -0.5f, -0.5f);
    markerGrab.morphIn();
}
Also used : MarkerGrab(com.peterlaurence.trekadvisor.menu.mapview.components.MarkerGrab) TileView(com.qozix.tileview.TileView) TileView(com.qozix.tileview.TileView) View(android.view.View) MarkerTouchMoveListener(com.peterlaurence.trekadvisor.menu.tools.MarkerTouchMoveListener)

Aggregations

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