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?
Solved! Go to Solution.
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()
});
Ken
I don't get a legend showing in the div now.
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();
})