My attempted on using the UndoManager has been unsuccessful for a couple days and I'm stuck.
I did not setup a proxy.
I create a FeatureLayer object in memory with
var drawingPointLayer = new esri.layers.FeatureLayer(featureCollection, {
id: "drawPointLayer",
mode: esri.layers.FeatureLayer.MODE_ONDEMAND
});
mapApp.map.addLayer(drawingPointLayer);
created UndoManager and button to perfom undo redo actions
undoManager = new esri.UndoManager({maxOperations:50});
var undoButton = new dijit.form.ToggleButton({
id: "undoButton",
showLabel: false,
iconClass: "dijitEditorIcon dijitEditorIconUndo",
onClick: function(){
undoManager.undo();
checkUndoRedoState();
mapApp.map.graphics.graphics.splice(mapApp.map.graphics.graphics.length-1, 1);
mapApp.map.graphics.redraw();
alert(undoManager.length + " | " + mapApp.map.graphics.graphics.length);
}
}, "undoButton");
var redoButton = new dijit.form.Button({
id: "redoButton",
showLabel: false,
iconClass: "dijitEditorIcon dijitEditorIconRedo",
onClick: function(){
undoManager.redo();
checkUndoRedoState();
}
}, "redoButton");
and add operation to UndoManager
function addToUndoManager(graphic, task){
var operation;
var featureLayer = mapApp.map.getLayer("drawPointLayer");
//var featureLayer = mapApp.map.getLayer("landuseLayer");
if(task=="add"){
featureLayer.applyEdits([graphic], null, null, function() {
operation = new esri.dijit.editing.Add({
featureLayer: featureLayer,
addedGraphic: graphic
});
});
}
if(operation)
undoManager.add(operation);
checkUndoRedoState();
alert(undoManager.canUndo + " | " + undoManager.canRedo + " | " + operation.label + " | " + operation.type + " | " + undoManager.length + " | " + mapApp.map.graphics.graphics.length);
}
New point markers would be added to the map via mouse click. Undomananger would register. But when I press the undo button, the graphics on the map would not disappear.
I'm clueless on what to do next to solve this problem.
Please Help