Bare with me on this...
The scenario I have is that I have users plot points on a map. These plotted points need a column populated with a unique value from other nearby points and lines ('id'). The issue I have is that these nearby points and lines are in different layers.
I am able to achieve when the nearby points are in one layer, however I am struggling to achieve this when there are multiple layers. Below is a snippet of the Arcade...
// FeatureClass2
var FeatureClass2 = FeatureSetById($map, /* Layer */ "***")
// Buffer FeatureClass1
var inspBuffer = Buffer($feature,1,'m')
// Undertake an intersection between FeatureClass2
// and FeatureClass1.
// These 2 should intersect when used correctly
var inspIntersection = Intersects(FeatureClass2, inspBuffer)
// Calculate the distance between the parcel and the current location
// Store the feature and distance as a dictionary and push it into an array
var featuresWithDistances = []
for (var f in inspIntersection) {
Push(featuresWithDistances,
{
'distance': Distance($feature, f, 'm'),
'feature': f
}
)
}
function sortByDistance(a, b) {
return a['distance'] - b['distance']
}
var sorted = Sort(featuresWithDistances, sortByDistance)
var closestFeatureWithDistance = First(sorted)
// If there is no id, return null
if (IsEmpty(closestFeatureWithDistance)) {
return `${closestFeatureWithDistance['feature']['id']}`
}
else {
return null
}
TIA