jadamssl

FeatureLayer won't label

Discussion created by jadamssl on Apr 7, 2014
Can someone please help me? I can't seem to get the code for the featureLayer labels to work. Any assistance would be greatly appreciated.

dojo.require("dijit.layout.ContentPane");
      dojo.require("esri.layers.FeatureLayer");
      dojo.require("esri.dijit.InfoWindow");
      dojo.require("dojox.charting.Chart2D");
   dojo.require("dojox.charting.Chart");
   dojo.require("dojox.charting.axis2d.Default");
      dojo.require("dojox.charting.plot2d.Pie");
   dojo.require("dojox.charting.plot2d.Columns");
      dojo.require("dojox.charting.action2d.Highlight");
      dojo.require("dojox.charting.action2d.MoveSlice");
      dojo.require("dojox.charting.action2d.Tooltip");
      dojo.require("dojo.number");
      dojo.require("dijit.layout.TabContainer");
     dojo.require("esri.map");
   dojo.require("esri.arcgis.utils");
   dojo.require("esri.symbols.SimpleLinesSymbol");
   dojo.require("esri.symbols.SimpleFillSymbol");
   dojo.require("esri.symbols.TextSymbol");
   dojo.require("esri.renderers.SimpleRenderer");
   dojo.require("esri.renderers.ScaleDependentRenderer");
   dojo.require("esri.layers.LabelLayer");
   dojo.require("dojo._base.Color");

function init() {

        //use the info window instead of the popup 
        var infoWindow = new esri.dijit.InfoWindow(null, dojo.create("div"));
        infoWindow.startup();

  map = new esri.Map("map", {
          basemap: "streets",
          center: [-96, 37],
          infoWindow: infoWindow,
          zoom: 4
        });

  var storeColor = new Color ("#666");
  
        var template = new esri.InfoTemplate();
        //flag icons are from http://twitter.com/thefella, released under creative commons
        template.setTitle("Store <b>${StoreNum}</b>");
        template.setContent(getWindowContent);
  
        //var storesLayer = new esri.layers.FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5", {
  var storesLayer = new esri.layers.FeatureLayer("http://gis-server.greatriv.com/ArcGIS/rest/services/ShamrockMktg/StoreLocations/MapServer/0", {
          mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
          outFields: ["*"],
    infoTemplate: template,
        });
  
  
        var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE,9,new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
   new dojo.Color([0,0,0]), .5),
   new dojo.Color([0,92,230]));
        storesLayer.setRenderer(new esri.renderer.SimpleRenderer(symbol));
  
        map.addLayer(storesLayer);
  
  var storesLabel = new TextSymbol().setColor(storeColor);
  storesLabel.font.setSize("9pt");
  storesLabel.font.setFamily("verdana");
  storesLabelRenderer = new SimpleRenderer(storesLabel);
  
  var storesScaleDependent = new ScaleDependentRenderer({
     rendererInfos: [{
         renderer: storesLabelRenderer,
      minScale: 1000000,
      maxScale: 1
    }]
     })
    var labels = new LabelLayer({ id: "labels"});
    labels.addFeatureLayer(storesLayer, storesScaleDependent, "${StoreNum}");
    map.addLayer(labels);
    

        map.infoWindow.resize(675, 475);
      
   }

Outcomes