1

When dragging a polygon vertex using the Sketch class, the update event is fired, with a type of "reshape".

4X:

sketch.on("update", onGraphicUpdate);
    
function onGraphicUpdate(event) {
      if (event.toolEventInfo && event.toolEventInfo.type === "reshape") {
        console.warn(toolEventInfo);
        //this does not seem to have any info about the vertex being dragged, even though we have the 
        //polygon 
      }
}

Previously in 3x, we could grab a vertexInfo object off of that type of event (vertex-move), which contained the pointIndex and segmentIndex of that vertex.

3X:

editToolbar.on('vertex-move',function(evt){
   console.log(evt.vertexInfo.pointIndex);
});

Does anyone know if pointIndex and segmentIndex exist anywhere, or how to decipher/identify which vertex within the polygon is actively being moved?

1 Answer 1

0

toolEventInfo.selected

This does not seem to be documented anywhere (as of 4.18, even if using the 4x typings), but through debugging, I was able to find pathIndex (previously segmentIndex) and pointIndex in the event fired from sketch.update

sketch.on("update", (event) => {
    const toolEventInfo = event.toolEventInfo;
    if (toolEventInfo && toolEventInfo.type === "reshape") {
        //reshape event types should have a "selected" prop containing info about the 
        //vertex being edited
        const { pathIndex, pointIndex } = event.toolEventInfo.selected[0].attributes;
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.