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

5968
14
Jump to solution
04-04-2016 08:17 AM
LeiZhou1
Occasional 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
14 Replies
RobertScheitlin__GISP
MVP Emeritus

Lei,

  in the startup of the LayerList widget add

this.fetchData();

0 Kudos
LeiZhou1
Occasional Contributor

Hi, Robert,

Does the following codes look OK to you? I inserted it to Swipe widget js file, but the alert statement does not show up. Why it does not send out anything? Thanks!

_onPublishClick: function() {

   alert("Sending out message");

    this.publishData({

        message: ''

      });

  },

0 Kudos
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.

0 Kudos
LeiZhou1
Occasional Contributor

I will keep working on it. Thanks a lot for your advise!

0 Kudos
VickyShen
New Contributor II

I followed the solution to add the code like this. It is not working. Is it correct I added the code? Thank you all!

onOpen: function () {

this.publishData({

message: 'Please turn on Aerials 2019 and Aerials 1951 layers'

});


if (true === this._isTestSizeFlag) {
return;//skip first on-open(1st open called from jimu)
}

//re-create
this._loadLayerInfos().then(lang.hitch(this, function () {
var layerInfos = utils.getVisibleLayerInfos(this.layerInfosObj);

this.setDefaultOptions(layerInfos);

this.createSwipeDijit(/*selected*/);

// this.a11y_updateFocusNodes({isFouceToFirstNode: true});
}));
},

 

0 Kudos