Enhanced Layer List - Metadata Dialogs (Tested up to WAB 2.15)
Update July 2017: adds REST Link and 'No Information Available' features.
Update December 2019: Still works great in current WAB (use the code here but insert it in to a current version of the widget.js in the existing 2.14 WAB)
GitHub Link: GitHub - kevinsagis/EnhancedLayerList
You can see this widget in action at SAGIS Property Map Viewer
Enhanced Layer List adds metadata Dojo dialogs to display the Description and Copyright text fields from the REST service. This replaces the standard out-of-the-box function that opens a new tab or window to display the Esri REST Service page when a user clicks the "Description" item in the '...' menu on a layer in the Layer List widget, and displays these dialogs instead. This is more friendly to the end user. Also includes LayerListView.js autoexpand mod for the layerlist based on posts from Robert Scheitlin et al in https://community.esri.com/thread/160914
Files that were modified are in widgets\eLayerList\PopupMenu.js and PopupMenuInfo.js
It only displays Copyright if it's present. Same for Description. It won't display a Dialog if there is no description, such as for Group layer IDs.
Hi Kevin,
In your enhanced layer list example, I was wondering how you managed to have a group layer configured in such a way that the primary 'parent' layer would be toggled on; but the various sublayers would be toggled off.
In my Portal where after toggling "off" sublayers for the 'group layer', and refreshing the map viewer, you see **all** of the layer items then appear unchecked includng parent layer and that is a known ESRI bug for Portal 10.3.1.
Is there a way to have a parent layer be on programmatically?
Thank you!
Nadia
Hm I do not know as I have not used Portal. (Yet!) I usually keep sublayers off in the MXD but keep the groups checked on. That way, users can just go in and turn on in one click. Esri should add partial state checkboxes though to indicate to users if only some layers on in a group. And also at least allow as optional behavior ability for one single click to turn a layer on, even if its parent(s) are off. Like how AGS JS TOC did.
Thank you, Kevin! The solution to control the On/Off group behavior from the MXD is a simple one, but it works! I was trying to control it from webmap or WAB widgets with no luck. Thank you for your help! Totally agree with idea of partial checkboxes for group layers.
The metadata popup is not appearing for many layers. What is the difference for these layers?
It doesn't work for any of the layers in these groups:
These groups have some layers showing it but others do not:
I would understand if it didn't show up for layers that don't have descriptions, but those in the Coastal Hazard Assessment - Hazard Level subgroup all have empty description popups.
Ken, example is updated with new code. I have gotten the Git and Example site in sync now. Now, after the code update, if the length is <1 char for Copyright or Details fields, it will say No Information Available, as to regarding your question.
Relevant portion of the code is:
if (response.hasOwnProperty("description")) { if (response.description.length > 0) { var descriptionTitle = '<b>Description: <br><br> </b>'; var copyrightCombined = response.copyrightText; if (response.copyrightText.length > 0) { var copyrightTitle = '<b><br><br>Copyright: <br><br> </b>'; copyrightCombined = copyrightTitle + response.copyrightText; } var _layerText = descriptionTitle + response.description + ' ' + copyrightCombined + '<br><br><b>GIS Details:</b><br><br> ' + '<a href=' + layerUrl + ' target="_blank"' + '>' + 'REST Link</a> '; layerText = _layerText; } else { var _layerText = "No information available." + '<br><br><b>GIS Details:</b><br><br> ' + '<a href=' + layerUrl + ' target="_blank"' + '>' + 'REST Link</a> '; layerText = _layerText; } } else { var _layerText = "No information available." + '<br><br><b>GIS Details:</b><br><br> ' + '<a href=' + layerUrl + ' target="_blank"' + '>' + 'REST Link</a> '; layerText = _layerText; }
It is rather unsophisticated I'm afraid. I need to refactor the dijit titlepane, and generally polish it up a bit. Then I'll consider it a bona fide v1.
I would be happy though to have Esri integrate my code or at least the concept in LayerList!
Perhaps next thing maybe I will do regarding LayerList is a simple CSS tweak to do partial checkboxes for groups.
Hi Kevin MacLeod Looks like the link to your gishub help file is broken. Maybe was an html and now a .txt file? Took me a while to find it. You may want to link to your repository direct too (just a suggestion)
eLayerList Git link corrected. (ThanksRebecca Strauch, GISP! Yes, it was changed via Git! Thanks!) FYI also our REST service for that demo site also was on a server that is being upgraded throughout this week. I've repointed to another layer temporarily and the demo is back up.
Interesting observation - I didn't realize my eLayerList metadata boxes would render inline html. If you have a <img> picture in your mxd Description it will render! Like in the demo link. So, that's neat. The EPA's actual site is down (problem on their server, not GIS-related) but the image works in the demo. I just grabbed the a random layer with a Description field form ArcGIS Online for the demo site's purposes as a temporary layer and made this observation. (It will be re-pathed to our coastal phsyiographic layer in the longterm). But I like how the EPA has an actual image that says METADATA. Could also have a corporate logo or something. Good to know!
Hi Kevin,
When I click on the link to GitHub to download the enhanced layer list and extract files, I do not see a folder that you refer to (i.e. widgets\eLayerList\PopupMenu.js and PopupMenuInfo.js). I see the LayerList widget folder, is this what I should be using?
Thanks!
Melissa