Nianwei Liu. Good morning:
Does your TOC support WMS Layer? How could I make the legend of its layers in a WMS Layer?
Thank you very much and forgive for the inconvenience.
Specifically, I use the dijit / TOC of this example:
http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109
Thank you very much for your answer.
And forgive for the inconvenience, but when I asked the question do not specify that it is for version 3.x
Here is an example of using a WMS layer with a Legend and a LayerList widget.
https://codepen.io/noash/pen/eaNLjK
When you add the WMS layer you point to the URL for the legend image:
<SPAN class="comment token">// Typical usage</SPAN> <SPAN class="keyword token">var</SPAN> layer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">WMSLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN> url<SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">// url to the service,</SPAN> sublayers<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">{</SPAN> name<SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">// name of the sublayer,</SPAN> legendUrl<SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">// url to the legend</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.