Sketch Widget : disabling tools and draw options

1296
1
Jump to solution
05-07-2021 11:50 AM
RachelPower
New Contributor

I’m trying to code the Sketch widget (4.x) to only display the rectangle draw tool on my map. I want the ability to limit the tool to just draw one graphic at a time. 

Displaying the rectangle draw tool was easy to do, however, trying to remove the ability to draw multiple graphics at a time is my current issue with this widget. 

I also noticed when I click on the drawn graphic after drawing the rectangle, the scaling boxes change to vertices, but I don’t want that as an option for my rectangle graphics, and I am unable to find the event that removes the vertices. 

Does anyone know how to  limit the tool to just draw one graphic at a time and remove the vertices from the graphic?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

This should give you the options you're looking for

const sketch = new Sketch({
  layer: graphicsLayer,
  view: view,
  availableCreateTools: ["rectangle"],
  creationMode: "single",
  defaultUpdateOptions: {
    tool: "move"
  }
});

 

View solution in original post

1 Reply
KenBuja
MVP Esteemed Contributor

This should give you the options you're looking for

const sketch = new Sketch({
  layer: graphicsLayer,
  view: view,
  availableCreateTools: ["rectangle"],
  creationMode: "single",
  defaultUpdateOptions: {
    tool: "move"
  }
});