Select to view content in your preferred language

legend does not refresh

1540
2
01-10-2011 12:19 PM
GabiVoicu
Deactivated User
I'm using version 10 or lower and my map services are publicly accessible
API Reference says:
" The legend automatically updates if the visibility of a layer or sublayer changes."
...but it does not seem to work in my example pasted here
http://maps.collincountytx.gov/maincomiss_jan1.html

It does draw the legend for the one layer turned on on start-up but then it never refreshes?!
I'm not using any layersInfo
"Calling refresh is only necessary when layerInfos is used in the Legend constructor, otherwise the legend will refresh the layers automatically."

Thank you for any suggestions
0 Kudos
2 Replies
PauPérez_Puigcerver
Emerging Contributor
Hello,

You have to call the function

legend.refresh();

in the click event of checkbox that make the sublayer on/off.
Only updates automatically when call layer.show() or layer.hide();

Regards.

Pau
0 Kudos
AdrianMarsden
Honored Contributor
Hi

I'm using the sample code to creat my legend

        //add the legend
        dojo.connect(map,'onLayersAddResult',function(results){
          var layerInfo = dojo.map(results, function(layer,index){
            return {layer:layer.layer,title:layer.layer.name};
          });
          if(layerInfo.length > 0){
            var legendDijit = new esri.dijit.Legend({
              map:map,
              layerInfos:layerInfo
            },"legendDiv");
            legendDijit.startup();
          }


So I would have thought that in my function that sets visibly of sublayers I would add

legendDijit.refresh()

But this just erors with

Uncaught ReferenceError: legendDijit is not defined


Friday night - I'm off home - which means I'll realize what I've done wrong at about 03:00 😄

ACM
0 Kudos