I am trying to remove a couple elements from my webmap legend (the rest service title and the world map).

enter image description here

Here is what my legend code looks like:

var legend = new Legend({
     map: map,
}, "legendDiv");

This is how I set up my D_ml.visible layers :

C_ml = new ArcGISDynamicMapServiceLayer("http://imcltpdarcp01.duke-energy.com/ArcGIS/rest/services/TEST_DEC_DEI/MapServer");//,{opacity: 0.6};

D_ml = new ArcGISDynamicMapServiceLayer("http://imcltpdarcp01.duke-energy.com/ArcGIS/rest/services/TEST_DEC_DEI/MapServer",{opacity: 0.75});



1 Answer 1


You can made this either :

  1. Using JS by seting the layer title to blank string , and this after add all layers to map :

    map.on("layers-add-result", function (evt) {
      // custom layer info  
      var layerInfo = arrayUtils.map(evt.layers, function (layer, index) {
         return {layer:layer.layer, title:" "};
      if (layerInfo.length > 0) {
         var legend= new Legend({
            map: map,
            layerInfos: layerInfo
        }, "legendDiv");

Ps:You need to import dojo/_base/array (named here arrayUtils in callback function)

  1. Or simply Using Css Styling by setting the class to display:none :

    .esriLegendServiceLabel {
  • The second option worked to remove the titles, thank you. However is there a way to remove the basemap entirely from the legend? It is separate from my D_ml.visiblelayers layer. Jan 19, 2017 at 12:32
  • @EthanHeidtman note that the first methode removes the Basemap from legend , just import required class (array , does it throws error ? ) Jan 19, 2017 at 13:00
  • layerInfos define all layer used to render Legend , so Basemap wont be rendred , if you have any issue please tell me Jan 19, 2017 at 13:36
  • The first method did work! I needed to delete my cookies and whatnot. thank you so much!! @bRIMOsBor Jan 19, 2017 at 14:21
  • I'm so glad it helps you :) Jan 19, 2017 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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