Turn certain layers on in the Layer List based on the type of search?

447
2
Jump to solution
04-06-2018 05:38 AM
MartinOwens1
Occasional Contributor II

This is probably a christmas list type question, but could it be possible to turn a certain layer on in the Layer List widget simple based on one of the search configs in the eSearch. So if a user searches on say a Subdivision Name the Subdivision layer ID in the Layer List turns on automatically for the user.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Martin,


This would Not be something that will be added to the eSearch release, because the eSearch does not depend on the layer being added to the map before the search is able to be completed. That being said it would not be difficult from you to add custom code to the eSearch to do this though. If you do this in the onAttributeLayerChange function you can use a function like this:

var layerInfo = this.operLayerInfos.getLayerInfoById(currentLayer.id);
layerInfo.setTopLayerVisible(true);

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Martin,


This would Not be something that will be added to the eSearch release, because the eSearch does not depend on the layer being added to the map before the search is able to be completed. That being said it would not be difficult from you to add custom code to the eSearch to do this though. If you do this in the onAttributeLayerChange function you can use a function like this:

var layerInfo = this.operLayerInfos.getLayerInfoById(currentLayer.id);
layerInfo.setTopLayerVisible(true);
0 Kudos
MartinOwens1
Occasional Contributor II

For whatever reason it kept barking about (currentLayer.id), but I got it to work by defining what config name the user selected. I'm sure this code is ugly and inefficient as far as the logic but it works and I'm a noob.

var newlayerInfo = this.config.layers[newValue].name;
            if(this.config.layers[newValue].name === "Subdivision"){
                var subs = this.operLayerInfos.getLayerInfoById("Subdivisions_8362");
                subs.setTopLayerVisible(true);
            }else{
                var subs = this.operLayerInfos.getLayerInfoById("Subdivisions_8362");
                subs.setTopLayerVisible(false);
        }
            if(this.config.layers[newValue].name === "Tax Map"){
                var tm = this.operLayerInfos.getLayerInfoById("TaxMap_5265");
                tm.setTopLayerVisible(true);
            }else{
                var tm = this.operLayerInfos.getLayerInfoById("TaxMap_5265");
                tm.setTopLayerVisible(false);
        }

Thanks again Robert!