I'd like to use an Arcade Function to populate the Road Name for a Work Zone Layer based off an underlying Road layer. The issue that I'm running into is that the expression is pulling the name from an intersecting road and not from the main line that I'm digitizing along.
// Create a feature set using the 'All Roads' layer in the map
var roads = FeatureSetByName($map, 'All Roadways', ['MAP_LBL'])
// Intersect the current location with the road and
// get the first road
var road = First(Intersects($feature, roads))
// If the current location does intersect a feature,
// return the name of the road. Otherwise, return null
if (!IsEmpty(road)) {
return road['MAP_LBL']
} else {
return null
}
So I'm not 100% sure if this is true, but from my testing on my own datasets, First() will grab the lowest (ie first created) object ID of the intersecting features. It's possible that's what you're running into. Are there any other fields that might match, like a roadway ID that is unique to a particular road? Then you could use the filter function instead of intersects?