I am working on arcgis map JavaScript API and i want to show map layer legend with close icon but i am unable to find legend load event to show the same. Legend along with close icon is shown in below image.

enter image description here

1 Answer 1


Create a container div first. add the close button on it. Then create a child div inside it and attach the legend to the child div.

<div id="containerDiv">
    <button type="button">X</button>
    <div id="legendDiv"><div>

var legend = new Legend({  
                map: map,  
                layerInfos: [{  
                    layer: layer1,  
                    title: "Layer1 Legend"  
            }, "legendDiv"); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.