Search code examples
leafletuser-experience

Leaflet: Difference between map panning and dragging


What does map.dragging do and what is the difference to the pan functionality of the map? Or is dragging = true enabling the panning of the map?


Solution

  • To pan is to change what part of the map the user is looking at; this is derived from the meaning of "pan" in cinematography: moving the camera so the viewport changes.

    In Leaflet, you can pan the map non-interactively, by calling map.panTo() and map.panBy() and map.setCenter() on your map instance (but those are not the only ways to pan a map).

    To drag means "to pull along a surface". In computing, it refers to the drag and drop interaction. It implies user interaction.

    In Leaflet, a map drag is the user action of using a pointing device in a down-move-up sequence on the viewport surface. The map pans as the user drags.

    A map drag implies a map pan; but a map pan does not imply a map drag.

    Also, note that Leaflet allows markers to be draggable. Thus, one can perform a marker drag, an action that is not a map drag, and does not imply a map pan.