A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-PointDrawAction.html below:

PointDrawAction | API Reference | ArcGIS Maps SDK for JavaScript 4.33

ESM: import PointDrawAction from "@arcgis/core/views/draw/PointDrawAction.js";

CDN: const PointDrawAction = await $arcgis.import("@arcgis/core/views/draw/PointDrawAction.js");

Class: @arcgis/core/views/draw/PointDrawAction

Since: ArcGIS Maps SDK for JavaScript 4.5

This class uses the view events to generate a set of coordinates to create a new Point geometry using Draw. When the draw.create("point") method is called, a reference to PointDrawAction is returned. Listen to PointDrawAction's cursor-update and the draw-complete events to handle the creation of the point geometry.

See also

Example

function enableCreatePoint(draw, view) {
  let action = draw.create("point");

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

  // PointDrawAction.draw-complete
  // Create a point when user clicks on the view or presses the "Enter" key.
  action.on("draw-complete", function (evt) {
    createPointGraphic(evt.coordinates);
  });
}

function createPointGraphic(coordinates){
  view.graphics.removeAll();
  let point = {
    type: "point", // autocasts as /Point
    x: coordinates[0],
    y: coordinates[1],
    spatialReference: view.spatialReference
  };

  let graphic = new Graphic({
    geometry: point,
    symbol: {
      type: "simple-marker", // autocasts as SimpleMarkerSymbol
      style: "square",
      color: "red",
      size: "16px",
      outline: { // autocasts as SimpleLineSymbol
        color: [255, 255, 0],
        width: 3
      }
    }
  });
  view.graphics.add(graphic);
}
Constructors
PointDrawAction Constructor new PointDrawAction(properties)

Parameter

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 Watch for changes topic.

Show inherited properties Hide inherited properties

Property Details
declaredClass

Inherited

Property declaredClass Stringreadonly

Since: ArcGIS Maps SDK for JavaScript 4.7 Accessor since 4.0, declaredClass added at 4.7.

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

hasZ

Inherited

Property hasZ Boolean

Controls whether the created geometry will have z coordinates or not.

Since: ArcGIS Maps SDK for JavaScript 4.19 PointDrawAction since 4.5, vertices added at 4.19.

An array of x,y coordinates for the point geometry.

Method Overview

Show inherited methods Hide inherited methods

Method Details
addHandles

Inherited

Method addHandles(handleOrHandles, groupKey)

Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();

Parameters

Handles marked for removal once the object is destroyed.

groupKey *

optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

canRedo

Inherited

Method canRedo(){Boolean}

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

Returns

Type Description Boolean Returns true if the redo() method can be called.
canUndo

Inherited

Method canUndo(){Boolean}

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

Returns

Type Description Boolean Returns true if the undo() method can be called.
complete Method complete()

Completes drawing the point 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 "Enter" key.

emit

Inherited

Method emit(type, event){Boolean}

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

Parameters

The name of the event.

optional

The event payload.

Returns

Type Description Boolean true if a listener was notified

Maps the given screen point to a map point.

Returns

getCoordsFromScreenPoint

Inherited

Method getCoordsFromScreenPoint(screenPoint){Number[] |null |undefined}

Maps the given screen point to a map point.

Returns

Type Description Number[] | null | undefined Array of x,y and z component (if hasZ is enabled) of the point associated with the given screen point or null if screen point could not be mapped.
hasEventListener

Inherited

Method hasEventListener(type){Boolean}

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

Returns

Type Description Boolean Returns true if the class supports the input event.
hasHandles

Inherited

Method hasHandles(groupKey){Boolean}

Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter

groupKey *

optional

A group key.

Returns

Type Description Boolean Returns true if a named group of handles exist.

Example

// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}
on

Inherited

Method on(type, listener){Object}

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

Returns

Type Description Object Returns an event handler with a remove() method that should be called to stop listening for the event(s). Property Type Description remove Function When called, removes the listener from the event.

Example

view.on("click", function(event){
  // event is the event handle returned after the event fires.
  console.log(event.mapPoint);
});
redo

Inherited

Method 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 events depending on the last action.

Example

if (action.canRedo()) {
  action.redo();
}
removeHandles

Inherited

Method removeHandles(groupKey)

Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter

groupKey *

optional

A group key or an array or collection of group keys to remove.

Example

obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

Maps the given screen point to a map point.

Returns

Type Description Point | null | undefined MapPoint associated with the given screen point or null if screen point could not be mapped.
undo

Inherited

Method 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 events depending on the last action.

Example

if (action.canUndo()) {
  action.undo();
}
Event Overview Name Type Summary Class cursor-update {coordinates: Number[],preventDefault: Function,defaultPrevented: Boolean,type: "cursor-update"}

Fires after the pointer moves on the view.

PointDrawAction draw-complete {coordinates: Number[],preventDefault: Function,defaultPrevented: Boolean,type: "draw-complete"}

Fires after when the user has completed drawing a point.

PointDrawAction Event Details
cursor-update Event cursor-update

Fires after the pointer moves on the view. It returns the location of the pointer on the view as an array of numbers representing an x,y coordinate pair in the spatial reference of the view.

Properties

An array of numbers representing an x,y coordinate pair in the spatial reference of the view.

Prevents event propagation bubbling up the event chain.

Set to true when preventDefault() is called.

The type of the event.

The value is always "cursor-update".

Example

action.on("cursor-update", function (evt) {
  view.graphics.removeAll();
  let point = new Point({
    x: evt.coordinates[0],
    y: evt.coordinates[1],
    spatialReference: view.spatialReference
  });
  let graphic = createGraphic(point);
  view.graphics.add(graphic);
});
draw-complete Event draw-complete

Fires after when the user has completed drawing a point. It returns the location of the pointer on the view as an array of numbers representing an x,y coordinate pair in the spatial reference of the view.

Properties

An array of numbers representing an x,y coordinate pair in the spatial reference of the view.

Prevents event propagation bubbling up the event chain.

Set to true when preventDefault() is called.

The type of the event.

The value is always "draw-complete".

Example

action.on("draw-complete", function (evt) {
  view.graphics.removeAll();
  let point = new Point({
    x: evt.coordinates[0],
    y: evt.coordinates[1],
    spatialReference: view.spatialReference
  });
  let graphic = createGraphic(point);
  view.graphics.add(graphic);
});

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4