Hello!
I have a web map with a point layer representing manholes and a point layer representing addresses. I am attempting to create an Arcade expression that will display the nearest address point in the popup of a selected manhole. I'm trying to do this by creating a buffer around the selected manhole, calculating the distance of each address point intersecting the buffer, and returning the address of the nearest address point. No matter how I format the code below (I won't get into everything that I've tried
), I do get one address point, but it is neither the nearest or the farthest manhole. I have tried sorting, ordering, and using compare functions for the intersecting address points, but I don't seem to have access to the distance value in order to grab the closest one. Can anyone tell me if I'm going about this the right way or if this is even possible? Thanks in advance!!!
var searchDist = 200;
var addresses = Intersects(FeatureSetById($map, "Primary_Address_3482"), Buffer( $feature, searchDist, "feet"));
var cnt = Count(addresses)
Console("Total Number of addresses within buffer: " + cnt);
var nearestaddress;
for (var f in addresses){
var addressDist = Round(Distance(f, $feature, "feet"),2);
Console(f.FULL_ADDR + ": " + " " + addressDist)
}
f.FULL_ADDR
