I have two expressions that are essentially the same and both are functional when testing them but when loading them into the popup only exp0 loads.
Here is the expression, less the ID. The console expression does work and loads the correct number. You'll see from the picture the line is there for the popup but nothing is displaying.
// Create a 2 mile buffer around the selected event
var buff = BufferGeodetic($feature, 2, 'miles')
// Return Retail Stores within 2 miles of what's selected
var portal = Portal("https://www.arcgis.com")
var nrstoreLocations = FeatureSetByPortalItem(portal,"REMOVED_ID", 0, ['Asset_Type'])
var nearbyNRStores = Intersects(nrstoreLocations, buff)
var nrStores = []
//console(count(nrstoreLocations))
for(var f in nearbyNRStores){
var distance = DistanceGeodetic(f, $feature, "miles")
var nrstore_distance = Dictionary("NRStoreName",f.Asset_Type,"Distance",distance)
nrStores[Count(rSTores)] = nrstore_distance
}
//console(count(rStores))
function compareDistance(a,b){
if(a['Distance']<b['Distance'])
return -1;
if(a['Distance']>b['Distance'])
return 1;
return 0;
}
// Build the pop-up string
var popup = ''
nrStores = Sort(nrStores, compareDistance)
for(var nrStore in nrStores){
popup += nrStores[nrStore].NRStoreName + ": " + ROUND(nrStores[nrStore].Distance, 1) + "mi" +
TextFormatting.NewLine
}
//return pop-up string
When(Count(nrStores) == 0, TextFormatting.NewLine + TextFormatting.NewLine +
"No NonRetail within 2 miles of event",
Count(nrStores) == 1, TextFormatting.NewLine + TextFormatting.NewLine +
"1 NonRetail within 2 miles of event" + TextFormatting.NewLine
+ popup,
TextFormatting.NewLine + TextFormatting.NewLine +
Count(nrStores) + " NonRetail within 2 miles of event" + TextFormatting.NewLine
+ popup)
Solved! Go to Solution.
In lines 17 and 21, you're using rStores instead of nrStores, that might be it...
In lines 17 and 21, you're using rStores instead of nrStores, that might be it...