0

I am having some problems with editing the Editor object. We have multiple layers that are editable by the user, and the user can enable and disable layers. When a layer is disable/enabled the Editor object should be modified or removed+created to make sure the layers are visible in the toolbar.

We have this method for creating the editor, but how could I modify the layers inside the editor (or templatepicker), when the object is allready initialized..

 this.addToolbar = function(map, id, layers, featureLayers) {
 if (dijit.byId(id)) { 
 //TODO Update existing editor if layers changed
 } else {
 var settings = {
 map: map,
 layerInfos: featureLayers,
 createOptions: {
 polylineDrawTools: [Editor.CREATE_TOOL_FREEHAND_POLYLINE],
 polygonDrawTools: [Editor.CREATE_TOOL_FREEHAND_POLYGON,
 Editor.CREATE_TOOL_CIRCLE,
 Editor.CREATE_TOOL_TRIANGLE,
 Editor.CREATE_TOOL_RECTANGLE
 ]
 },
 toolbarVisible: false,
 toolbarOptions: {
 reshapeVisible: true
 }
 };
 var params = {
 settings: settings
 };
 var myEditor = new Editor(params, id);
 myEditor.startup();
 }
 }

So i could store the value of myEditor, but what variable do I change, and how do I make sure it updates the html? Any ideas?

Update: This is not the way to go, when i destroy a editor, the elements that are already drawn with it are not editable anymore. I will just show and hide the editors with some plain js.

asked Feb 11, 2015 at 7:39

1 Answer 1

1

Nest your editor node in another container.

<div id="editorContainer">
 <div id="editor"> </div>
</div>

Move the settings and params before the if statement.

Then in the TODO part -

  1. destroy the editor

    myEditor.destroyRecursive();

  2. recreate the editor div in the editorContainer

    domConstruct.create("div",{id:"editor"},"editorContainer");

  3. recreate the editor

    var myEditor = new Editor(params, id);

answered Feb 11, 2015 at 16:09
1
  • Thanks for you reply. I found out that elements that are drawn with a toolbar are not editable anymore when that toolbar is re-created.. So i need to change the way the app works atm. Commented Feb 13, 2015 at 9:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.