Legend from JSON Object

1956
5
05-10-2012 05:40 AM
demdeberanz
New Contributor II
Hi everybody,

Is it possible to create a legend of a specific layer belonging to a dynamic map service layer using the json object returned from the web map service's rest interface?
(accessible from .../<map service name>/MapServer/legend ....)

Thank you very much.
0 Kudos
5 Replies
ShreyasVakil
Occasional Contributor II
0 Kudos
demdeberanz
New Contributor II
See if this helps!

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/legend.htm


Hi Svakil,
   thank you for your reply. I've already checked out that example but I couldn't get anything useful. Because what I need is to draw a legend only for certain layer accessible from the DynamicMapServiceLayer I'm using. What I'm able to do is to draw all the legends from all the layers of the DynamicMapServiceLayer or I manage to draw the legend of a single FeatureLayer but I can not draw selectively the legend of the layers accessible from the DynamicMapServiceLayer.

Any ideas???

Many thanks.
0 Kudos
ShreyasVakil
Occasional Contributor II
Can you post some code?
0 Kudos
demdeberanz
New Contributor II
Can you post some code?

I haven't got any code 🙂 the only code I used is the one of the link you have given.
Thank you very much.
0 Kudos
demdeberanz
New Contributor II
Hi guys,
   I succeeded in creating legend for single specific layers with the template picker. But now I not able to show it. Better, I can show one legend in one div but if create as many divs as I need no one legend is displayed (firebug display in gray the html code of the legend div ). Why?


layers2.push(new esri.layers.FeatureLayer(****************));
              
              dojo.connect(layers2[0], "onLoad", function (lay) {
                  
                  var symbols2 = dojo.map(lay.renderer.infos, function (info) {
                      return { label: info.label,
                          symbol: info.symbol
                      };
                  });
                  var wdg3= new esri.dijit.editing.TemplatePicker({
                      //featureLayers: lay,
                      items: symbols2,
                      rows: 2,
                      columns: 2,
                      showTooltip: true,
                      style: "height: 100px !important; width: 300px !important;"
                  }, "testLegend2");

                  wdg3.startup();



Thank you all very much
0 Kudos