Select to view content in your preferred language

Get UI to respond to change in visibleElements.createTools

242
0
01-18-2023 08:39 AM
nevvo
by
Emerging Contributor
Hello there,
I have a map that I am constructing as part of a jQuery widget and that map has the sketch controls on it and is configured as below (partial snippet but gets the idea across) :

 

esriConfig.portalUrl = this.options.portalUrl;
this.graphicsLayer = new GraphicsLayer();
// create the webmap using the desired portal id
this.webMap = new WebMap({
    portalItem: {
        id: this.options.portalId
    },
    layers: [this.graphicsLayer]
});
this.view = new MapView({
    container: mapContainerId,
    map: this.webMap
});
this.sketch = new Sketch({
    layer: this.graphicsLayer,
    view: this.view,
    visibleElements: {
        createTools: {
            "circle": this.options.createTools.circle,
            "point": this.options.createTools.point,
            "polygon": this.options.createTools.polygon,
            "polyline": this.options.createTools.polyline,
            "rectangle": this.options.createTools.rectangle
        },
        selectionTools: {
            "lasso-selection": false,
            "rectangle-selection": false,
        },
        settingsMenu: this.options.settingsMenu,
        undoRedoMenu: this.options.undoRedoMenu
    }
});
this.view.ui.add(this.sketch, this.options.controlsPosition);

I have a method on the widget that I can then call that changes the visibility of the createTools based on the name of the tool passed in:

toggleTool: function (tool, value) {
    this.sketch.visibleElements.createTools[tool] = value;
    //what to call here!?!
}

Then I call it as per:

$("#map").mapcontrol("toggleTool", "circle", true);

The circle value gets toggled to true as expectedIf I then click the tool bar or the zoom in / zoom out icons on the map after toggling the value then the circle tool appears.

The thing I am struggling with and I'm sure it is going to be something really simple is what method to call to get the tool UI to refresh after the tool gets toggled?

I've tried calling various methods but have not been able to work out the correct way to do it.

Thanks 

 

0 Kudos
0 Replies