Dynamically add/remove points from polygon shape

Hi, I’m evaluating GoJS and one of the features I’m trying to implement is the ability for the user to change a polygon’s geometry by adding/removing points and changing position of points.

I’m looking at the Geometry Reshaping sample and it handles the second part (changing position of points). However, can you point me in the right direction for adding/removing points dynamically?

Basically I want to be able to Cmd/Ctrl+Click on a path segment to add a new point or click on a point adornment (highlight adornment) and press Del to remove. This should adjust the geometry accordingly.


Cmd/Ctrl+Click to add a new point (notice new point in red)


Any assistance would be greatly appreciated. The GoJS library is awesome and will definitely help us create a great product for our customers.

If you look at the Link.resegmentable property, a selected link shows additional handles at the middle of each segment. Dragging such a handle automatically inserts a segment (or two if orthogonal). Dragging it so that it in a straight line between two points causes the segment (or two) to automatically disappear. This has the advantage that it works on touch devices as well as with a mouse.

A similar design and implementation could be done for reshaping a Geometry. Or you could implement what you just specified.

A problem with depending on the “Delete” command (such as pressing the “Delete” key) is that it could be confusing to users who might be expecting to delete the selected nodes instead of just one point in one shape geometry. Or vice-versa: they’re expecting to modify the geometry but they accidentally delete all selected nodes and links.