Select to view content in your preferred language

Web AppBuilder - Limit Legend Items Based on Filters or Map Extent

4236
16
Jump to solution
04-10-2018 03:47 PM
TessOldemeyer
Regular Contributor

Is there a way to limit legend items to only those feature values in the current extent in a Web AppBuilder (Developer's Edition 2.7) app? I currently have a service layer symbolized by unique values for my attribute of interest, though as I zoom to features, it would be nice to limit the legend to show only the unique values that are currently displayed (rather than having to browse through the many many unique values that are symbolized for the layer within the legend). I am using the filter widget to filter and zoom to features based off of multiple expressions for unique values and previous expression filters. Maybe limiting legend contents would need to be configured within the original map document, the service, the Portal web map, or in the application itself? I have attempted to achieve this functionality with the Legend and Layers widgets and have not had any luck. I'm curious as to what steps I may need to take to establish this functionality. 

Thanks in advance!


Tess

16 Replies
TessOldemeyer
Regular Contributor

Thanks!

0 Kudos
LisaT
by
Frequent Contributor

Hey Jamal, I am hoping that you can help me a bit with the setup of your code.  This will be the first widget that I am attempting to customize.  You mention that you are using a "report" widget as the base for this code.  The only widget that I see is "ReportFeature", is this the widget that you used? I tried to just copy and paste the code you supplied into the Widget.js and comment out the "close" line, for now. However, when I click on it, it is still using the base code to ask for info that is related to ReportFeature.  I can go in and remove those questions and related js, but I am starting to think I am on the wrong path.  Can you help get me started?

0 Kudos
JamalWest2
Regular Contributor

What are you attempting to do exactly? A custom report or a custom print widget?

0 Kudos
LisaT
by
Frequent Contributor

What I am trying to do is make a large overall map. I have a few US-wide layers, such as endangered wildlife.  My ultimate goal would be to put a bookmark and, when clicked, zoom into an area.  I would then like the map legend to only show the endangered wildlife symbols that are in the are that I zoom into.  It would also be great if it could print this way.  I would think that I should be able to "re-set extent" of the map so that only a specific area is selected and thus the print and legend would only show that area, but I haven't found it yet.  It seems that your tool will help to take care of the in-application legend?

0 Kudos
JamalWest2
Regular Contributor

The bookmark widget does this. You can add bookmarks that take you to an exact extent that you save. Also the newer versions of print and legend widget already use the map extent as a filter. So you don't really need to use this function.

0 Kudos
LisaT
by
Frequent Contributor

I may be missing something.  I have the newest version, 10.6.1, and can't get the map to only show the symbols in the visible extent. I want something similar to the checkbox in ArcPro "Format Legend Item" where you can check the box to "Only Show features visible in the map extent".  In my case, the extent of the underlying map is set to the whole US. There are LOTS of endangered wildlife symbols in the US extent.  If I zoom in to a city, I may only see 3 symbols. In that case, I only want 3 symbols on my legend, but ALL of the symbols still print and show in the legend because the underlying map extend is still the whole US.  I have configured the legend and checked/unchecked "Respect current map scale" and "Auto Update" and these 2 settings do not appear to make a difference on the legend.  I was thinking that your tool fixes it so that only the 3 symbols print?   Am I misunderstanding the functionality? Or, am I experiencing incorrect results with 10.6.1? Please let me know your thoughts on this so that I can attempt to troubleshoot.

Ideally, if I am zoomed into an area without ANY endangered species, I would like the layer to completely disappear or grey out on the legend (and print). 

Charlie_Kaufman
Occasional Contributor

Has there been any updates to this issue?  I'm having the same problem which I have a large study area with numerous smaller subset bookmarks.  I would love an easy solution that as my web app moves through the bookmarks my legend changes to only show what is visible in each extent.    So far I have not found a way to do this.

0 Kudos