当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JavaScript ArcGIS MultipointDrawAction用法及代码示例


基本信息

以下是所在类或对象的基本信息。

AMD: require(["esri/views/draw/MultipointDrawAction"], (MultipointDrawAction) => { /* code goes here */ });

ESM: import MultipointDrawAction from "@arcgis/core/views/draw/MultipointDrawAction";

类: esri/views/draw/MultipointDrawAction

继承: MultipointDrawAction > DrawAction > Accessor

自从:用于 JavaScript 4.6 的 ArcGIS API

用法说明

此类使用视图事件生成一组坐标,以使用 Draw 创建新的 Multipoint 几何图形。当调用 draw.create("multipoint") 方法时,将返回对 MultipointDrawAction 的引用。您可以侦听 MultipointDrawAction 实例上的事件,这允许用户创建满足应用程序指定条件的多点。

已知限制

目前,MultipointDrawAction 仅在 MapView 中受支持。

例子:

function enableCreateMultipoint(draw, view) {
  let 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();

  let 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);
}

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 MultipointDrawAction。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。