我正在尝试通过调用禁用地图视图缩放功能
map.setFocusable(false);
为什么这不起作用,有什么办法可以做到这一点
我正在尝试通过调用禁用地图视图缩放功能
map.setFocusable(false);
为什么这不起作用,有什么办法可以做到这一点
最后我找到了方法
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;
}
}