问题描述
arcgis runtime for android开发时,如果对地图设定了自定义点击事件后,地图变的不能放大缩小,大概率是通过new View.OnTouchListener(){}的方式设置的事件。如:
mapView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_UP){
Point mapPoint = mapView.screenToLocation(new android.graphics.Point((int)event.getX(), (int)event.getY()));
Graphic g = new Graphic(mapPoint, markerSymbol);
drawLayer.getGraphics().add(g);
}
return true;
}
});
问题解决
解决的方法是通过 new DefaultMapViewOnTouchListener()来设定事件,代码如下:
mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(mapView.getContext(), mapView){
@Override
public boolean onSingleTapUp(MotionEvent event) {
Point mapPoint = mapView.screenToLocation(new android.graphics.Point((int)event.getX(), (int)event.getY()));
Graphic g = new Graphic(mapPoint, markerSymbol);
drawLayer.getGraphics().add(g);
return super.onSingleTapUp(event);
}
});