Merge pull request #1482 from rdoeffinger/mousewheelzoom
Support zooming via mouse wheel.
This commit is contained in:
commit
a79556219c
3 changed files with 32 additions and 1 deletions
|
@ -50,6 +50,14 @@ public class OsmAndMapLayersView extends View {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||||
|
if(mapView == null) {
|
||||||
|
return super.onGenericMotionEvent(event);
|
||||||
|
}
|
||||||
|
return mapView.onGenericMotionEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if(mapView == null) {
|
if(mapView == null) {
|
||||||
|
|
|
@ -87,6 +87,14 @@ public class OsmAndMapSurfaceView extends SurfaceView implements Callback {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||||
|
if(mapView == null) {
|
||||||
|
return super.onGenericMotionEvent(event);
|
||||||
|
}
|
||||||
|
return mapView.onGenericMotionEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if(mapView == null) {
|
if(mapView == null) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ import android.util.DisplayMetrics;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.GestureDetector.OnDoubleTapListener;
|
import android.view.GestureDetector.OnDoubleTapListener;
|
||||||
import android.view.GestureDetector.OnGestureListener;
|
import android.view.GestureDetector.OnGestureListener;
|
||||||
|
import android.view.InputDevice;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.SurfaceHolder;
|
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) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if (mapRenderer != null) {
|
if (mapRenderer != null) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|
|
Loading…
Reference in a new issue