schlot

Basic example for scaledependent renderer for labelLayer

Discussion created by schlot on Jun 26, 2014
Is there some limitation on using a scaleDependentRenderer and a featureLayer/LabelLayer?   I could find no examples for scaleDependentRenderer, just the API reference.   I have a labelLayer defined using the LabelLayer example, but thought it would be useful to have a different size font on my county names depending on the view scale.  I have my ScaleDependentRenderer defined using my two different SimpleRenderers, but it seems to be ignoring the scale, drawing the same size for all.  I do see the featureLayer of county boundaries and labels, just not the scale behavior I expected.  I've tried both minScale/maxScale and minZoom/maxZoom types of syntax. 

This is my first time using both scaleDependentRenderers and LabelLayers, maybe I'm misunderstanding how they're used. 
var pathName = "https://ogi.oa.mo.gov";
 var countyFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NULL, 
        new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([149,149,149]), 2)); 
        
        var countyLayer = new FeatureLayer(pathName + "/ArcGIS/rest/services/BaseMap/county_simple/MapServer/0", {
        id: "countyLayer",
        mode: FeatureLayer.MODE_ONDEMAND,
        outFields: ["COUNTYNAME"]
      });
     
     on(map,'extent-change', function() {
//populates a div tag I have set right above the map to see what the current scale is
       dom.byId('scaleDiv').innerHTML = "map scale: " + map.getScale() + "   level: " + map.getLevel();
     });

      var countyRenderer = new SimpleRenderer(countyFillSymbol);
      
        var countyColor = new Color("#666");
        var countyLabel_sm = new TextSymbol();
        countyLabel_sm.setColor(countyColor);
        countyLabel_sm.font.setSize("5pt");
        countyLabel_sm.font.setFamily("arial");
        
        var countyLabelRenderer_sm = new SimpleRenderer(countyLabel_sm);
        
        var countyLabel_lg = new TextSymbol();
        countyLabel_lg.setColor(countyColor);
        countyLabel_lg.font.setSize("20pt");
        countyLabel_lg.font.setFamily("arial");
        
        var countyLabelRenderer_lg = new SimpleRenderer(countyLabel_lg);
        
        var countyLabelScaleRenderer = new ScaleDependentRenderer({
          rendererInfos: [{
            renderer: countyLabelRenderer_sm,
            maxScale: 5000000,
            minScale: 1900000        
          }, {
            renderer: countyLabelRenderer_lg,
            maxScale: 1800000,
            minScale: 10000
          }]
        });
                  
     var labels = new LabelLayer({ id: "labels" });
     labels.addFeatureLayer(countyLayer, countyLabelScaleRenderer, "${COUNTYNAME}");
      map.addLayers([countyLayer, labels]);

Outcomes