Hi,
I want to restrict the sketch from sketch widget with the polygon boundary. I'm aware that we can get the geometry with event of click
sketch.on("create, (event) => {
if(!(geometryEngine.within(event.graphic.geometry, polygon))) {
return;
}
});
but I'm still able to create feature outside the polygon boundary.
Thanks
Hello @SaiPeketi,
I was able to get this working by creating a polygon graphic and deleting the sketched graphic when it is not within that polygon. One important note, the default spatial reference for the Sketch widget is 102100, so make sure the boarder polygon has the same spatial reference.
Here is the sample I created, hopefully this is helpful.
https://codepen.io/MarkW1/pen/xxNORZm