Select to view content in your preferred language

541
3
04-04-2023 02:47 AM
Labels (1)
New Contributor II

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?

1 Solution

Accepted Solutions
by
MVP Esteemed Contributor

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')``````

- Josh Carlson
Kendall County GIS
3 Replies
by
MVP Esteemed Contributor

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')``````

- Josh Carlson
Kendall County GIS
New Contributor II

It Works! Thx

New Contributor II

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?