Hello
I'm using the Near Me Widget in WAB 2.3 and have noticed that if I run a Near Me search the widget will turn on all the search layers that were previously off in the map and they will appear in Legend but are still switched off in the Layer List. When I close the Near Me widget again when I'm finished using it these layers remain on in the map and in the legend but not switched on in the Layer List.
Is there something I can change in the code that will turn off these extra layers once the widget is closed again?
Maureen,
In the NearMe\Widget.js find the onClose function and comment out line 9 below:
onClose: function () {
if (this._isValidConfig) {
this._disconnectMapEventHandler();
//Clear the previous text in search textbox
if (this._searchInstance) {
this._searchInstance.clearSearchText();
}
if (this._searchedLocation && this._itemListObject) {
// this._itemListObject.showAllLayers();
this._itemListObject.resetAllFilters();
this._clearResults();
}
}
}
I tried commenting out the line Robert Scheitlin, GISP suggested, but it didn't work for me. Did anything else help you fix your problem?
Chelsea,
Are you sure you made the change in the right file? What do you mean by it did not work?
I commented out the line this._itemListObject.showAllLayers(); under the onClose function within the Widget.js file (...\PoliticalDistricts\widgets\NearMe\Widget.js). I'll leave it commented out. This is my site, I believe it should be available to everyone: ArcGIS Web Application . All the Political Districts are turning on still and staying on even when I change to other widgets. This is a huge problem, because I want to label all the districts with their numbers, and it looks like a jumbled mess when they're all on at once. The .mxd I published has none of the layers turned on, and I just double checked again, my web map that the app is using has all the districts unchecked, so I don't know why it thinks I want them on.
Thanks for the reply Maureen Kerr, that occurred to me too. I had them all added as one map service, and just yesterday I separated them out. I do see that behavior that you mentioned, that now all the district layers are checked on in the WAB layer list widget instead of what it was before: the top map service checked but none of the sublayers, yet I could see all the districts on the map.
This is currently the designed behavior. You would need to contact esri tech support and start an enhancement request. The dev team would need to record the layers original state (visibility) and then reset to that when the widget is closed instead of just turning all the configured layers on when the widget is closed.
Thanks for taking a look at it. That's unfortunate that it does that. I'll get around it for now by adding all the layers again as one Map Service, removing symbology, and having Near Me query that invisible set of layers. The downside now, aside from duplicate layers, is that those popups are always enabled, so when a user goes to the Layer List to explore the political districts on their own, they get popups for all the layers instead of just the one layer they've turned on.
Hi
no it didn't work for me either, however I think my problem (not sure if This will be the same for you or not) is that my services were added to the web map as one whole map service and so the app was turning the whole service on and leaving it on but not checking the layers on in the layerlist sublayers. Separating the service out into separate feature layers has helped me i.e. When searching with the near me widget it turns on all the layers but switches them on in the layer list too so it's clear to the end user what has happened
i hope that this makes sense and is of some help
and in fact I'm just thinking I'm not sure I tried Your fix Robert in my new set up so I'll test that tomorrow