2

Is there a way of disabling panning/zooming and keeping map overlays clickable?

I am specifically thinking about an ItemizedOverlay that I want to be tappable while denying users from moving around the map's viewport (It's for a game).

I've seen the same question answered but the answer sadly doesn't allow for overlay items to be clicked.

Thanks alot, best regards, Alex

Community
  • 1
  • 1
Alex Thiel
  • 29
  • 1

2 Answers2

4

I know this question is a little old but I had the same problem and found a workaround, it's not a graceful solution but appears to work.

First you have to create your own map subclass overriding the onTouchEvent handler

public class NonPannableMapView extends MapView {

    public NonPannableMapView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);    
    }

    public NonPannableMapView(Context context, AttributeSet attrs){
        super(context, attrs);
    }

    public NonPannableMapView(Context context, String apiKey) {
         super(context, apiKey);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
          //Handle a move so there is no panning or zoom
          if(ev.getAction() == MotionEvent.ACTION_MOVE)
              return true;
      return super.onTouchEvent(ev);
    }
}

Then it's just a case of changing the MapView reference in your layout to NonPannableMapView.

Dwayne
  • 56
  • 4
-1

Try this:

mapView.setBuiltInZoomControls(false);

Hope that works! Have fun!

Srichand Yella
  • 4,218
  • 2
  • 23
  • 24
  • That just enables the built-in zoom controls, but i want to have them disabled as well as the possibility to pan and zoom. – Alex Thiel Jun 22 '11 at 12:44
  • respectively disables them, but still doesn't affect zooming and panning with one's fingers :/ – Alex Thiel Jun 22 '11 at 12:57