Skip to main content
edited tags
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to display Displaying labels - created using LabelLayer only at certain scales in ArcGIS API for JavaScript

I am using ESRI Javascript 3.7 framework to develop a map application, in it I am trying to display labels created using LabelLayer at certain scales only, say from 1:1 to 1:500 scale only, how.

How can I achieve this? 

I played a little with ScaleDependentRenderer but it results in 2 firebug exceptions. Not sure if the ScaleDependentRenderer is the right answer or not. So, if anyone can help, I would really appreciate.

var occupancyLabelLayer = new esri.layers.LabelLayer({ id: "labels" });
// add the label layer to the map
map.addLayer(occupancyLabelLayer);

var labelField = "FLOOR";
// create a text symbol to define the style of labels

var spaceLabelColor = new dojo.Color("red");
var spaceOccupancyLabel = new esri.symbol.TextSymbol().setColor(spaceLabelColor);
//spaceOccupancyLabel.font.setSize("14pt");
spaceOccupancyLabel.font.setFamily("arial");
var spaceOccupancyLabelRenderer = new esri.renderer.SimpleRenderer(spaceOccupancyLabel);

var spaceLabelScaleDependentRenderer = new ScaleDependentRenderer({
    rendererInfos: [{
        renderer: spaceOccupancyLabelRenderer,
        minScale: 500,
        maxScale: 1
    }]
});

occupancyLabelLayer.addFeatureLayer(featureLayer, spaceLabelScaleDependentRenderer, "${" + labelField + "}");
                

Firebug Exceptions:

1)exception in animation handler for: onEnd
http://js.arcgis.com/3.7/ (line 45)
2)TypeError: b is undefined
http://js.arcgis.com/3.7/js/esri/layers/LabelLayer.js    Line 21

How to display labels - created using LabelLayer only at certain scales

I am using ESRI Javascript 3.7 framework to develop a map application, in it I am trying to display labels created using LabelLayer at certain scales only, say from 1:1 to 1:500 scale only, how can I achieve this? I played a little with ScaleDependentRenderer but it results in 2 firebug exceptions. Not sure if the ScaleDependentRenderer is the right answer or not. So, if anyone can help, I would really appreciate.

var occupancyLabelLayer = new esri.layers.LabelLayer({ id: "labels" });
// add the label layer to the map
map.addLayer(occupancyLabelLayer);

var labelField = "FLOOR";
// create a text symbol to define the style of labels

var spaceLabelColor = new dojo.Color("red");
var spaceOccupancyLabel = new esri.symbol.TextSymbol().setColor(spaceLabelColor);
//spaceOccupancyLabel.font.setSize("14pt");
spaceOccupancyLabel.font.setFamily("arial");
var spaceOccupancyLabelRenderer = new esri.renderer.SimpleRenderer(spaceOccupancyLabel);

var spaceLabelScaleDependentRenderer = new ScaleDependentRenderer({
    rendererInfos: [{
        renderer: spaceOccupancyLabelRenderer,
        minScale: 500,
        maxScale: 1
    }]
});

occupancyLabelLayer.addFeatureLayer(featureLayer, spaceLabelScaleDependentRenderer, "${" + labelField + "}");
                

Firebug Exceptions:

1)exception in animation handler for: onEnd
http://js.arcgis.com/3.7/ (line 45)
2)TypeError: b is undefined
http://js.arcgis.com/3.7/js/esri/layers/LabelLayer.js    Line 21

Displaying labels created using LabelLayer only at certain scales in ArcGIS API for JavaScript

I am using ESRI Javascript 3.7 framework to develop a map application, in it I am trying to display labels created using LabelLayer at certain scales only, say from 1:1 to 1:500 scale only.

How can I achieve this? 

I played a little with ScaleDependentRenderer but it results in 2 firebug exceptions. Not sure if the ScaleDependentRenderer is the right answer or not.

var occupancyLabelLayer = new esri.layers.LabelLayer({ id: "labels" });
// add the label layer to the map
map.addLayer(occupancyLabelLayer);

var labelField = "FLOOR";
// create a text symbol to define the style of labels

var spaceLabelColor = new dojo.Color("red");
var spaceOccupancyLabel = new esri.symbol.TextSymbol().setColor(spaceLabelColor);
//spaceOccupancyLabel.font.setSize("14pt");
spaceOccupancyLabel.font.setFamily("arial");
var spaceOccupancyLabelRenderer = new esri.renderer.SimpleRenderer(spaceOccupancyLabel);

var spaceLabelScaleDependentRenderer = new ScaleDependentRenderer({
    rendererInfos: [{
        renderer: spaceOccupancyLabelRenderer,
        minScale: 500,
        maxScale: 1
    }]
});

occupancyLabelLayer.addFeatureLayer(featureLayer, spaceLabelScaleDependentRenderer, "${" + labelField + "}");
                

Firebug Exceptions:

1)exception in animation handler for: onEnd
http://js.arcgis.com/3.7/ (line 45)
2)TypeError: b is undefined
http://js.arcgis.com/3.7/js/esri/layers/LabelLayer.js    Line 21
removed arcgis-10.0 tag
Link
Derek Swingley
  • 14.5k
  • 2
  • 45
  • 63
edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
added tags
Link
Ash
  • 123
  • 6
Loading
added clarity to question
Source Link
Ash
  • 123
  • 6
Loading
Source Link
Ash
  • 123
  • 6
Loading