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();
}
Aggregations