arcgis for js制作面
1765 ワード
著者がここで使っているesriバージョンは419です.ここでは事前にdrawパッケージを初期化する必要があります.「esri/view/draw/Draw」「esri/Graphic」 「esri/geometry/Polygon」
this.$message.success(" ");
var draw = new Draw({
view:this.view
})
var action = draw.create("polygon", {
mode: "click"//
});
//
this.view.focus();
//
action.on("vertex-add", (evt) =>{
this.createPolygon(evt)
});
//
action.on("vertex-remove", (evt) =>{
this.createPolygon(evt)
});
//
action.on("cursor-update", (evt) =>{
this.createPolygon(evt)
});
//
action.on("draw-complete", (evt) =>{
this.createPolygon(evt)
this.$message.success(" ");
});
ここではgraphicとpolygonの二つのカバンを使いました.async createPolygon(event) {
//
var vertices = event.vertices;
//
this.view.graphics.removeAll();
var Graphic = await arcgisPackage.Graphic;
var Polygon = await arcgisPackage.Polygon;
//
var graphic = new Graphic({
geometry: new Polygon({
hasZ: false,
hasM: false,
rings: [vertices],
spatialReference: this.view.spatialReference
}),
symbol: {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
color: [ 51,51, 204, 0.9 ],
style: "solid",
outline: { // autocasts as new SimpleLineSymbol()
color: "white",
width: 1
}
}
});
this.view.graphics.add(graphic);
console.log(graphic.geometry.toJSON());
}
その他の文章元の作者のリンク