Support zooming via mouse wheel.
Behaviour should possibly be fine-tuned to use a smooth instead of animated zooming and to keep the cursor position as a fixed point instead of moving it to the center. Still, this should be a small improvement for usage with mouse. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
This commit is contained in:
parent
26596e3957
commit
cc87c16b34
3 changed files with 32 additions and 1 deletions
|
@ -50,6 +50,14 @@ public class OsmAndMapLayersView extends View {
|
|||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||
if(mapView == null) {
|
||||
return super.onGenericMotionEvent(event);
|
||||
}
|
||||
return mapView.onGenericMotionEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if(mapView == null) {
|
||||
|
|
|
@ -87,6 +87,14 @@ public class OsmAndMapSurfaceView extends SurfaceView implements Callback {
|
|||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||
if(mapView == null) {
|
||||
return super.onGenericMotionEvent(event);
|
||||
}
|
||||
return mapView.onGenericMotionEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if(mapView == null) {
|
||||
|
|
|
@ -49,6 +49,7 @@ import android.util.DisplayMetrics;
|
|||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.OnDoubleTapListener;
|
||||
import android.view.GestureDetector.OnGestureListener;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
|
@ -729,6 +730,20 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
|
||||
}
|
||||
|
||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0 &&
|
||||
event.getAction() == MotionEvent.ACTION_SCROLL &&
|
||||
event.getAxisValue(MotionEvent.AXIS_VSCROLL) != 0) {
|
||||
final RotatedTileBox tb = getCurrentRotatedTileBox();
|
||||
final double lat = tb.getLatFromPixel(event.getX(), event.getY());
|
||||
final double lon = tb.getLonFromPixel(event.getX(), event.getY());
|
||||
int zoomDir = event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0 ? -1 : 1;
|
||||
getAnimatedDraggingThread().startMoving(lat, lon, getZoom() + zoomDir, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (mapRenderer != null) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
|
@ -996,4 +1011,4 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
return activity;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue