Hi, I would to show the list of nearest substations in the popup of the areas that I'm drawing.
I've managed to get it in the console but I cannot return a list; it would be gret if i could display the first 3 from the nearest
var substat= FeatureSetByName($map,"OSM SUBSTATION",["operator"])
var searchDistance = 10;
var inrangesubstat = Intersects( substat, Buffer( $feature, searchDistance, "kilometers") );
var cnt = Count(inrangesubstat)
Console("Total Number of addresses within "+searchDistance+ "km buffer: " + cnt);
var min_dist = infinity;
for (var f in inrangesubstat){
var substDist = Round(Distance(f,$feature,"kilometers"),2);
if (substDist < min_dist) {
inrangesubstat = f.operator;
min_dist = substDist;
}
console(f.operator + ": " + " " + substDist);
}
return f.operator+": at " + " " + substDist+" km"
thanks
Solved! Go to Solution.
I'm guessing that the Intersects function isn't returning any values for the value nearbyCities.
Major facepalm moment, the situation I was looking at was not within 2 miles. Thank you again for the help. Also quick question - wanting to learn more about arcade and the language of it, any recommendations? I am able to copy and paste but I do not fully understand why certain syntax is the way it is. Would it be helpful to go and learn python, html?
Start with the Arcade documentation to get a better understanding of all the functions and how to use them.
I would also suggest the Esri Training site. They have several lessons (videos or web courses) that are free or could be covered by a maintenance agreement. They also have curated learning plans (such as this one) that are more guided.