I'm looking to restrict the size of a polygon that a user can create with the sketch tool based on current extent. I can calculate the distance between lat and lon, but I will need an event that I can monitor while the polygon is being drawn.
const sketchLayer = new GraphicsLayer();
sketchViewModel = new SketchViewModel({
view: view,
layer: sketchLayer,
pointSymbol: pointSymbol,
polylineSymbol: polylineSymbol,
polygonSymbol: polygonSymbol,
snappingOptions: {
enabled: true,
featureSources: [{ layer: sketchLayer, enabled: true }],
},
mode: 'click',
defaultCreateOptions: {
hasZ: false,
enableScaling: false,
enableRotation: false,
toggleToolOnClick: false,
shapeOperation: 'none',
},
updateOnGraphicClick: false,
});
sketchViewModel.on('create', (event) => {
if (event.state === 'complete') {
// know if the polygon dimensions are valid size before getting here.
}
});