Select to view content in your preferred language

Legend adding layer twice

782
2
05-11-2011 07:11 AM
JoshObrecht
Regular Contributor
I am having an issue when I call the line:

myLegend.layers = [event.layer]

where myLegend is just the basic ESRI legend from the API. For some reason, the layer shows up twice in the legend even though the layer is only in the map once.  Has anyone else encountered this or have a resolution?
Tags (2)
0 Kudos
2 Replies
ReneRubalcava
Esri Frequent Contributor
Not sure if it would matter, but can you verify of event.layer.loaded is true before adding it to legend? Not sure what the internals of the ESRI legend look like, but if the layers load event fires after adding it to legend, maybe it's adding it again internally.
0 Kudos
JoshObrecht
Regular Contributor
Unless I'm not following you correctly, it doesn't appear that is the case.  I tried inserting the LayerEvent.LOAD and that seemed to only run once.  I am trying to have the legend change when a layer is added.  I set an Alert directly before setting the legend and the Alert is only called once and even though the layer is only in the Legend layers array once, it shows twice.
0 Kudos