【问题标题】:osmdroid mapview disabling zoom in/outosmdroid mapview 禁用放大/缩小
【发布时间】:2013-03-06 11:35:10
【问题描述】:

我正在尝试通过调用禁用地图视图缩放功能

map.setFocusable(false);

为什么这不起作用,有什么办法可以做到这一点

【问题讨论】:

    标签: android zooming android-mapview osmdroid


    【解决方案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;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-17
      • 1970-01-01
      相关资源
      最近更新 更多