AnsweredAssumed Answered

scale dependent visibility for graphics layer

Question asked by dbecker88 on May 3, 2012
Latest reply on May 7, 2012 by dbecker88
I filled a new graphics layer with text symbols; one for each point in a feature layer. The below function works fine and the labels are displayed correctly in their +50,+50 offset location, but how do I control the graphics layer visibility based on scale?


function createLabels(){  var queryTask = new esri.tasks.QueryTask("REST url");  var query = new esri.tasks.Query();  query.returnGeometry = true;  query.outFields = ["site_code"];  query.where = "site_code LIKE '%'";  queryTask.execute(query, function(featureSet){;   var lbls = new esri.layers.GraphicsLayer();   var font = new esri.symbol.Font("9px", esri.symbol.Font.STYLE_NORMAL, esri.symbol.Font.VARIANT_SMALLCAPS, esri.symbol.Font.WEIGHT_BOLDER);   for (var i=0, il=featureSet.features.length; i<il; i++) {    var x = featureSet.features[i].geometry.x + 50;    var y = featureSet.features[i].geometry.y + 50;    featureSet.features[i].geometry.x = x;    featureSet.features[i].geometry.y = y;    var graphic = featureSet.features[i].attributes.site_code;    var textSymbol = new esri.symbol.TextSymbol(graphic, font, new dojo.Color([0, 0, 0]));    var symb = featureSet.features[i];    symb.setSymbol(textSymbol);    lbls.add(symb);   };   map.addLayer(lbls);  }); }