Select to view content in your preferred language

How to show a description stored in another layer in a pop up window

229
3
05-29-2024 06:26 AM
SanchezNuñez
Occasional Contributor

Good morning,

I am looking for a way, I guess using Arcade to show the Description in a popup windows stored in another layer.

For example a point , that stores the Municipality Code and the Commission ID code. How can I display when a user identifies  the point, an attribute that is stored on the Municipality layer or Commission District Layer. For example the Municipality Name,  City Hall address, or the Commissioner's Name.

Is there a way in Arcade to retrieve using a Code the description from another layer and show it in the popup window?

 

 

 

 

0 Kudos
3 Replies
jcarlson
MVP Esteemed Contributor

Yes, there is! You can use one of the various FeatureSet functions. If the other layer is in the name, it might look like this:

var fs = FeatureSetByName(
  $map,
  'Municipality',
  ['name', 'city_hall_address', 'commissioner_name'], // the fields you want to access
  true
)

// get the underlying municipality
var xs_feat = First(Intersects($feature, fs))

// return an attribute
return xs_feat['city_hall_address']

 

If you're going to bring multiple fields into the popup, I would suggest using an Arcade popup element and building a field list. That way the features only have to intersect once to get all your values, rather than running for each attribute.

- Josh Carlson
Kendall County GIS
0 Kudos
SanchezNuñez
Occasional Contributor

Hi @jcarlson 

How do I look now for a field located in another point layer that does not intersect.

Let's say that I am looking for a way to show a property address, for a point that has a Folio Number, and the property layer is a centroid. So I need to  query the Feature, instead of doing an intersect, using the Folio number.

 

Thanks

 

 

0 Kudos
jcarlson
MVP Esteemed Contributor

You can use the Filter function for this.

var fs = FeatureSetByName(
  $map,
  'Municipality',
  ['some_field'],
  false // don't need geometry for attribute filter
)

var filt = Filter(fs, `some_field = '${$feature['some_field']}'`)

// sometimes filtering returns nothing, and trying to access records will throw an error. by checking the output of the filter first, we can adjust for this

return Iif(
  Count(filt) > 0,
  First(filt)['some_field'],
  'No Corresponding Feature Found'
)

 

- Josh Carlson
Kendall County GIS
0 Kudos