Ctrl + mouse drag

564
5
02-01-2011 10:59 PM
MarcelKleinmann
New Contributor
Hi there,

we set up a map, using a rest service in an ArcGISDynamicMapServiceLayer.

By pressing the Ctrl key while dragging the mouse and let go again, the map sticks to the mouse pointer and a continous panning is being performed It's not possible to cancel the panning. The only way to get out is to load the website again.

I reproduced this in Esri example maps as well, as:
http://help.arcgis.com/en/webapi/javascript/arcgis/demos/toolbar/toolbar_edit.html

Any clues how to avoid/cancel this pan?

Cheers
Marcello
0 Kudos
5 Replies
HemingZhu
Occasional Contributor III
Hi there,

we set up a map, using a rest service in an ArcGISDynamicMapServiceLayer.

By pressing the Ctrl key while dragging the mouse and let go again, the map sticks to the mouse pointer and a continous panning is being performed It's not possible to cancel the panning. The only way to get out is to load the website again.

I reproduced this in Esri example maps as well, as:
http://help.arcgis.com/en/webapi/javascript/arcgis/demos/toolbar/toolbar_edit.html

Any clues how to avoid/cancel this pan?

Cheers
Marcello


add map.disablePan() in you code logic...
0 Kudos
MarcelKleinmann
New Contributor
Hi hzhu,

thank you, I will give this a try tomorrow and come back to you...

Cheers
0 Kudos
MarcelKleinmann
New Contributor
Hi there,

here the solution (partly taken from a former thread😞

Insert this code into the init() method of your page:

         // IE doesn't play nice attaching onkeyup/onkeydown to the window object...
         var key_event_handle = dojo.isIE ? dojo.query('body')[0] : window;
         dojo.connect(key_event_handle, "onkeydown", function(evt) {
          if (evt.ctrlKey || evt.keyCode == 17) {
           map.disablePan();
           map.disableRubberBandZoom();
             }
         });
         dojo.connect(key_event_handle, "onkeyup", function(evt) { 
          if (evt.ctrlKey || evt.keyCode == 17) {
           map.enablePan();
           map.enableRubberBandZoom();
             }
         });


Cheers
Marcello
0 Kudos
derekswingley1
Frequent Contributor
That code looks familiar ... I'm sure I've seen it somewhere before :).
0 Kudos
MarcelKleinmann
New Contributor
Yes,

thank you Derek for your solution! 😉
0 Kudos