BrianBunker / cmv-widgets

Widgets based on the Esri jsapi, configured for the Configurable Map Viewer. Widgets include Drag and Drop, Goto, Map Navigation Hash, and Nearby.
https://brianbunker.github.com/cmv-widgets
MIT License
18 stars 24 forks source link

Controlling the layer list on the Nearby Widget #36

Open gaokai85 opened 8 years ago

gaokai85 commented 8 years ago

Currently, the Nearby widget will auto populate all layers and sublayers (with data) listed in the viewer.js. Could we change the code so that we could have more control over which layers we include in the Nearby widget? From the Nearby.js file it seems this function creates the drop-down list:

populateLayerSelect: function () { var options = []; array.forEach(this.map.layerIds, lang.hitch(this, function (layerId, i) { if (i !== 0) { if (this.map.getLayer(layerId).layerInfos && this.map.getLayer(layerId).layerInfos.length > 0) { array.forEach(this.map.getLayer(layerId).layerInfos, lang.hitch(this, function (layerInfo, j) { // check to exclude the group layers as they do not contain features if (!layerInfo.subLayerIds) { options.unshift({ value: layerId + ':' + j, label: layerInfo.name }); } })); } else if (this.map.getLayer(layerId).name) { options.unshift({ value: layerId + ':', label: this.map.getLayer(layerId).name }); } } })); this.nearbyFeaturesSelect.addOption(options); this.setupSelectionLayers(this.nearbyFeaturesSelect.get('value')); },

Any quick pointers on how we might approach this would be helpful. If it would be a complex task, that insight would also be helpful. Thank you!