MultipointDrawAction

require(["esri/views/2d/draw/MultipointDrawAction"], function(MultipointDrawAction) { /* code goes here */ });
Class: esri/views/2d/draw/MultipointDrawAction
Inheritance: MultipointDrawAction Accessor
Since: ArcGIS API for JavaScript 4.6

This class uses the view events to generate a set of coordinates to create a new Multipoint geometry using Draw. When the draw.create("multipoint") method is called, a reference to MultipointDrawAction is returned. You can listen to events on the MultipointDrawAction instance, which allows users to create a multipoint that meets criteria specified by the application.

See also:
Example:
function enableCreateMultipoint(draw, view) {
  var action = draw.create("multipoint");

  // Give a visual feedback to users as they move the pointer over the view
  action.on("cursor-update", function (evt) {
    createMultipointGraphic(evt.vertices);
  });

  // Fires when the user clicks, or presses the "F" key on the view
  // Can also fire when the "R" key is pressed to redo.
  action.on("vertex-add", function (evt) {
    createMultipointGraphic(evt.vertices);
  });

  // Fires when the "Z" key is pressed to undo the last added point
  action.on("vertex-remove", function (evt) {
    createMultipointGraphic(evt.vertices);
  });

  // Create a point when user clicks on the view or presses "C" key.
  action.on("draw-complete", function (evt) {
    createMultipointGraphic(evt.vertices);
  });
}

function createMultipointGraphic(vertices) {
  view.graphics.removeAll();

  var multipoint = new Multipoint({
    points: vertices,
    spatialReference: view.spatialReference
  });

  graphic = new Graphic({
    geometry: multipoint,
    symbol: {
      type: "simple-marker",
      style: "square",
      color: "red",
      size: "16px",
      outline: {
        color: [255, 255, 0],
        width: 3
      }
    }
  });
  view.graphics.add(graphic);
}

Constructors

new MultipointDrawAction(properties)
Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
String

The name of the class.

more details
more detailsAccessor
Number[][]

Two-dimensional array of numbers representing the coordinates of each vertex that comprises the drawn geometry.

more details
more detailsMultipointDrawAction
MapView

A reference to the MapView.

more details
more detailsMultipointDrawAction

Property Details

declaredClassStringreadonly inherited

The name of the class. The declared class name is formatted as esri.folder.className.

verticesNumber[][]readonly

Two-dimensional array of numbers representing the coordinates of each vertex that comprises the drawn geometry.

A reference to the MapView.

Method Overview

NameReturn TypeSummaryClass
Boolean

Indicates if the redo() method can be called on the action instance.

more details
more detailsMultipointDrawAction
Boolean

Indicates if the undo() method can be called on the action instance.

more details
more detailsMultipointDrawAction

Completes drawing the multipoint geometry and fires the draw-complete event.

more details
more detailsMultipointDrawAction

Emits an event on the instance.

more details
more detailsMultipointDrawAction
Boolean

Indicates whether there is an event listener on the instance that matches the provided event name.

more details
more detailsMultipointDrawAction
Object

Registers an event handler on the instance.

more details
more detailsMultipointDrawAction

Incrementally redo actions recorded in the stack.

more details
more detailsMultipointDrawAction

Incrementally undo actions recorded in the stack.

more details
more detailsMultipointDrawAction

Method Details

canRedo(){Boolean}

Indicates if the redo() method can be called on the action instance.

Returns:
TypeDescription
BooleanReturns true if the redo() method can be called.
canUndo(){Boolean}

Indicates if the undo() method can be called on the action instance.

Returns:
TypeDescription
BooleanReturns true if the undo() method can be called.
complete()

Completes drawing the multipoint geometry and fires the draw-complete event. Call this method if the drawing logic needs to be completed other than by double-clicking or pressing the "C" key.

emit(type, event)protected

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters:
type String

The name of the event.

event Object

The event payload.

hasEventListener(type){Boolean}

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameter:
type String

The name of the event.

Returns:
TypeDescription
BooleanReturns true if the class supports the input event.
on(type, listener){Object}

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters:
type String

The name of event to listen for.

listener Function

The function to call when the event is fired.

Returns:
TypeDescription
ObjectReturns an event handler with a remove() method that can be called to stop listening for the event.
PropertyTypeDescription
removeFunctionWhen called, removes the listener from the event.
See also:
Example:
view.on("click", function(event){
  // event is the event handle returned after the event fires.
  console.log(event.mapPoint);
});
redo()

