2点触摸事件
private boolean isZoom = false;
private float oldDist;
private float spacing(MotionEvent event) {
float x = event.getX(0) - event.getX(1);
float y = event.getY(0) - event.getY(1);
return FloatMath.sqrt(x * x + y * y);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
getCurrentInfo();
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_POINTER_UP:
isZoom = false;
break;
case MotionEvent.ACTION_POINTER_DOWN:
oldDist = spacing(event);
isZoom = true;
break;
case MotionEvent.ACTION_MOVE:
if (isZoom) {
float newDist = spacing(event);
if (newDist + 10 > oldDist) {
MapUtil.MapzoomIn();
setMainMapScale();
}
if (newDist + 10 < oldDist) {
MapUtil.MapzoomOut();
setMainMapScale();
}
}
break;
}
return false;
}