When using the legend widget (esri JAPI 3.20), not all the layers show up when my map loads. I have to zoom a level first then they all show up. Any fixes?
got it to work by adding refresh.
var legend = new Legend({ map: map, layerInfos: layers
}, "legendDiv"); map.on ("layer-add-result", function(){ legend.refresh(); legend.startup(); })
Can you share your code, how you have initialize the Legend widget.
var legend = new Legend({ map: map, layerInfos: layers, }, "legendDiv"); legend.startup();
I think problem lies in my array of featurelayers being used for layerlist. I tried the legend.refresh() code but it didn't help
Wait until the map loads all your layers before adding the legend
map.on("layers-add-result", function () { var legend = new Legend({ map: map, layerInfos: layers }, "legendDiv"); legend.startup() });<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Ken
I don't get a legend showing in the div now.
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.