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

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

-1

Try this:

mapView.setBuiltInZoomControls(false); 

Hope that works! Have fun!

2 Comments

That just enables the built-in zoom controls, but i want to have them disabled as well as the possibility to pan and zoom.
respectively disables them, but still doesn't affect zooming and panning with one's fingers :/

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.