Hey everybody,
I was thinking about implementing the undomanager in my map to remove or re-add graphics.
When looking at the example page I found this:
Graphics with undo redo | ArcGIS API for JavaScript
I am able to get it to work, but I don't want to load an outside module, like they use the customoperation Does anyone have an example where all the code is within the application?
Thanks,
Tim
Solved! Go to Solution.
While this is possible (see attached) is there a particular reason why you wanted everything in a single file? This thread from a stack overflow user asks a similar question and there are some good replies.
javascript - Questions about Dojo modules from Dojo newb? - Stack Overflow
There's also some good info in the JSAPI help on creating modules: Tutorials | ArcGIS API for JavaScript
Hi Tim,
If you download the sample, the code for the module is included with it.
define([
"dojo/_base/declare", "esri/OperationBase", "esri/toolbars/navigation"
], function(declare, OperationBase, Navigation) {
var customOp = {};
customOp.Add = declare(OperationBase, {
label: "Add Graphic",
constructor: function ( /*graphicsLayer, addedGraphic*/ params) {
params = params || {};
if (!params.graphicsLayer) {
console.error("graphicsLayer is not provided");
return;
}
this.graphicsLayer = params.graphicsLayer;
if (!params.addedGraphic) {
console.error("no graphics provided");
return;
}
this._addedGraphic = params.addedGraphic;
},
performUndo: function () {
this.graphicsLayer.remove(this._addedGraphic);
},
performRedo: function () {
this.graphicsLayer.add(this._addedGraphic);
}
});
return customOp;
});
Thanks Jake, would I be able to just include that in my application or is there another step I would have to do?
While this is possible (see attached) is there a particular reason why you wanted everything in a single file? This thread from a stack overflow user asks a similar question and there are some good replies.
javascript - Questions about Dojo modules from Dojo newb? - Stack Overflow
There's also some good info in the JSAPI help on creating modules: Tutorials | ArcGIS API for JavaScript
Hey Kelly,
thanks for the quick reply and thanks for the zip file and the helpful links.
At the moment I am working on an Advanced Draw Widget and wanted to include the redo/undo function. Instead of explaining the user how to install modules, I wanted a one-stop shop That is why I wanted to include everything in one file.
Btw. let me know what you think of the widget
Tim