FeatureDragNDropHandler(map)

Feature drag and drop handler class.

The following events will be triggered on the map:

  • feature-is-draggable
  • feature-dragstart
  • feature-drag
  • feature-dragend

Each event is composed of the following fields:

  • originalEvent the browser event
  • startPoint the point where the drag starts
  • point the current point
  • feature the feature on which the drag starts
  • handler this handler instance

new FeatureDragNDropHandler(map)

Parameters:
Name Type Description
map Map

The Mapbox GL JS map to add the handler to.

Methods

private _fireEvent(type, e) → {Map}

Fire the event on the map.

The event is wrapped in a object providing the following fields:

  • originalEvent the browser event
  • startPoint the point where the drag starts
  • point the current point
  • feature the feature on which the drag starts
  • handler this handler instance
Parameters:
Name Type Description
type string

event type

e Event

browser event

Returns:
Map -

the map instance

private _ignoreEvent(e) → {boolean}

Tells if the event is processed by this handler or not.

Parameters:
Name Type Description
e Event

any browser event but probably on MouseEvent or TouchEvent.

Returns:
boolean -

true is event ignored

private _onDown(e)

Triggered when a mouse button is pressed on the canvas.

Parameters:
Name Type Description
e MouseEvent | TouchEvent

mouse or touch browser event

private _onMouseUp(e)

Triggered when a mouse button is released or the mouse leave the window.

Parameters:
Name Type Description
e MouseEvent | FocusEvent

mouse browser event

private _onMove(e)

Triggered when the mouse move on the document.

Parameters:
Name Type Description
e MouseEvent | TouchEvent

mouse or touch browser event

private _onTouchEnd(e)

Triggered when the touch event ends.

Parameters:
Name Type Description
e FocusEvent

touch browser event

private _onUp(e)

Triggered when a mouse button is released or the touch event ends.

Parameters:
Name Type Description
e MouseEvent | TouchEvent | FocusEvent

mouse or touch browser event

_pointToArray(point) → {Array}

Convert a local Point instance into a [x, y] Array.

Parameters:
Name Type Description
point Point

local Point instance

Returns:
Array

disable()

Disables this handler

enable()

Enables this handler

featureNotDraggable()

Call by external code when a feature-is-draggable event is triggered and the feature should not be draggable

getFeature() → {Object}

Returns the feature on which the drag starts.

Returns:
Object -

the feature on which the drag starts.

isActive() → {boolean}

Returns a boolean indicating whether this handler is in a dragging state or not.

Returns:
boolean -

true if dragging.

isEnabled() → {boolean}

Returns a boolean indicating whether this handler is enabled or not.

Returns:
boolean -

true if the drag and drop enabled.