I've copied the geoprocessing widget and set it up in web appbuilder to run a geoprocessing service that asks the user for an input polygon. After a successful run I want the tool to clear the map graphics and close the widget window.
It's asynchronous so I'm editing the onJobComplete method within Widget.js.
I followed instructions here to close the widget panel and that's working successfully.
It appears the widget uses a draw tools box within the editor. I'm not sure if I should just "click" the clear button or if there is a better solution..
How can I click the button using the attach-point name btnClear?
Thanks
Solved! Go to Solution.
I can sort through all the this.map.graphicsLayerIds but I can't get anything for this.map.layers. It's undefined.
Michael,
In your widget you just call
I got an error and it shows that drawBox is undefined. What exactly is "this" referring to in this context?
Michael,
This refers to the current code scope. You need to use lang.hitch to maintain current code scope to the widget itself.
Thanks Robert,
I had to do a bit of reading on lang.hitch.
The widgets onJobComplete is called using lang.hitch(). I attempt to call this.drawBox_onClickClear() within onJobComplete but "this" has no reference to drawBox. It does have a reference to drawTools and drawTools[0] is the drawBox.
this.drawTools[0]._onClickClear() did the trick.
Is there a more elegant way to reference that?
I appreciate your help.
Actually no that is the correct way, as the GP widget can have multiple drawBox widgets it maintains them in an array unlike other widgets.
Don't forget to mark this question as answered.
Hi Michael,
Just in case you need loop layers in the map object, use this.map_layers would work.