Hello
I have this code it was working before but right now is not working
//OnStreet
// If feature doesn't have geometry return null
if (IsEmpty(Geometry($feature))) { return null }
// Get the parcels layer
var portal = Portal("https://www.arcgis.com")
var parcels = FeatureSetByPortalItem(portal,"ItemID",0,['onstreet'], true)
// Buffer the current location and intersect with parcels
var bufferedLocation = Buffer($feature, 100, 'feet')
var candidateParcels = Intersects(parcels, bufferedLocation)
// 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 candidateParcels) {
Push(featuresWithDistances,
{
'distance': Distance($feature, f, 'feet'),
'feature': f
}
)
}
// Sort the candidate parcels by distance using a custom function
function sortByDistance(a, b) {
return a['distance'] - b['distance']
}
var sorted = Sort(featuresWithDistances, sortByDistance)
// Get the closest feature
var closestFeatureWithDistance = First(sorted)
// If there was no feature, return null
if (IsEmpty(closestFeatureWithDistance)) { return "Not Detected"}
// Return the address
return `${closestFeatureWithDistance['feature']['onstreet']}` I can't find why this isn't working