problem creating label layer

1149
1
11-26-2014 09:20 AM
TracySchloss
Frequent Contributor

I have created a labelLayer before, but today I'm having problems.  This layer has an alias on the field name, which might be causing the problem.  I've tried both the name and the alias, but my feature layer still doesn't have any labels. 

  var countyLayer = new FeatureLayer(pathName + "/ArcGIS/rest/services/BaseMap/county_simple/MapServer/0", 
     {id:'countyLayer', visible:true});     
      districtLayer = new FeatureLayer(pathName+"/ArcGIS/rest/services/DESE/Education/MapServer/3",{
        id:'districtLayer', 
        infoTemplate:generateInfoTemplate,
        outFields : ['*']}); 
     buildingLayer = new FeatureLayer(pathName+"/ArcGIS/rest/services/DESE/Education/MapServer/0", 
      {id:'buildingLayer',
      infoTemplate:generateInfoTemplate,
      outFields : ['*']});


  var districtText = new TextSymbol();
    districtText.setColor(new Color("#666"));
    districtText.font.setSize("8pt");
    var districtLabelRenderer = new SimpleRenderer(districtText);
    var districtLabelLayer = new LabelLayer({ id: "districtLabels" });
    districtLabelLayer.maxScale = 1155582;
    // tell the label layer to label the counties feature layer 
    districtLabelLayer.addFeatureLayer(districtLayer, districtLabelRenderer, "{District Name}");//the alias name
    map.addLayers([countyLayer, districtLayer, buildingLayer, districtLabelLayer]);
0 Kudos
1 Reply
by Anonymous User
Not applicable

When I have troubles like this I start by printing the featureLayer.fields object to the console log of my browser so I can see what the app thinks the actual field name should be. Usually I copy and paste the name, not alias, right from this output.

console.log(districtLayer.fields);

0 Kudos