LanceWeaver

change TiledMapServiceLayer 'displayLevesl' property AFTER layer is added

Discussion created by LanceWeaver on May 23, 2012
here's a tricky one.  

I'm creating a Custom display scale range control with a dojo horizontal range slider.

Seems the cleanest way to do this would be attach a function to the range slider that simply changes the TiledMapServiceLayer's 'displayLevels' property.  But in testing it appears that the displayLevels property has to be set when the layer is created. After its added to the map it appears that it becomes ._displayLevels and is not changeable?  Am I missing something?

I guess I could remove the layer, redefine it, and re-add it to the map.  But it would be nice if there was an easier way to set the display Levels of a Tiled Layer after its added to the map and then just refresh it.

I see that the FeatureLayer has a setScaleRange(min,max) method, and min/maxScale property. Can there be something like this for a Tiled Layer?    Or better add the min/maxScale to the esri.layers.Layer class so its available on all layers.

Or is there an easier way of doing this that i'm missing?  I dont want to have to listen for zoom changes and loop through all my layers adding and removing them...

If it helps here's a link to my application.   If you click the arrow next to the layer, the range slider appears which im trying to make control the display levels... http://geology.utah.gov/testing/marshall/jstest/indexTest.html

 var rangeslider = new dojox.form.HorizontalRangeSlider({
   name: "rangeSlider",
   value: [min, max],
   minimum: 0,
   maximum: 19,
   discreteValues: 20,     
   intermediateChanges: false,    
   showButtons: true,
   onChange: function(n) {
   layer._displayLevels = Array.range(n[0],n[1]);
   layer.refresh();
 }


I'm actually kind of surprised ArcGIS.com doesnt have this functionality next to the set opacity control on each layer.  It would be a cool feature.

Outcomes