Zone Lookup in Experience Builder: A Near Me Experiment

405
0
07-03-2024 11:32 AM
JeffreyThompson2
MVP Regular Contributor
2 0 405

About a month ago, I was tasked with a project to find points in a polygon area. I could never quite crack it, in part, because by polygon layer wasn't actually a layer, it was a table, but I kept getting close. Ultimately, we converted the table to an actual polygon layer and used the Zone Lookup Instant App. It did everything we needed and was super easy to set up. Then, the new ArcGIS Online update came out and the update to Feature Info didn't quite work the way anyone expected and I wondered if could use the Near Me tricks I was working on to make a popup replacement. Again, I couldn't quite get there. I felt I was so close to something useful, but I every iteration lead to some weird response. I wound up with some versions that would work on mouse click and others that would work with a Search Widget, but never both at the same time. In some versions, clicking a polygon would select a neighboring polygon. I was getting a bit obsessive and going slightly crazy.

I think I finally cracked it. I found the idea that is mostly useful. I built a Zone Lookup App using only OOTB Experience Builder widgets. Did you know one Near Me Widget can trigger another? This is a build based on double-hidden Near Me Widgets. This is a build that can find points in a polygon using either a Locator Source or a Layer Source, or by clicking on the map. Downsides: If you want to use both a Locator and Layer Source, you will need to separate Search Widgets and clicking directly on the point layer will not trigger the Near Me functions.

For my demo, I have a map with a polygon layer of counties and a point layer of Bigfoot sightings. Let's find some big feet! (Maybe don't Google that.)

Step One: Big Feet Near Me (Really Don't Google That.)

Let's add a Map Widget and connect it to our Bigfoot map. I'm going to turn off popups. I think it will be better that way. Then, I throw in a Near Me Widget and rename it Bigfeet Near Me. In my Near Me settings, I will set the Search Distance to 0. I go to Add Analysis and select my Bigfoot layer and set the Analysis Type to Proximity.  (To all the confused people who just typed the first four letters of analysis and big feet into their search engines, this isn't the site you are looking for.) Now, go back to the Map Widget Settings Action Tab. Add a Record Selection Changes>Framework>Select Data Records Action and set both the Trigger and Action Data to the Counties layer. Then, Add Action and Bigfeet Near Me>Set Location. This should find all of the Bigfeet in a county by mouse click.

JeffreyThompson2_0-1720026160846.png

JeffreyThompson2_1-1720026396287.png

Step Two (Optional): Search By Layer Source

Add a Search Widget. Add New Search Source and select the Counties layer. It would be good design to change the Hint to something that clarifies that the user should enter a county name. Turn off Enable Filtering For Layer Source Search. I've also renamed my Search Widget to County Search. In the Action Tab, add a Record Selection Changes>Map>Zoom To Action and then a Bigfeet Near Me>Set Location Action. Zoom To should be before Near Me, apparently this order matters. Now, searching for counties should find Bigfeet.

JeffreyThompson2_3-1720027217265.png

JeffreyThompson2_2-1720027193553.png

Step Three: Search By Locator Source

This is where it gets a little weird. We are going to double up Near Me. (Google people, go away, this still isn't what you want. (Seinfeld voice: Not that there's anything wrong with that.))  Add a second Near Me Widget. We'll call this one Counties Near Me. As before, set the Search Distance to 0. This time set the Analysis Type to Closest Feature. You will also want to turn off Highlight Results On Map. In the Action Tab, add a Record Selection Changes>Bigfeet Near Me>Set Location Action.

JeffreyThompson2_4-1720028379943.png

Now add a second Search Widget, set your search to a Locator Source. In the Action Tab, make Record Selection Changes>Map>Zoom To and Counties Near Me>Set Location Actions. Now using the Locator Search will find a location, send it to the Counties Near Me Widget, find the correct county and pass the county on to the Bigfeet Near Me Widget.

Step Four: Build An Output

Depending on how your user searches and in what order, the Counties Near Me Widget may fall out of sync with the currently searched for Bigfeet. So you will definitely want to hide it. And I still ain't a fan of how Near Me looks so I'll hide both of them. To make my output, I will use the newly updated capabilities of the Feature Info Widget. To get my Bigfeet, I will go to the Outputs Tab>Bigfeet Near Me>BigFoot (Proximity) Output View. 

JeffreyThompson2_1-1720031188042.png

For the Counties, I will add the Counties layer from my map in the Added Data Tab. Then, I will click back on the Counties layer in the Settings Panel to get more options and use the dropdown menu to pick Selected Features.

JeffreyThompson2_2-1720031311387.png

JeffreyThompson2_3-1720031404502.png

Go find big feet near you from the safety of Experience Builder. 

JeffreyThompson2_0-1720031028316.png

About the Author
A frequently confused rock-hound that writes ugly, but usually functional code.