Incrementally redo actions recorded in the stack. Call canRedo() prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the vertex-add or vertex-remove event depending on the last action.

Example:
if (action.canRedo()) {
  action.redo();
}
undo()

Incrementally undo actions recorded in the stack. Call canUndo() prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the vertex-add or vertex-remove event depending on the last action.

Example:
if (action.canUndo()) {
  action.undo();
}

Event Overview

NameTypeSummaryClass
{vertices: Number[][],vertexIndex: Number,preventDefault: Function,defaultPrevented: Boolean,type: String}

Fires after the pointer moves on the view.

more details
more detailsMultipointDrawAction
{vertices: Number[][],preventDefault: Function,defaultPrevented: Boolean,type: String}

Fires after the user has completed drawing a multipoint.

more details
more detailsMultipointDrawAction
{vertices: Number[][],vertexIndex: Number,preventDefault: Function,defaultPrevented: Boolean,type: String}

Fires when a point is added to the multipoint.

more details
more detailsMultipointDrawAction
{vertices: Number[][],vertexIndex: Number,preventDefault: Function,defaultPrevented: Boolean,type: String}

Fires when a point is removed from the multipoint.

more details
more detailsMultipointDrawAction

Event Details

cursor-update

Fires after the pointer moves on the view.

Properties:
vertices Number[][]

Two-dimensional array of numbers representing the coordinates of each vertex that comprises the drawn geometry.

vertexIndex Number

Index of the last vertex added to the vertices array.

preventDefault Function

Prevents event propagation bubbling up the event chain.

defaultPrevented Boolean

Set to true when preventDefault() is called.

type String

The type of the event. For this event, the type is always cursor-update.

Example:
// fires when the pointer moves on the view.
action.on("cursor-update", function (evt) {
  view.graphics.removeAll();
  var multipoint = new Multipoint({
    points: evt.vertices,
    spatialReference: view.spatialReference
  });
  var graphic = createGraphic(multipoint);
  view.graphics.add(graphic);
});
draw-complete

Fires after the user has completed drawing a multipoint.

Properties:
vertices Number[][]

Two-dimensional array of numbers representing the coordinates of each vertex that comprises the drawn geometry.

preventDefault Function

Prevents event propagation bubbling up the event chain.

defaultPrevented Boolean

Set to true when preventDefault() is called.

type String

The type of the event. For this event, the type is always draw-complete.

Example:
// fires when completed drawing the multipoint.
action.on("draw-complete", function (evt) {
  view.graphics.removeAll();
  var multipoint = new Multipoint({
    points: evt.vertices,
    spatialReference: view.spatialReference
  });
  var graphic = createGraphic(multipoint);
  view.graphics.add(graphic);
});
vertex-add

Fires when a point is added to the multipoint.

Properties:
vertices Number[][]

Two-dimensional array of numbers representing the coordinates of each vertex that comprises the drawn geometry.

vertexIndex Number

Index of the last vertex added to the vertices array.

preventDefault Function

Prevents event propagation bubbling up the event chain.

defaultPrevented Boolean

Set to true when preventDefault() is called.

type String

The type of the event. For this event, the type is always vertex-add.

Example:
// fires when a point is added to the multipoint.
action.on("vertex-add", function (evt) {
  view.graphics.removeAll();
  var multipoint = new Multipoint({
    points: evt.vertices,
    spatialReference: view.spatialReference
  });
  var graphic = createGraphic(multipoint);
  view.graphics.add(graphic);
});
vertex-remove

Fires when a point is removed from the multipoint.

Properties:
vertices Number[][]

Two-dimensional array of numbers representing the coordinates of each vertex that comprises the drawn geometry.

vertexIndex Number

Index of the vertex removed from the vertices array.

preventDefault Function

Prevents event propagation bubbling up the event chain.

defaultPrevented Boolean

Set to true when preventDefault() is called.

type String

The type of the event. For this event, the type is always vertex-remove.

Example:
// fires when a point is removed from multipoint.
action.on("vertex-remove", function (evt) {
  view.graphics.removeAll();
  var multipoint = new Multipoint({
    points: evt.vertices,
    spatialReference: view.spatialReference
  });
  var graphic = createGraphic(multipoint);
  view.graphics.add(graphic);
});

API Reference search results

NameTypeModule

There were no match results from your search criteria.