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!
Solved! Go to Solution.
Lei,
So what is calling _onPublishClick in the swipe widget? I would have just added
this.publishData({
message: ''
});
to the onOpen function.
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
Lei,
And are you dispatching the this.publishData in the swipe widget?
this.publishData({
message: someObject
});
No, I didnot. So about this someOject, what message should I insert? Is there any sample for this? Thanks!
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
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).
Lei,
You ca set it to anything or just a empty string if you don't have anything you want to pass.
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!
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!