Disable duplicate items in the legendpanel

334
0
09-26-2013 01:12 AM
roybaer
New Contributor
Hello !
I have a problem with duplicate items in the legend panel!
[ATTACH=CONFIG]27777[/ATTACH]

I have PointFeatureLayer as Shapefile in ArcMap. I had group these features by an attribute in the Menu :
Properties-Symboloy-Categories-Match to Symbols in a style

After that, i have published this as mapservice.
Have i choose the wrong settings in the Service Editor or is that a problem in my sourcecode?

Here is my Code from my featurelayer:

[HTML]// Feature Layer
        var msFeatureLayer = new esri.layers.FeatureLayer("url",{
            mode: esri.layers.FeatureLayer.MODE_SELECTION,
            outFields: ["*"],
            infoTemplate:new esri.InfoTemplate({
                title:"<b>infos</b>",
                content:"<b>Code:</b>${Code}<br/>" 
            }),
            displayOnPan:true,
            visible:true,
            opacity:1.0
        });[/HTML]

And here i adding the layer to the map and to the legend:

[HTML]legendLayers.push({layer:msFeatureLayer,title:'Ms'});
        map.addLayers([msFeatureLayer]);

        // control when add a Layer to the map
        dojo.connect(map,'onLayersAddResult',function(results){
            // Activate all Features from a Feature Layer
            showFromFeatureLayer(msFeatureLayer,"1=1");


            // Legend init
            new esri.dijit.Legend({
                map:map,
                layerInfos:legendLayers
            },"legendDiv").startup();

            // Add Checkboxes with label
            dojo.forEach(legendLayers, function(layer){        
                var checkBox = new dijit.form.CheckBox({
                    name: "checkBox" + layer.layer.id,
                    value: layer.layer.id,
                    checked: layer.layer.visible,
                    onChange: function(evt) {
            var clayer = map.getLayer(this.value);clayer.setVisibility(!clayer.visible);
                           this.checked = clayer.visible;
                    }
                });
                dojo.place(checkBox.domNode,dojo.byId("toggle"),"after");
                dojo.place("<br />",dojo.create('label',{'for':checkBox.name, innerHTML:layer.title},checkBox.domNode,"after"),"after");
            });
        });[/HTML]

Thanks for your help!
0 Kudos
0 Replies