Hey. After selecting Map from Editor I get the following error when I want to editorwidget.destroy()error message: _E.DISCONNECT IS NOT A FUNCTION
When I call destroy() and recreate after, got following error:Unable to draw graphic (geometry:null, symbol:null): Tried to register widget with id==templateDiv but that id is already registered.
I had experienced the same problem. From what I can tell in testing, the solution is to called <yourEditorWidget>.destroy() successfully. In addition, create the template and editor divs dynamically in the DOM using the tools of your choice. In dojo...var contentHolder = "<div id='templateDiv'></div><div id='editorDiv'></div>"; dojo.place(contentHolder, "LogOccurrence", "first");Include this code prior to or during your creation of the editor-related objects. To deactivate editing or recreate the editing stuff upon opening a container, for example, just call <yourEditorWidget>.destroy();Using static divs in the page prevented the editor from reappearing after a destroy. I could see the editor initially but not after destroy. I believe the destroy operation blows away the domNodes associated with the static divs.
var contentHolder = "<div id='templateDiv'></div><div id='editorDiv'></div>"; dojo.place(contentHolder, "LogOccurrence", "first");
dijit.registry.forEach(function(w){ w.destroy(); });
function openEdit(){ editLayersAdded = dojo.connect(map,'onLayersAddResult',addEditor); StructurePoints = new esri.layers.FeatureLayer(STRUCTPOINTSERV, { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"] }); RecPolygon = new esri.layers.FeatureLayer(RECPOLYSERV, { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"] }); map.addLayers([StructurePoints,RecPolygon]); } function closeEditor(){ if(editIsOn){ dojo.disconnect(editLayersAdded); map.removeLayer(StructurePoints); map.removeLayer(RecPolygon); myEditor.destroy(); } } function addEditor(r){ var contentHolder = "<div id='editorDiv'></div><div id='tmpDiv'></div>"; $j('##editDiv').append(contentHolder); var templateLayers = dojo.map(r,function(result){ return result.layer; }); var widget = new esri.dijit.editing.TemplatePicker({ featureLayers: templateLayers, grouping: true, rows: 'auto', columns: 3 },'tmpDiv'); widget.startup(); var layers = dojo.map(r, function(result) { return {featureLayer:result.layer}; }); var settings = { map: map, templatePicker: widget, geometryService: new esri.tasks.GeometryService(GEOSERVICE), layerInfos:layers, toolbarVisible: true, createOptions: { polylineDrawTools:[ esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYLINE], polygonDrawTools: [ esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYGON, esri.dijit.editing.Editor.CREATE_TOOL_CIRCLE, esri.dijit.editing.Editor.CREATE_TOOL_TRIANGLE, esri.dijit.editing.Editor.CREATE_TOOL_RECTANGLE ] }, toolbarOptions: { reshapeVisible: true } }; var params = {settings: settings}; myEditor = new esri.dijit.editing.Editor(params,'editorDiv'); myEditor.startup(); }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.