我正在尝试通过调用来禁用mapview缩放功能
map.setFocusable(false);
为什么这不起作用,有没有办法做到这一点
答案 0 :(得分:1)
最后我找到了一种方法
public class MapActivity extends Activity{
protected MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.map);
mapView .setTileSource(TileSourceFactory.MAPNIK);
MyOverlay myOverlay = new MyOverlay(getApplicationContext());
//disable double tap
appendOverlay(myOverlay);
//do something here
//enable double top
removeOverlay(myOverlay);
}
protected void removerOverlay(Overlay overlay) {
final OverlayManager mng = map.getOverlayManager();
if(mng.contains(overlay)) {
mng.remove(overlay);
}
}
protected void appendOverlay(Overlay overlay) {
final OverlayManager mng = map.getOverlayManager();
if(!mng.contains(overlay)) {
mng.add(overlay);
}
}
}
这是启用/禁用双击的类,实际上是mapView.setFocusable(false) 不能满足我的需求,就像这个解决方案一样
public class MyOverlay extends Overlay{
public MyOverlay(Context ctx) {
super(ctx);
this.mapView = mapView;
// TODO Auto-generated constructor stub
}
@Override
protected void draw(Canvas arg0, MapView arg1, boolean arg2) {
}
@Override
public boolean onDoubleTap(MotionEvent e, MapView mapView) {
//here return true means that I handled double tap event no
//one need to do anything for this event
//if you do not do anything here double tap will be disable.
return true;
}
}