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");
 });
 });
Midavalo
30k11 gold badges53 silver badges108 bronze badges
asked Sep 25, 2013 at 7:57
8
  • 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. Commented Sep 25, 2013 at 8:17
  • Welcome to SE.GIS !! Please check the layer first. Check mxd in ArcMap identify the duplicate values. Commented Sep 25, 2013 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. Commented Sep 25, 2013 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. Commented Sep 25, 2013 at 13:04
  • thanks @Craig ! what should i look for by the service settings? Commented Sep 25, 2013 at 13:31

1 Answer 1

0

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.

answered Jul 9, 2014 at 13:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.