Just a simple script to have a new point search for the nearest property and update a text field with the new address. Seem to work fine in the Online version, but in Field Maps it gives me a "Failed to Calculate" message.
var searchDist = 100;
var addresses = Intersects(FeatureSetByName($map, "Parcels"), Buffer( $feature, searchDist, "feet"));
var nearestaddress = "";
var min_dist = 150;
for (var f in addresses){
var addressDist = Round(Distance(f, $feature, "feet"),2);
if (addressDist < min_dist) {
nearestaddress = f.PROP_ADD1;
min_dist = addressDist;
}
}
return nearestaddress;