AnsweredAssumed Answered

how to stop  move  when  reshape graphic with sketchviewModel?

Question asked by yanasdf789 on Oct 15, 2019
Latest reply on Oct 17, 2019 by kenbuja

i  want to  remove    move event  when reshape   graphic  with  SketchViewModel ,how to do?

view.when(function() {
// Query all buffer features from the school buffers featurelayer
bufferLayer.queryFeatures().then(function(results) {
buffers = results.features[0].geometry;
});

// Add the boundary polygon and new lot polygon graphics
addGraphics();

// Create a new instance of sketchViewModel
sketchViewModel = new SketchViewModel({
view: view,
layer: graphicsLayer,
updateOnGraphicClick: true,
defaultUpdateOptions: {
// set the default options for the update operations
toggleToolOnClick: false // only reshape operation will be enabled
}
});

// Listen to sketchViewModel's update event to do
// graphic reshape or move validation
sketchViewModel.on(["update", "undo", "redo"], onGraphicUpdate);
});

function onGraphicUpdate(event) {
// get the graphic as it is being updated
const graphic = event.graphics[0];
// check if the graphic is intersecting school buffers or is
// still contained by the boundary polygon as the graphic is being updated
intersects = geometryEngine.intersects(buffers, graphic.geometry);
contains = geometryEngine.contains(boundaryPolygon, graphic.geometry);

// change the graphic symbol to valid or invalid symbol
// depending the graphic location
graphic.symbol =
intersects || !contains ? invalidSymbol : validSymbol;

// check if the update event's the toolEventInfo.type is move-stop or reshape-stop
// then it means user finished moving or reshaping the graphic, call complete method.
// this will change update event state to complete and we will check the validity of the graphic location.
if (
event.toolEventInfo &&
event.toolEventInfo.type === "reshape-stop"
) {
if (contains && !intersects) {
//sketchViewModel.complete();
}
} else if (event.state === "cancel" || event.state === "complete") {
// graphic moving or reshaping has been completed or cancelled
// if the graphic is in an illegal spot, call sketchviewmodel's update method again
// giving user a chance to correct the location of the graphic
if (!contains || intersects) {
sketchViewModel.update([graphic], { tool: "reshape" });
}
} else if (
event.toolEventInfo &&
event.toolEventInfo.type === "move-start"
) {
// How to  stop  move  here?
return;
} else if (
event.toolEventInfo &&
event.toolEventInfo.type === "move"
) {

return;
} else if (
event.toolEventInfo &&
event.toolEventInfo.type === "move-stop"
) {

return;
}
}

Outcomes