Select to view content in your preferred language

Distance from current location to features in a List widget

265
9
2 weeks ago
Labels (1)
MappyIan
Frequent Contributor

I think I know the answer to this, but I'm going to ask anyway!  I have an Experience that allows students to filter study centre (points) based on their facilities.  I'm displaying the list of buildings using the List widget.  What I'd like to add to each list item is the (straight line) distance from the users current location to each study centre as shown in the first record (Alison House) on the image below:

MappyIan_0-1763049421667.png

If this is possible, what I'd also like to be able to do is sort the list by distance from the users current location.

I suspect this isn't possible (I'm using ArcGIS Online, not Enterprise) but would love to know if anyone else has done something like this and how it was achieved.

0 Kudos
9 Replies
JeffreyThompson2
MVP Frequent Contributor
  1. Set up a Hidden Near Me Widget.
  2. While setting up your Near Me Analysis, make sure you have Include Approximate Distance turned on.
  3. In your List Widget, while selecting your data, go to the Outputs Tab and use the Near Me Output.JeffreyThompson2_0-1763055032114.png
  4. Inside the List Widget, add a Text Widget and go to Dynamic Content. Approximate Distance should be an available Attribute.JeffreyThompson2_1-1763055143515.png

     

It should also be possible to use this Attribute as a Sort field.

GIS Developer
City of Arlington, Texas
0 Kudos
MappyIan
Frequent Contributor

Hi @JeffreyThompson2, many thanks for getting back to me, that's really helpful.  I've kind of got it working (you can see a very simple implementation here: https://experience.arcgis.com/experience/a8e84912e5924d41895e5eef342d3e0f)  but have a couple of questions:

  1. How do you trigger the 'find my location' to retrieve the users location without having them click on the 'find my location' button on the map?
  2. How can you stop the map zooming in to the users current location, then out to the search extents?

I see you've managed both of these things in your Park Finder application (https://gis2.arlingtontx.gov/parkfinder/) and I'd love to know how you achieved this.

Any tips/pointers/help would be greatly appreciated.

Thanks!

0 Kudos
MappyIan
Frequent Contributor

I should add, the way I set up the above linked Experience it to create two lists and put them each within a Section/View which are then toggled using a Views Navigation widget.  I couldn't think how else to set this up so that the default alphabetically sorted list was visible on load if the lists data source is set to the output of the Near Me tool which is only activated when the user presses the 'find my location' button, unless there is a way to activate this tool at the point the Experience loads?

0 Kudos
JeffreyThompson2
MVP Frequent Contributor
  • I can't see your application. You need to adjust your Sharing settings.
  • Park Finder was built in Developer Edition. I sort of explain how it works in this post. But short story, all the interactions are custom code.
  • Also in that post, I describe a build where you could use a Sidebar to automatically cover the alphabetical List with the Near Me Output List.
GIS Developer
City of Arlington, Texas
MappyIan
Frequent Contributor

Aaargh, sorry, I forgot to share the ExB app.  You should be able to see it now: https://experience.arcgis.com/experience/a8e84912e5924d41895e5eef342d3e0f (it's very basic though)

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

The Near Me results aren't showing up for me. I suspect this has something to do with the distance between Texas and Scotland. Not any issue with the configuration.

Mostly just give this a bit of style (pictures for each location would go a long way) and you should have a nice application.

GIS Developer
City of Arlington, Texas
0 Kudos
MappyIan
Frequent Contributor

Thanks @JeffreyThompson2, I'm using ArcGIS Online not Developer Edition and the maximum search distance you can configure in AGOL is 1609km (1000miles).  Looking at your ParkFinder app, we're 4800miles apart!

There are too many annoyances in this AGOL version to be able to use this in a production app, specifically the zooming in then out caused by the 'find my location' then 'near me' widgets respectively; and the fact the user has to press the 'find my location' button to populate the 'libraries by distance list'.  It's interesting to see what's possible, but at the moment we can't embed this in the app we're developing.  Thanks for your help though, it is much appreciated 👍

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

I meant to mention this earlier, but the next ArcGIS Online Update, Q1 2026, should include an enhancement to automatically get and track the user's location.

GIS Developer
City of Arlington, Texas
0 Kudos
MappyIan
Frequent Contributor

Yeah I saw that too.  Thanks.

0 Kudos