5

I have a problem with duplicate items in the legend panel!

Legend

Can anyone help me? This is my feature Layer with popup info:

// 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
        });

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

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");
            });
        });
  • 1
    I'm having trouble understanding your situation. DO you have the same layer multiple times in your Map? Or are the duplicate symbols present in the Map Service itself? Without this information, just the code does not really help us understand your situation. – Devdatta Tengshe Sep 25 '13 at 8:17
  • Welcome to SE.GIS !! Please check the layer first. Check mxd in ArcMap identify the duplicate values. – Sunil Sep 25 '13 at 8:35
  • I have a PointFeature Layer in ArcMap. I have classified these about Properties-Symboloy-Categories-Match to Symbols in a style. After that I have published these Layer aus Mapservice. – roybaer Sep 25 '13 at 12:46
  • I have had this issue many times. It has been almost always due to an issue with the service. Check your service settings, restart the service and check your ArcGIS Server logs. – Craig Sep 25 '13 at 13:04
  • thanks @Craig ! what should i look for by the service settings? – roybaer Sep 25 '13 at 13:31
1

You may try inspecting the object that has your list of items and building a new one containing the single instance of the strings in the old object. This sounds like what you might be trying to do. If not, then please let me know and i will refine the approach, as appose to simply down voting me ;). The idea is to filter your object with duplicates by constructing a new one with only one copy of what you want to see in it. I hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.