How Can I Disable Panning?

4272
5
06-15-2012 09:57 AM
EDWINSANCHEZ
New Contributor
I'm trying to allow the user to move/edit the position of a marker. I would like to disable panning to allow the user to just move the selected marker. How do I accomplish this?
0 Kudos
5 Replies
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
You can disable the OnPanListener event by implementing:
MapView.setOnPanListener(null);
0 Kudos
_lkerArg_n
New Contributor
You can disable the OnPanListener event by implementing:
MapView.setOnPanListener(null);


Does not work for me.
0 Kudos
AndyGup
Esri Regular Contributor
@mggl if the setOnPanListener(null) pattern doesn't work then make sure you don't have another listener enabled somewhere. Chances are that another listener is overriding.

-Andy
0 Kudos
_lkerArg_n
New Contributor
@agup i dont have another onpanlistener enabled. After setting onpanlistener to null, the result of
mapView.getOnPanListener() == null
is true. However, the map still can be panned.
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
Try Implementing this via the MapView.OnTouchListener(); event:
 mMapView.setOnTouchListener(new OnTouchListener(){


  @Override
  public boolean onTouch(View v, MotionEvent event) {
   // TODO Auto-generated method stub
   mMapView.setOnPanListener(null);
   return false;
  }
  
 });


Downside is this will intercept any touch events on your map (pan/zoom/etc..).  With some more logic, you could probably trap what is pan, what is zoom, etc.
Hope this helps.
0 Kudos