Select to view content in your preferred language

Set initial value of HORIZONTALSLIDER not working

822
1
08-14-2013 06:56 AM
WalterEralio
Occasional Contributor
I have a feature layer with attached dijit horizontalslider

Initially the layer is not visible and I'll like to programatically enable it (I'm doing that) but with the slider set in the middle (value 0.5, i.e. Opacity= 0.5). I cannot do this.. the layer appears with the slider on the beginning but no opacity and as soon as I move it to the right it'll go from 0 to 1


Declaration:

            // FLOOD LAYER
            featureLayerFL = new esri.layers.FeatureLayer('<s:property value = "arcGisFeatureLayerUrl" />/mxds/manmapC/MapServer/12', {
                mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
                outFields: ['*'],
                opacity: 1
            });
            legendLayers.push({
                layer: featureLayerFL,
                title: 'FLOOD'
            });
            featureLayerFL.hide();
            dojo.connect(featureLayerFL, 'onMouseOver', showTooltipFL);
            dojo.connect(featureLayerFL, 'onMouseOut', closeDialogFL);
   featureLayerFloodSlider = new dijit.form.HorizontalSlider();
   featureLayerFloodSlider.id = "Flood Slider";
   featureLayerFloodSlider.value=0.5;
   featureLayerFloodSlider.layerID = 12;
   featureLayerFloodSlider.minimum = 0;
   featureLayerFloodSlider.maximum = 1;
   featureLayerFloodSlider.tooltip = "Flood";
   featureLayerFloodSlider.intermediateChanges = true;
   featureLayerFloodSlider.showButtons = true;

   featureLayerFloodSlider.style = "width:100px";
   //featureLayerFloodSlider.onChange = function(){slideLayerOpacity(12,this.value)}
   featureLayerFloodSlider.onChange = function(){slideLayerOpacity(12,featureLayerFloodSlider.value)}
   featureLayerFloodSlider.handleSrc = "https://serverapi.arcgisonline.com/jsapi/arcgis/1.1/js/dojo/dijit/themes/tundra/images/preciseSlider...";


Part when I make visible and try to set value to 0.5
                   featureLayerFL.setVisibility(true);
                   featureLayerFloodSlider.value=0.5;
                   map.graphics.refresh();
0 Kudos
1 Reply
JasonZou
Frequent Contributor
Try this.

Change:
featureLayerFL.setVisibility(true);
featureLayerFloodSlider.value=0.5;
map.graphics.refresh();

To:
featureLayerFloodSlider.set("value", 0.5);
featureLayerFL.setOpacity(0.5);
featureLayerFL.setVisibility(true);
0 Kudos