基本信息
以下是所在類或對象的基本信息。
AMD:
require(["esri/views/draw/PolylineDrawAction"], (PolylineDrawAction) => { /* code goes here */ });
ESM:
import PolylineDrawAction from "@arcgis/core/views/draw/PolylineDrawAction";
類:
esri/views/draw/PolylineDrawAction
繼承: PolylineDrawAction > DrawAction > Accessor
自從:用於 JavaScript 4.5 的 ArcGIS API
用法說明
此類使用不同的事件生成一組頂點,以使用 Draw 創建新的 Polyline 幾何圖形。當調用draw.create("polyline")時,將返回對該類的引用。您可以偵聽 PolylineDrawAction 實例上的事件,該實例允許用戶創建滿足開發人員指定條件的折線。
例子:
function enableCreatePolyline(draw, view) {
let action = draw.create("polyline");
// listen to PolylineDrawAction.vertex-add
// Fires when the user clicks, or presses the "F" key
// Can also fire when the "R" key is pressed to redo.
action.on("vertex-add", function (evt) {
createPolylineGraphic(evt.vertices);
});
// listen to PolylineDrawAction.vertex-remove
// Fires when the "Z" key is pressed to undo the
// last added vertex
action.on("vertex-remove", function (evt) {
createPolylineGraphic(evt.vertices);
});
// listen to PolylineDrawAction.cursor-update
// fires when the pointer moves over the view
action.on("cursor-update", function (evt) {
createPolylineGraphic(evt.vertices);
});
// listen to PolylineDrawAction.draw-complete
// event to create a graphic when user double-clicks
// on the view or presses the "C" key
action.on("draw-complete", function (evt) {
createPolylineGraphic(evt.vertices);
});
}
function createPolylineGraphic(vertices){
view.graphics.removeAll();
let polyline = {
type: "polyline", // autocasts as Polyline
paths: vertices,
spatialReference: view.spatialReference
};
let graphic = new Graphic({
geometry: polyline,
symbol: {
type: "simple-line", // autocasts as SimpleLineSymbol
color: [4, 90, 141],
width: 3,
cap: "round",
join: "round"
}
});
view.graphic.add(graphic);
}
相關用法
- JavaScript ArcGIS PolylineDrawAction redo事件用法及代碼示例
- 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 PolylineDrawAction draw-complete事件用法及代碼示例
- JavaScript ArcGIS PolylineDrawAction.redo用法及代碼示例
- JavaScript ArcGIS PolylineBarrier用法及代碼示例
- JavaScript ArcGIS Polyline.paths用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction draw-complete事件用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction.mode用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction vertex-add事件用法及代碼示例
- JavaScript ArcGIS Polygon.rings用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction vertex-remove事件用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction cursor-update事件用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction.undo用法及代碼示例
- JavaScript ArcGIS PolygonSymbol3D.clone用法及代碼示例
- JavaScript ArcGIS PolygonSymbol3D用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction.on用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction.redo用法及代碼示例
- JavaScript ArcGIS PolygonDrawAction redo事件用法及代碼示例
注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 PolylineDrawAction。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。