I have an Experience Builder that contains 6 Near Me widgets that are triggered with a Select widget. When a user selects a parcel using the Select widget, the 6 Near Mes go off and search that parcel for various layers within different distances for each Near Me.
I then have an Arcade script inside of a Text widget that has all of the Near Me output data sources connected and this summarizes the results into a nice list - since I am stringing together 6 Near Mes, it's kind of long and not super clean for users to see the results. The request was that they could have something to simply copy/paste since they are often sharing these results with others.
The issue that I am having is that it is now holding onto stale results - so if a user runs it once and it returns 1 Species at Risk area for example, and then it is run again on a parcel that is not near any Species at Risk areas, it will still keep the 1 result. For any newly found layers that were not in the previous search or updated feature counts, it will properly adjust them in the list. It is just having issues with the layers that were found and then are no longer found.
This is a new issue and not something I observed happening when I created the script a year ago. I had to add some new layers to the tool recently and that's when I noticed it happening - I removed those new layers to see if that was the issue but it is happening with or without them. I know there have been some additional settings added to the Near Me widgets since I last set this up - I'm not sure if I need to adjust something, or is there a different profile I should be referring to in my code when calling the layers?
Any help or insight is appreciated!
Screenshots and code below.
First run, everything works as expected:
Second run, no longer near any of those 400m features that showed up in the first run, but they continue to show. New items are added as expected and layers that did previously exist in the last list do have their counts properly updated:
// Empty variable to hold output
var output = "";
// List of output layers in Near Me widgets
var layers = [
// Intersecting
{name: "Propane RSMP (intersecting)", ds: "widget_545_output_proximity_7844902899039525-output"},
{name: "KRCA Regulated Areas (intersecting)", ds: "widget_545_output_proximity_7968463111736579-output"},
{name: "ORCA Regulated Area (intersecting)", ds: "widget_545_output_proximity_9598497442304497-output"},
{name: "Noise Exposure Forecast (intersecting)", ds: "widget_545_output_proximity_08644733937223714-output"},
{name: "Clean Water Act Policies Apply (intersecting)", ds: "widget_545_output_proximity_18102019944760728-output"},
{name: "ORCA Floodplain (intersecting)", ds: "widget_545_output_proximity_6147625999696148-output"},
{name: "ORCA Lake High Water Level (intersecting)", ds: "widget_545_output_proximity_8184674839954809-output"},
{name: "KRCA Floodplain (intersecting)", ds: "widget_545_output_proximity_26042425009594083-output"},
{name: "Oak Ridges Moraine Land Use Designation (intersecting)", ds: "widget_545_output_proximity_035943006449194126-output"},
{name: "Area of High Mineral Potential (intersecting)", ds: "widget_545_output_proximity_5789448905263223-output"},
{name: "Wintering Area (intersecting)", ds: "widget_545_output_proximity_5954101991213211-output"},
// Within 120m
{name: "Peterborough Proposed Bypass (within 120m)", ds: "widget_544_output_proximity_8750538018314757-output"},
{name: "Areas of Natural and Scientific Interest (ANSI) (within 120m)", ds: "widget_544_output_proximity_2642195208116723-output"},
{name: "Spawning Area (within 120m)", ds: "widget_544_output_proximity_9555566998953181-output"},
{name: "Species at Risk Areas (within 120m)", ds: "widget_544_output_proximity_24353840154442263-output"},
{name: "Species at Risk Observations (within 120m)", ds: "widget_544_output_proximity_7010013464426786-output"},
{name: "King's Highway (within 120m)", ds: "widget_544_output_proximity_6057019457101002-output"},
{name: "Evaluated-Provincial Wetlands (within 120m)", ds: "widget_544_output_proximity_6816526860263106-output"},
{name: "Evaluated-Other Wetlands (within 120m)", ds: "widget_544_output_proximity_007184386039725488-output"},
{name: "Non-Evaluated Wetlands (within 120m)", ds: "widget_544_output_proximity_602167485573717-output"},
{name: "Cemetery Data (within 120m)", ds: "widget_544_output_proximity_6850263073775575-output"},
{name: "Waterbody (within 120m)", ds: "widget_544_output_proximity_7204693750133947-output"},
{name: "Watercourse (within 120m)", ds: "widget_544_output_proximity_7919740128394555-output"},
{name: "Woodlands (within 120m)", ds: "widget_544_output_proximity_3919084483159394-output"},
// Within 300m
{name: "Aggregate Sand and Gravel (within 300m)", ds: "widget_546_output_proximity_6767129073346421-output"},
{name: "Karst (within 300m)", ds: "widget_546_output_proximity_9203990105672937-output"},
{name: "Lake Sensitivity (within 300m)", ds: "widget_546_output_proximity_3502717978959833-output"},
{name: "Aggregate (Pit) (within 300m)", ds: "widget_546_output_proximity_21222536163466876-output"},
{name: "Archaeological Sites - CONFIDENTIAL (within 300m)", ds: "widget_546_output_proximity_018261958119917487-output"},
{name: "Railway (within 300m)", ds: "widget_546_output_proximity_936438734203539-output"},
// Within 400m
{name: "Buildings and Lands (within 400m)", ds: "widget_570_output_proximity_7844902899039525-output"},
{name: "Encroachment (within 400m)", ds: "widget_570_output_proximity_7232271423020573-output"},
{name: "Power Pole Transmission (within 400m)", ds: "widget_570_output_proximity_5042122413876593-output"},
{name: "Signs (within 400m)", ds: "widget_570_output_proximity_6695595499849716-output"},
{name: "Major Traffic Generator (within 400m)", ds: "widget_570_output_proximity_2693141622377604-output"},
// Within 500m
{name: "Aggregate (Pit/Quarry) (within 500m)", ds: "widget_551_output_proximity_9757872224346482-output"},
// Within 1000m
{name: "Petroleum Well (within 1000m)", ds: "widget_744_output_proximity_18734428093124356-output"},
{name: "Abandoned Mines (within 1000m)", ds: "widget_744_output_proximity_9999940247389159-output"}
];
// Count features and build summary
for (var i in layers) {
var dsid = layers[i].ds; // Get ID of data source
var layerName = layers[i].name; // Get name of layer
var ds = $dataSources[dsid]; // Connect to actual data source
var countFeatures = Count(ds.layer); // Get count of features
// Check if count is greater than 0, if it is, add it to the list
if (countFeatures > 0) {
if (output != "") {
output += TextFormatting.NewLine;
}
output += "(" + countFeatures + ") " + layerName;
}
}
return output;