1

I have created maps in ArcGIS for desktop and published them to ArcGIS for server 10.2.2. Because of performance issues I have created a group layer of the same map with different levels of details. They all have the exact same symbology. I add the group layer in my script as one layer. I am attempting to create a legend with it but I am not succeeding. I do get a box with the note "No Legend". This indicates to me it does not recognize my legend from my ArcGIS Server. Could anybody help me?

This question is a follow up of a previous question of me that seems to be fully answered since I am getting the legend box: Add a legend in an ArcGIS Javascript API

 <script>
        var map;
        var wmsLayer;
        var URL;
        var legend;
        require(["dojo/query", "esri/map", "esri/layers/WMSLayer", "esri/dijit/Legend", "esri/config", "dojo/domReady!"],
      function (query, Map, WMSLayer, Legend, esriConfig) {

          esriConfig.defaults.io.proxyUrl = "/proxy/proxy_gcx.php";

          map = new Map("map", {
              basemap: "topo",
              center: [5.5, 52.485],
              minZoom: 8,
              maxZoom: 13,
              zoom: 8,
              slider: true
          });

          wmsLayer = new WMSLayer("http://localhost:6080/arcgis/services/P_00_15/P_00_15/MapServer/WMSServer", {
              format: "png",
              visibleLayers: ["31", "30", "29", "28"]
          });

          map.addLayer(wmsLayer);
          map.on("layer-add", function (results) {
              //add the legend
              legend = new Legend({
                  map: map,
                  layerInfos: [{
                      layer: results,
                      title: "P_00_2013"
                  }]
              }, "legendDiv");
              legend.startup();

          });

      });
    </script>
</head>

<body>

    <div id="map"></div>

    <div id="legendDiv"></div>

</body>

1 Answer 1

1

It might work this way: at layerInfos you should add as layer your wmsLayer and not the 'results':

layerInfos: [{
    layer: wmsLayer,
    title: "P_00_2013"
}]

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.