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