I just configured the query widget for my application and it works well for the most part. However it would be great if when I run the query, my existing operational layers would automatically be disabled with query results layer as only visible layer. Similarly I want the operational layer to be re-enabled when I click on remove the result link or close the widget.
I tried looking into query widgets code but not sure where the click events are buried.
Has anyone got any ideas about this?
Solved! Go to Solution.
Anish,
Here are the changes to the Query Widget.js (all additional code is added to the begging of each function indicated):
postCreate:function(){
this.mapObj = {
layers: {}
};
...
onClose:function(){
//Use this to restore the layers visiblity state
var layerOptions = this.mapObj.layers;
this.layerInfosObj.restoreState({
layerOptions: layerOptions || null
});
...
//start to query
_onBtnApplyClicked:function(currentAttrs){
if (this.layerInfosObj && this.layerInfosObj.traversal) {
this.layerInfosObj.traversal(lang.hitch(this, function(layerInfo) {
this.mapObj.layers[layerInfo.id] = {
visible: layerInfo.isVisible()
};
//Now turn then off
if(layerInfo.isVisible()){
layerInfo.setTopLayerVisible(false);
}
}));
}
...
removeSingleQueryResult: function(singleQueryResult){
//Use this to restore the layers visiblity state
var layerOptions = this.mapObj.layers;
this.layerInfosObj.restoreState({
layerOptions: layerOptions || null
});
...
Anish,
Here are the changes to the Query Widget.js (all additional code is added to the begging of each function indicated):
postCreate:function(){
this.mapObj = {
layers: {}
};
...
onClose:function(){
//Use this to restore the layers visiblity state
var layerOptions = this.mapObj.layers;
this.layerInfosObj.restoreState({
layerOptions: layerOptions || null
});
...
//start to query
_onBtnApplyClicked:function(currentAttrs){
if (this.layerInfosObj && this.layerInfosObj.traversal) {
this.layerInfosObj.traversal(lang.hitch(this, function(layerInfo) {
this.mapObj.layers[layerInfo.id] = {
visible: layerInfo.isVisible()
};
//Now turn then off
if(layerInfo.isVisible()){
layerInfo.setTopLayerVisible(false);
}
}));
}
...
removeSingleQueryResult: function(singleQueryResult){
//Use this to restore the layers visiblity state
var layerOptions = this.mapObj.layers;
this.layerInfosObj.restoreState({
layerOptions: layerOptions || null
});
...
Thanks Robert. I really appreciate it.