I have a subLayer, "Parcels_9562_6", within a group layer that I need to programmatically make visible, after the LayerList has already opened. Another widget communicates with the LayerList widget during user interaction. I've had no success while fiddling around with the LayerList widget's, Widget.js and LayerListView.js files. Does someone know how this can be accomplished? Thanks.
Solved! Go to Solution.
Ryan,
Well this took some work to figure out. Keep the onRecieveData function in the widget.js and here is what it will look like:
//RJS Add onReceiveData: function (name, widgetId, data, historyData) { //this makes sure that it is your event that you are reacting to and not another if(name === 'eSearch' && data.hasOwnProperty('message')){ //my layer is called Parcel Data so Parcel Data_0 is the first layer or group //these next lines cause the map to set that layer as not visible this.operLayerInfos.getLayerInfoById('Parcel Data_0').setTopLayerVisible(false); this.operLayerInfos.getLayerInfoById('Parcel Data_83').setTopLayerVisible(false); //this causes the layer list widget to redraw and show that the layers are turned off this._clearLayers(); this.showLayers(); } }, //RJS End Add
Ryan,
So are you saying that you have already figured out the part of how to make the sublayer visible in the map and that the LayerList widget is just not updating?
No I haven't figured out how to make the sublayer visible in the map yet. It should be easy right?
Ryan,
So what do you have so far?
Another widget communicates with the LayerList widget during user interaction
You can control sub layer visibility using the ImageParameters class in the JS API:
Sorry I just realized it's your widget, the eSearch widget, that I'm communicating to the LayerList widget with. In your code ---
var myObject = this.getUrlParams();
if (myObject.esearch) {
this._queryFromURL(myObject.esearch, myObject.slayer, myObject.exprnum);
this.publishData({
message: myObject.slayer
});
---communicates to the LayerList.js ---
onReceiveData: function (name, widgetId, data, historyData) {
dijit.byId("jimu_dijit_CheckBox_7").setValue(true);
}
I check a Subdivisions layer checkbox. And also need to make the Subdivisions layer visible, since it is not visible by default.
Ryan,
Do you mean the LayerListView.js is where you have your onReceiveData function?
I currently have it in LayerList's Widget.js. If it needs to be in the LayerListView.js. I think I could place it there. I'm just struggling to figure out how to make it work.
Ryan,
Well this took some work to figure out. Keep the onRecieveData function in the widget.js and here is what it will look like:
//RJS Add onReceiveData: function (name, widgetId, data, historyData) { //this makes sure that it is your event that you are reacting to and not another if(name === 'eSearch' && data.hasOwnProperty('message')){ //my layer is called Parcel Data so Parcel Data_0 is the first layer or group //these next lines cause the map to set that layer as not visible this.operLayerInfos.getLayerInfoById('Parcel Data_0').setTopLayerVisible(false); this.operLayerInfos.getLayerInfoById('Parcel Data_83').setTopLayerVisible(false); //this causes the layer list widget to redraw and show that the layers are turned off this._clearLayers(); this.showLayers(); } }, //RJS End Add
Beauty! Thanks for your work. I owe you a beer next time you're in Boise.
Robert,
This is exactly what I need, now just to get it to work. I need to fire this off from when the Edit widget launches. What do I need to add in the Widget.js of the edit widget to get it to work.