基本信息
以下是所在类或对象的基本信息。
AMD:
require(["esri/views/draw/PolygonDrawAction"], (PolygonDrawAction) => { /* code goes here */ });
ESM:
import PolygonDrawAction from "@arcgis/core/views/draw/PolygonDrawAction";
类:
esri/views/draw/PolygonDrawAction
继承: PolygonDrawAction > DrawAction > Accessor
自从:用于 JavaScript 4.5 的 ArcGIS API
用法说明
此类使用不同的事件生成一组顶点,以使用 Draw 创建新的 Polygon 几何图形。当调用draw.create("polygon")时,返回对PolygonDrawAction的引用。您可以侦听 PolylineDrawAction 实例上的事件,该实例允许用户创建满足开发人员指定条件的折线。
例子:
function enableCreatePolygon(draw, view) {
let action = draw.create("polygon");
// PolygonDrawAction.vertex-add
// Fires when user clicks, or presses the "F" key.
// Can also be triggered when the "R" key is pressed to redo.
action.on("vertex-add", function (evt) {
createPolygonGraphic(evt.vertices);
});
// PolygonDrawAction.vertex-remove
// Fires when the "Z" key is pressed to undo the last added vertex
action.on("vertex-remove", function (evt) {
createPolygonGraphic(evt.vertices);
});
// Fires when the pointer moves over the view
action.on("cursor-update", function (evt) {
createPolygonGraphic(evt.vertices);
});
// Add a graphic representing the completed polygon
// when user double-clicks on the view or presses the "C" key
action.on("draw-complete", function (evt) {
createPolygonGraphic(evt.vertices);
});
}
function createPolygonGraphic(vertices){
view.graphics.removeAll();
let polygon = {
type: "polygon", // autocasts as Polygon
rings: vertices,
spatialReference: view.spatialReference
};
let graphic = new Graphic({
geometry: polygon,
symbol: {
type: "simple-fill", // autocasts as SimpleFillSymbol
color: "purple",
style: "solid",
outline: { // autocasts as SimpleLineSymbol
color: "white",
width: 1
}
}
});
view.graphics.add(graphic);
}
相关用法
- JavaScript ArcGIS PolygonDrawAction draw-complete事件用法及代码示例
- JavaScript ArcGIS PolygonDrawAction.mode用法及代码示例
- JavaScript ArcGIS PolygonDrawAction vertex-add事件用法及代码示例
- JavaScript ArcGIS PolygonDrawAction vertex-remove事件用法及代码示例
- JavaScript ArcGIS PolygonDrawAction cursor-update事件用法及代码示例
- JavaScript ArcGIS PolygonDrawAction.undo用法及代码示例
- JavaScript ArcGIS PolygonDrawAction.on用法及代码示例
- JavaScript ArcGIS PolygonDrawAction.redo用法及代码示例
- JavaScript ArcGIS PolygonDrawAction redo事件用法及代码示例
- JavaScript ArcGIS PolygonDrawAction undo事件用法及代码示例
- JavaScript ArcGIS Polygon.rings用法及代码示例
- JavaScript ArcGIS PolygonSymbol3D.clone用法及代码示例
- JavaScript ArcGIS PolygonSymbol3D用法及代码示例
- JavaScript ArcGIS Polygon.fromExtent用法及代码示例
- JavaScript ArcGIS PolylineDrawAction redo事件用法及代码示例
- JavaScript ArcGIS PolylineBarrier用法及代码示例
- JavaScript ArcGIS PolylineDrawAction undo事件用法及代码示例
- JavaScript ArcGIS PolylineDrawAction.on用法及代码示例
- JavaScript ArcGIS PolylineDrawAction.mode用法及代码示例
- JavaScript ArcGIS PolylineDrawAction cursor-update事件用法及代码示例
- JavaScript ArcGIS PolylineDrawAction vertex-remove事件用法及代码示例
- JavaScript ArcGIS PolylineDrawAction.undo用法及代码示例
- JavaScript ArcGIS PolylineDrawAction vertex-add事件用法及代码示例
- JavaScript ArcGIS Polyline.paths用法及代码示例
- JavaScript ArcGIS PolylineDrawAction用法及代码示例
注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 PolygonDrawAction。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。