Select to view content in your preferred language

Turn On Layers on Widget Start

3129
13
Jump to solution
10-04-2016 11:27 AM
GabiVoicu1
Emerging Contributor

How can we turn on layers from a different widget (other than the layer list) say - for example my widget only works when this certain layer is on (by default they are all off)

Thank you

0 Kudos
13 Replies
RobertScheitlin__GISP
MVP Emeritus

Zhujing,

   I am not sure if I can explain it any better then the info in this thread. What specific part are you not understanding?

0 Kudos
ZhujingXia
Frequent Contributor

Robert,

I put your code in the Screen Widget under Report Button, but it dose not work.

this._initLayerInfosObj().then(lang.hitch(this, function() {
          if(!this.layerInfosObj.getLayerInfoById('IP_IndianPoint_3610').isVisible()){
            this.layerInfosObj.getLayerInfoById('IP_IndianPoint_3610'').setTopLayerVisible(true);
          }
          if (!this.hasVisibleTemporalLayer()) {
            html.setStyle(this.noTimeContentNode, 'display', 'block');
            html.setStyle(this.timeContentNode, 'display', 'none');
            this._showed = true;
          } 
          }
        }));
     

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Zhujing,

 

  Your problem is you are just copy and pasting code and expecting it to work. That code you were copying was specifically for the TimeSlider widget.

You need to use my original code I posted, that has the require.

ZhujingXia
Frequent Contributor

Robert,

I used your original code and it works.

 LayerInfos.getInstance(this.map, this.map.itemInfo).then(function(layerInfosObject){
             layerInfosObject.getLayerInfoById('IP_IndianPoint_3610_8').setTopLayerVisible(true);
          });

Thanks

Zhujing

0 Kudos