Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapbox Android disable scroll and pan the map

Tags:

android

mapbox

I'm trying to disable the zoom and pan the mapview in a mapbox. I use mapbox 0.4.0. Currently I can disable the zoom, but cannot disable the pan

    MapView mv = (MapView) tab.findViewById(R.id.mapid);
    mv.setZoom(14);
    mv.setMaxZoomLevel(14);
    mv.setMinZoomLevel(14);
like image 918
stephen1706 Avatar asked Sep 23 '14 09:09

stephen1706


2 Answers

Just override the OnTouch returning true:

mapView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return true;
    }
});
like image 124
shaithana Avatar answered Oct 05 '22 23:10

shaithana


In the current version (4.1), this should probably do:

map.getUiSettings().setZoomControlsEnabled(false);
map.getUiSettings().setZoomGesturesEnabled(false);
map.getUiSettings().setScrollGesturesEnabled(false);

Or if you want to get rid of interaction completely:

map.getUiSettings().setAllGesturesEnabled(false);
like image 22
Danilo Bargen Avatar answered Oct 06 '22 00:10

Danilo Bargen