how to disable duplicate items in the legend for ArcGIS JavaScript API

المشرف العام

Administrator
طاقم الإدارة
I have a problem with duplicate items in the legend panel!



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:"infos", content:"Code:${Code}
" }), 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("
",dojo.create('label',{'for':checkBox.name, innerHTML:layer.title},checkBox.domNode,"after"),"after"); }); });thanks for your help !



أكثر...
 
أعلى