Does anyone know if it's possible using the ArcGIS JS API to make it so the map auto-pans based on the user's cursor position if they get within a close distance to the edge of the map viewing area?

This would allow the user to continue editing and not have to do some other action (such arrow keys, or a pan icon) to get the map to pan to an area they want to continue to edit in. I've been looking for some examples of this and I can't seem to find any.

  • You could do this with a mouse move event listener but it would be easy to implement poorly. By default, you click and drag to pan (or use two-finger drag on macs with a trackpad). Have you disabled this in your app? – Derek Swingley Jan 28 '14 at 19:10
  • Yeah, maybe not worth it if the chances are it will behave poorly. Yes, default panning is disabled since trying to both pan and digitize together leads to a bad digitizing experience unfortunately. Kind of seems like this would be a common problem for many. I guess it may be worth just training users to use keyboard arrows to pan. Although that doesn't seem to be working in IE 10/11 right now. – wilbev Jan 30 '14 at 4:01

Here's an example of a simple way to do this: http://jsbin.com/IsokUWEV/1/edit

The map will pan when you get within ten pixels of an edge.

| improve this answer | |
  • Thanks Derek, that is a huge help. Could there be a way to make the panning more incremental, like not pan quite so far when you get within 10 pixels? Likely closer to the same behavior as the arrow keys which only plan in pretty small increments. – wilbev Feb 2 '14 at 0:52
  • 1
    You're welcome. My example uses the API's map.panXXX() methods, which are hardcoded to pan a specific distance. To have more control, you could calculate and use extents to do the panning. – Derek Swingley Feb 3 '14 at 18:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.