view2.when(() => {
addGraphics();
const obj: any = {
view: view2,
layer: graphicsLayer,
updateOnGraphicClick: false,
snappingOptions: {
enabled: true,
featureSources: [{ layer: graphicsLayer, enabled: true }]
}
}
const sketch: any = new Sketch(obj)
sketch.on("update", (event: any) => {
if (event.state === "complete") {
const updatedLatLng: any = [];
const xyPoints = event.graphics[0].geometry.rings[0];
xyPoints.forEach((point: any) => {
const result = webMercatorUtils.xyToLngLat(point[0], point[1]);
updatedLatLng.push(result);
});
}
});
});
// Add new development polygon graphic and boundary polygon graphics
const addGraphics = () => {
const vertices: any = [];
const latlngvertices = this.updateLatLong(this.footPrintData.footprint_data);
latlngvertices.forEach((point: any) => {
const result = webMercatorUtils.lngLatToXY(point[0], point[1]);
vertices.push(result);
});
const polygon: any = {
type: "polygon",
rings: vertices,
spatialReference: view2.spatialReference
};
const validSymbol: any = {
type: "simple-fill",
style: "solid",
color: "#4472c4",
outline: {
color: "white",
width: 2
}
};=
const newDevelopmentGraphic = new Graphic({
geometry: polygon,
symbol: validSymbol
});
graphicsLayer.addMany([newDevelopmentGraphic]);
}
}