LabelLayer using feature layer called via CreateMap?

Discussion created by benaller on Nov 4, 2013
Does anyone know if there's a way to label feature layers that are called through the arcgisUtils.CreateMap method? Perhaps there's a way to get at the operational layers in the webmap to build label layers without having to use map.addLayer for each feature layer I wish to label?    My test page seems overkill in that it's calling the same layer through both the CreateMap and through map.addLayer.  I'd like to leverage all the settings saved within my webmap, and guess I'm looking for the most efficient way of creating the labels. 


<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="//">
      html, body, #map {
        height: 100%; width: 100%; margin: 0; padding: 0; 

    <script src="//"></script>
      var map;

      ], function(Map, arcgisUtils, Extent, FeatureLayer, SimpleLineSymbol, SimpleFillSymbol, TextSymbol, SimpleRenderer, ScaleDependentRenderer, LabelLayer, Color) 
          arcgisUtils.createMap("a04f0acc513e4f8d94f008d2937bf9ab", "map").then(function(response) {
          map =;

          // create a renderer for the monitoring wells layer to override default symbology
          var MonwellColor = new Color("#666");
          //var MonwellLine = new SimpleLineSymbol("solid", MonwellColor, 1.5);
          //var MonwellSymbol = new SimpleFillSymbol("solid", MonwellLine, null);
          //var MonwellRenderer = new SimpleRenderer(MonwellSymbol);
          var Monwell = new esri.layers.FeatureLayer(
              mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
              outFields: ["PERMITID"]

          // create a text symbol to define the style of labels
          var MonwellLabel = new TextSymbol().setColor(MonwellColor);
          MonwellLabelRenderer = new SimpleRenderer(MonwellLabel);

          // scale dependent renderer for city labels
          var MonwellScaleDependent = new ScaleDependentRenderer({
              rendererInfos: [{
                  renderer: MonwellLabelRenderer,
                  minScale: 10000,
                  maxScale: 1
              var labels = new LabelLayer({ id: "labels" });
              // tell the label layer to label the monitoring wells feature layer
              labels.addFeatureLayer(Monwell, MonwellScaleDependent, "${PERMITID}");
              // add the label layer to the map
    <div id="map"></div>