How to show overlapping features in popup if the features are within the same layer?

1193
3
09-29-2020 06:04 AM
RVx_GaslineGiS
New Contributor III

I have had no problem following the very informative blog posts and GeoNet threads on using Arcade expressions to show information from multiple overlapping layers in a single popup. However, I have a tangentially related issue that I couldn't figure out how to do using FeatureSets and Intersects in Arcade.

I have a layer with multiple overlapping polygons. There are basically 2-11 duplicate polygons for each area. For various reasons due to back infrastructure and reasons I don't understand, we can't condense these into a single polygon with multiple attribute fields. I would like to have the popup for each of these show only a single time while showing a single selected field from each of the other overlapping features. However, I'm not sure how to do this or if it can even be done.

So I suppose:

1) Is it possible to reference overlapping polygons within a single feature layer in a single popup?

2) And where would I start using Arcade to do that?

0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor

Hi Robert Domiano ,

First of all, if there is any way to filter the layer and only show a single polygon, that would speed up performance. You can use the intersect of the $layer with the $feature to access the overlapping polygons, but depending if they are exactly the same or differ in size (and how much) you might have to apply a buffer with a negative value to avoid selecting neighboring polygons. The downside is that when you click a polygon, and it finds 11 polygons at that spot, it will do the intersect 11 times, once for each polygon the user clicked on. So, is it possible: yes. Will it perform and give a friendly experience: probably not so much. I would probably try and change the input polygon data and structure it differently, but it this depends on the dependencies you may have at a polygon level with other data or specific requirements to store it in this way.

If you intersect the polygon regions with a layer that contains a single polygon with the entire area, you will end up intersecting every overlapping polygon and the ObjectID will help you identify the specific overlap case of the new polygon.

0 Kudos
RVx_GaslineGiS
New Contributor III

Thank you for the help!

I don't believe there is a good way to filter the polygons. The fields are identical for all overlapping polygons (they directly overlap and are essentially duplicates) except for two fields: The name of an attachment and a URL to that attachment.  I'm not sure why this is the setup, and have no authority on making changes to the process so changes to the polygon data is unfortunately not possible.

Since all the fields but for two are identical, I don't care which polygon shows the popup. I'd like to basically have it so instead of 2+ popups, I can have one popup and that popup will create a list of all the Attachment names + attachment URL in a single popup.

I used $feature and $layer as you noted, and was able to produce an ugly and disorganized list (really wish I could output HTML in the arcade expressions on Portal..)

It works and I end up with the below, but the main problem is I still have the 2+ popups showing up for every single polygon. Is there a way to have another expression or add to this expression a way to grab the first instance of Intersects and output only that one?

var int = Intersects($layer, $feature);
var cnt = Count(int);
var result = "";

if (cnt > 0) {
    for (var i in int) {
        var attach = i.WorkOrdersMonthly_DOCUMENT_ + ":" + i.WorkOrdersMonthly_URLNAME;
        result += TextFormatting.NewLine + attach;
    }
} else {
    result = "No Layers";
}
return result

XanderBakker
Esri Esteemed Contributor

Hi Robert Domiano ,

It works and I end up with the below, but the main problem is I still have the 2+ popups showing up for every single polygon. Is there a way to have another expression or add to this expression a way to grab the first instance of Intersects and output only that one?

The problem is that the expression is executed at the feature level. And when the user clicks con a feature, it will drill down to find all features it can find at that location. Unfortunately, there is no setting in the web map like you have in ArcGIS Pro (or ArcMap) to just return the top feature. 

Normally this type of data would be stored in a polygon layer with 0:n attachments configured for each polygon. A single polygon can have multiple attachments, avoiding the storage of multiple polygon at the same location. Although you don't have authority to change the data, you could derive a layer form this data that is following the correct storage (in case the data is static). If the data changes, since it is still being edited, I might be could to point out to the curator that this is most likely not the recommended way to manage the data. Continuing on this track is likely to produce more challenges on the road ahead.

0 Kudos