Hi! I would like a Arcade script for a popup that shows me all the features within a buffer from one layer with their distances to the selected feature in an other layer.
for example: I selected an adress. The popup has to show all the schools by name within a distance of 10km, followed by their distance to the selected adress.
Can anyone help me?
Solved! Go to Solution.
This is certainly possible. Including spatial operations in a popup expression can cause your expression to take a bit longer to evaluate, but it's not too hard to put together.
// create the 10km buffer
var buff = Buffer($feature, 10, 'kilometers')
// get intersecting schools
var xs_schools = Intersects(buff, FeatureSetByName($map, 'school_layer_name'))
// loop through the returned schools and populate an array
var school_list = []
for (var s in xs_schools) {
// get distance
var dist = Distance(s, $feature, 'kilometers')
// push a formatted string to the school_list array
Push(school_list, `${s['school_name_field']}: ${Text(dist, '#,###.0')} km away`)
// return a newline-delimited string from your array
return Concatenate(school_list, '\n')
This is certainly possible. Including spatial operations in a popup expression can cause your expression to take a bit longer to evaluate, but it's not too hard to put together.
// create the 10km buffer
var buff = Buffer($feature, 10, 'kilometers')
// get intersecting schools
var xs_schools = Intersects(buff, FeatureSetByName($map, 'school_layer_name'))
// loop through the returned schools and populate an array
var school_list = []
for (var s in xs_schools) {
// get distance
var dist = Distance(s, $feature, 'kilometers')
// push a formatted string to the school_list array
Push(school_list, `${s['school_name_field']}: ${Text(dist, '#,###.0')} km away`)
// return a newline-delimited string from your array
return Concatenate(school_list, '\n')
It Works! Thx
Hi! I would like a Arcade script for a popup that shows me all the features within a buffer from one layer with their distances to the selected feature in an other layer.
for example: I selected an adress. The popup has to show all the schools by name within a distance of 10km, followed by their distance to the selected adress.
Can anyone help me?