Add/remove drawBox tools after creation

680
2
Jump to solution
07-08-2021 04:48 AM
Labels (1)
MattiasEkström
Occasional Contributor III

I'm building a widget where the user should be able to draw custom areas/polygons. I use the DrawBox dijit and limit the tools to "POLYGON" and "EXTENT" on creation (declarativ creation).

My html tag looks like this:

<div data-dojo-attach-point="drawBox" data-dojo-type="jimu/dijit/DrawBox" data-dojo-props='geoTypes:["POLYGON","EXTENT"],showClear:true,deactivateAfterDrawing:false' style="margin-top: 10px;"></div>

 

So far it's all good, but I also want to give the user the possibility to apply a buffer, and when the user checks a checkbox for applying buffer I want to modify the drawBox to allow the user to draw a polyline or point as well since the buffer will make it a polygon.
I've looked at the DrawBox.js and can't seem to find a suitable method for this, tried just change the value of this.drawBox.geoTypes but with no succes.

Anyone know if this is possible?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

@MattiasEkström After you have set the geoTypes in code then you just have to call the _initTypes() method on the drawBox.

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

@MattiasEkström After you have set the geoTypes in code then you just have to call the _initTypes() method on the drawBox.

MattiasEkström
Occasional Contributor III

Thanks Robert! It works great!

0 Kudos