Select to view content in your preferred language

How to programmatically draw a sketchModel

483
2
12-13-2022 12:06 AM
Lzy
by
Emerging Contributor
I want to use the button to trigger a click event for drawing a sketchModel. Is there any good way to do this?
0 Kudos
2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

This sample shows how it can be done: https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=highlight-features-by-ge...

From the button click you call the SketchViewModel.create() method and pass in the tool name you need as shown below.

selectButton.addEventListener("click", () => {
  sketchViewModel.create("rectangle");
});


 

0 Kudos
Lzy
by
Emerging Contributor

Thank you for your answer, maybe I didn't express it clearly. I want to finish drawing the polygon when creating a polygon given a coordinate point and adding each point by clicking the button. Instead of drawing by tapping the screen.

0 Kudos