HI I want to write an Arcade expression in a pop up.
I have two polygon layers in my web map
Suburb polygon and Flood polygon
I want to appear the name of the suburb in the flood event pop up when click on the suburb layer
My expression is
var SI = FeatureSetByName($map,"Suburb")
var int = First(Intersects($feature, SI))
return int.Suburb
The expression returns a suburb name but it returns the same name all the time for example "suburb 1". If I click in another suburb it still return the name "suburb 1"
Solved! Go to Solution.
Hi @Greta
When you click on the flood area you want to see the suburb at the location where you clicked. The problem is that when you start with the flood area polygon it will use the entire polygon to see what suburbs it intersects with and when your flood area polygon is large it will intersect with a large number of suburbs. At this moment it is not possible in the Arcade expression to have access to the location where the user clicked and therewith being able to return a single suburb at the location. You will have in the pop-up a button to go through all the features at the location where the user clicked and have access to the suburb, but not as you want in the pop-up of the flood area:
You could also go a little further and present information of multiple suburbs and the % of the area that the flood area covers the suburb. There are many possibilities.
I have created an idea to provide access to the location clicked, but it is not implemented yet. Hopefully, this will happen soon.
Hoi @Ade_Bruijn ,
Your expression is close, but when you intersect the "wijken" layer with a "buurt", you obtain a featureset or in other words a collection of features even if there is only one feature. You will have to take for instance the first wijk found and then you can access the attribute that contains the name fo the "wijk".
var wijken = FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310");
var wijk = First(Intersects(wijken, $feature));
return wijk["VeldNaamVanVeldMetWijkNaam"];
There is a potential catch... it is possible that a neighboring "wijk" is also returned and to avoid obtaining the wrong "wijk" name you could do a negative buffer to reduce the size of the "buurt" (current feature) and ensure that you get the right "wijk". An example you can find below:
var wijken = FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310");
var buf = Buffer($feature, -1, "meter");
var wijk = First(Intersects(wijken, buf));
return wijk["VeldNaamVanVeldMetWijkNaam"];
Hi @Greta
When you click on the flood area you want to see the suburb at the location where you clicked. The problem is that when you start with the flood area polygon it will use the entire polygon to see what suburbs it intersects with and when your flood area polygon is large it will intersect with a large number of suburbs. At this moment it is not possible in the Arcade expression to have access to the location where the user clicked and therewith being able to return a single suburb at the location. You will have in the pop-up a button to go through all the features at the location where the user clicked and have access to the suburb, but not as you want in the pop-up of the flood area:
You could also go a little further and present information of multiple suburbs and the % of the area that the flood area covers the suburb. There are many possibilities.
I have created an idea to provide access to the location clicked, but it is not implemented yet. Hopefully, this will happen soon.
Any chance you can link to this idea so I can give it my support?
I have created an idea to provide access to the location clicked, but it is not implemented yet. Hopefully, this will happen soon.
Hi @CBarrett ,
Thanks for your support. You can find the link below: https://community.esri.com/t5/arcgis-online-internal-ideas/provide-the-location-clicked-in-the-pop-u... (although this is an internal idea, and it might not be available to everyone)...
Thank you
Hi,
I have a similar question but I'm not sure despite answer @XanderBakker if it's possible or not. So I will describe the case. Two polygon layers, one with districts (wijken) and the other with smaller polygons, neighbourhoods (buurten). I want the name of the district to apear in the popup of the neighbourhood. I tried several Arcade Geometry Functions Contains, Within and Intersects.
var wijken=FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310")
var wijk=Intersects(wijken,$feature)
return wijk
Hoi @Ade_Bruijn ,
Your expression is close, but when you intersect the "wijken" layer with a "buurt", you obtain a featureset or in other words a collection of features even if there is only one feature. You will have to take for instance the first wijk found and then you can access the attribute that contains the name fo the "wijk".
var wijken = FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310");
var wijk = First(Intersects(wijken, $feature));
return wijk["VeldNaamVanVeldMetWijkNaam"];
There is a potential catch... it is possible that a neighboring "wijk" is also returned and to avoid obtaining the wrong "wijk" name you could do a negative buffer to reduce the size of the "buurt" (current feature) and ensure that you get the right "wijk". An example you can find below:
var wijken = FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310");
var buf = Buffer($feature, -1, "meter");
var wijk = First(Intersects(wijken, buf));
return wijk["VeldNaamVanVeldMetWijkNaam"];
Thank you @XanderBakker ,
Exactly what I wanted to achieve. And of course I needed also the negative buffer. Simple but effective trick.
Groeten Anne