For e.g:
I have added graphics layer to show buffer from custom widget
this._bufferLayer = new GraphicsLayer({
"id": "bufferGraphicsLayer"
});
this.map.addLayer(this._bufferLayer);
Steps to reproduce:
1: Open app with widget configured in edit mode
2: Add Graphics to graphics layer
3: Open the widget configuration settings page
4: Click ok to save settings
5: Draw a new Graphics on the buffer layer and notice the graphics is not drawn
Where as, if we add graphics layer without id's and try the same steps this issues is not reproducible. This seems to be an issue with the reloading of the app in the builder mode after editing. Also i tried to access the graphics layer in the postCreate method after aditing and that layer is already available in map.
So i think WAB - Builder mode is not removing the graphics layer after editing, which it should.
Solved! Go to Solution.
Sumit,
Yes if you add a GL in your widget you should remove it in the destroy method (this is not a method that exists unless you specifically add it) of your widget. The WAB builder will not handle this automatically for you. I do this in most of my widgets.
Sumit,
What error are present in your browsers web console after you see this issue?
So i think WAB - Builder mode is not removing the graphics layer after editing, which it should.
A GL is not remove from the map unless you have to to tell it to do so.
I don't see any error in console, but the graphics are not drawn on the layer.
Sumit,
It is something in your code then as I add GLs in widgets all the time with id propeties.
Robert,
Attached is the demo sample.
1. Open WAB in edit mode (WAB in builder mode)
2. Open Demo Widget
3. Click on map to add graphics
4. now edit the demo widget settings
5. click ok to save
6. Demo widget is open, now click on map to add graphics. Notice graphics are not visible on map.
- Now open widget.js and and comment line no 24, and perform the above mentioned steps again. Now issues is not reproducible.
Sumit,
Your issue makes since seems how you are adding a GL in the startup function which will get fired again (possible multiple times) when you edit the widgets settings and thus adds multiple GLs with the same ID. you should really create the GL in the postCreate or check for the GLs existance before adding it.
Robert,
Although when i tried to add the layer from postCreate it is still reproducible. Yes I can check for the layer id exist in the map and remove it, but i was thinking it should be handled by the Builder when it is reloading the map after edit it should remove all the graphics layer form the map otherwise every widget adding graphics layer will face the same issue.
Thanks for your inputs.
Sumit,
Yes if you add a GL in your widget you should remove it in the destroy method (this is not a method that exists unless you specifically add it) of your widget. The WAB builder will not handle this automatically for you. I do this in most of my widgets.