Hi,
I am looking for a way to undo edits such as move, scale and rotate of existing graphics on the map. So far I've tried to undo it in the same way as we currently undo 'draw' operations:
var editToolbar = new Edit(map); editToolbar.on("scale-stop, vertex-move-stop", function (evt) { var operation = new CustomOperation.Add({ graphicsLayer: selectedGraphicsLayer, addedGraphic: evt.graphic }); undoManager.add(operation); });
However this undoes the action that happened directly previous to the 'edit', which in our case was 'draw' and removes the graphic from the map. Am I missing something or should I be using a different method altogether?
I'm using following classes:
Edit - Edit | API Reference | ArcGIS API for JavaScript
UndoManager - UndoManager | API Reference | ArcGIS API for JavaScript
Hi Vygintas, Have you tried to look up this sample? https://developers.arcgis.com/javascript/jssamples/graphics_undoredo.html
Hi Yue,
Unfortunately the example you're referring to performs undo on a draw of a new graphic. I am looking to undo an edit to an existing graphic.
I have a feeling this can't be done with the undo manager.
Maybe what you can do is, save the current graphic, once it has been edited and you don't like the current graphic, delete it and add the saved graphic?
Hi Tim,
That's a good idea, if undo manager for sure cannot be used in this case, I will go ahead with your suggestion. Perhaps Yue or someone else from ESRI staff could confirm this?
I just have points, and it works to undo a move. There'd be no scale or rotate with those, though. I was disappointed to see that undo/redo didn't include attribute changes.