Skip to content
Permalink
Browse files

Layer onScroll event (#1132)

  • Loading branch information...
mg4gh authored and devemux86 committed Oct 22, 2019
1 parent 66c95a4 commit 79c0af8f2eca8f032202bd156b6d2926e530f6a8
@@ -5,6 +5,7 @@
* Copyright 2014 Jordan Black
* Copyright 2015 Andreas Schildbach
* Copyright 2018 mikes222
* Copyright 2019 mg4gh
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -24,7 +25,6 @@
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.widget.Scroller;

import org.mapsforge.core.model.LatLong;
import org.mapsforge.core.model.Point;
import org.mapsforge.map.android.view.MapView;
@@ -237,6 +237,13 @@ public void onScaleEnd(ScaleGestureDetector detector) {
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (!this.isInScale && e1.getPointerCount() == 1 && e2.getPointerCount() == 1) {
for (int i = this.mapView.getLayerManager().getLayers().size() - 1; i >= 0; --i) {
Layer layer = this.mapView.getLayerManager().getLayers().get(i);
if (layer.onScroll(e1.getX(), e1.getY(), e2.getX(), e2.getY())) {
return true;
}
}

this.mapView.onMoveEvent();
this.mapView.getModel().mapViewPosition.moveCenter(-distanceX, -distanceY, false);
return true;
@@ -2,6 +2,7 @@
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2014-2015 Ludwig M Brinckmann
* Copyright 2015 devemux86
* Copyright 2019 mg4gh
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -74,6 +75,20 @@ public boolean onLongPress(LatLong tapLatLong, Point layerXY, Point tapXY) {
return false;
}

/**
* Handles a scroll event. A return value of true indicates that the scroll event has been handled by this overlay
* and stops its propagation to other overlays.
*
* @param scrollX1 the x position of the first down motion event that started the scrolling.
* @param scrollY1 the y position of the first down motion event that started the scrolling.
* @param scrollX2 the x position of the move motion event that triggered the current onScroll.
* @param scrollY2 the y position of the move motion event that triggered the current onScroll.
* @return true if the scroll event was handled, false otherwise.
*/
public boolean onScroll(float scrollX1, float scrollY1, float scrollX2, float scrollY2) {
return false;
}

/**
* Handles a tap event. A return value of true indicates that the tap event has been handled by this overlay and
* stops its propagation to other overlays.

0 comments on commit 79c0af8

Please sign in to comment.
You can’t perform that action at this time.