Select to view content in your preferred language

How do I turn on layers in the Layerlist widget when I open another?

6401
14
Jump to solution
04-04-2016 08:17 AM
LeiZhou1
Regular Contributor

I want to set two layers A and B in the swipe widget for comparison, once the widget is open, these two layers are automatically turned on. Layer A is set as my default swipe layer. I guess my question is that how do I turn on both layers in the layer list widget everytime when I open the swipe widget? Thanks!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Lei,

  So what is calling _onPublishClick in the swipe widget? I would have just added

this.publishData({

        message: ''

      });

to the onOpen function.

View solution in original post

0 Kudos
14 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
LeiZhou1
Regular Contributor

I put codes in the file widget.js of the Layer List widget as the following, but it seems nothing happen. Could you please have a look at it? Thanks a lot!

onReceiveData: function (name, widgets_Swipe_Widget_52, data, historyData) { 

        //this makes sure that it is your event that you are reacting to and not another 

        if(name === 'Swipe' && data.hasOwnProperty('message')){ 

          

          this.operLayerInfos.getLayerInfoById('Land_Use_2040_1084').setTopLayerVisible(true); 

          

          //this causes the layer list widget to redraw and show that the layers are turned off 

          this._clearLayers(); 

          this.showLayers(); 

        }  // if statement ends

      }, 

//RJS End Add 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lei,

  And are you dispatching the this.publishData in the swipe widget?

this.publishData({

                    message: someObject

                });

0 Kudos
LeiZhou1
Regular Contributor

No,  I didnot. So about this someOject, what message should I insert? Is there any sample for this? Thanks!

0 Kudos
LeiZhou1
Regular Contributor

I also tried this following.  I download the file from Developer Edition and then work on it. Should I work in the directory: arcgis-web-appbuilder-1.3\client\stemapp ?Thanks!

onReceiveData: function (name, widgetId, data, historyData) {

        //this makes sure that it is your event that you are reacting to and not another

        if(name === 'Swipe'){

          this.operLayerInfos.getLayerInfoById('Land_Use_2040_1084').setTopLayerVisible(true);

         

          this._clearLayers();

          this.showLayers();

        }  // if statement ends

      },

//RJS End Add

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lei,

I do all my development in a specific app when I am working on a widget (i.e. arcgis-web-appbuilder-1.3\server\apps\[app#]\widgets).

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lei,

You ca set it to anything or just a empty string if you don't have anything you want to pass.

0 Kudos
LeiZhou1
Regular Contributor

Hi, Robert,

I insert these line to Swipe widget

_onPublishClick: function() {

    this.publishData({

        message: ''

      });

  },

     

I also insert alert statement in LayerList like this: onReceiveData: function (name, widgetId, data, historyData) {  alert("Receive something here");  ....... }

It seems the layerlist does receive anything, otherwise the alert pop up should display. I really want this to happen, could you please give me some hints? Many thanks!

0 Kudos
LeiZhou1
Regular Contributor

I work something out. But it seems I have to open layer list widget first, otherwise the swipe widget does not send anything to LayerWidget. Can I make the layer visible without open the LayerList Widget? Thanks!

0 Kudos