How can i disable the panning/zooming functionality of a MapView (not the zoom controls, i want a wholly static map)?
I've also noticed that touching the map doesn't seem to trigger the MapView onClickListener, could anyone elaborate why?
How can i disable the panning/zooming functionality of a MapView (not the zoom controls, i want a wholly static map)?
I've also noticed that touching the map doesn't seem to trigger the MapView onClickListener, could anyone elaborate why?
For version 2 of the Google Maps API for Android, this is the way:
map.getUiSettings().setScrollGesturesEnabled(false);
This is gauranteed to work
mapView.getMap().getUiSettings().setAllGesturesEnabled(false);
Use android:clickable="false"
in your layout file.
MapView
is closed source. There is nobody who will answer your onClickListener
question.
Commented
Sep 1, 2010 at 12:12
Please use Overlay to get the tap event on the map
http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/Overlay.html
I had the same question and the following solution is the best one I could find and that fulfilled my requirements:
mapView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if(event.getPointerCount() > 1) {
return true;
}
return false;
}
});
As posted by Alexander Stolz here:
How to disable pinch in Android MapView
And here is the reason:
It does not disable clicking on the mapView completely - it only grabs & prevents two-finger gestures (for zooming you need two fingers) - tapping on the map (for instance on Overlays) still works.
this is the right way
@Override
public boolean dispatchTouchEvent(MotionEvent ev)
{
switch (ev.getAction()&MotionEvent.ACTION_MASK)
{
case (MotionEvent.ACTION_DOWN):
{
// do what you want
// you may scroll map where you want
// don't use 'break', the same in case pointer events;
//break;
return true;
}
}
// 'super' go to the mapView procedures and scroll map in own algorithm
return super.dispatchTouchEvent(ev);
}
on your onMapReady method, add these code lines
gMap.getUiSettings().setZoomGesturesEnabled(false);
to disable all the guesures
gMap.getUiSettings().setAllGesturesEnabled(false);
happy coding :)