Show 1:M relationships in pop-up:

485
2
06-15-2021 12:31 AM
Labels (1)
VitaRashchuk
New Contributor II

I have relation in two layers (building layer and table of item description - 1:M). When i configurate pop-up in Map Viewer classic i see statistic information (not real relation information). But in my map I want to use related layers instead of one because is more advantageous for what I need to do. I would like all the information of object to be displayed in a pop-up window, similar to ArcMap or ArcGIS Pro

VitaRashchuk_1-1623741844055.png

 

 

0 Kudos
2 Replies
jcarlson
MVP Notable Contributor

The related records need to be aggregated in some way for them to show up in the "main" popup, though you can click show related records at the bottom to browse through the records.

If you wanted to show a list of related features, you can use FeatureSetByRelationshipName. You'll find, though, that you cannot have a FeatureSet itself be part of the popup. Instead, you'll have to access individual features or attributes to assemble an output string or array.

Here's an example of a parcel polygon with a related lines layer.

var related = FeatureSetByRelationshipName($feature,"Lines")

var out_str = 'Related Records:'

for (var r in related){
    out_str += `\n${r.sequenceid}\t${r.category}\t${Round(r.distance)}`
}

return out_str

Which returns:

jcarlson_0-1623764443846.png

You'll probably want to do some other formatting with those strings. You could also do something like make your popup into an HTML table with each attribute as its own list. Here's the popup HTML:

<table style="width:90%">
  <tbody><tr>
    <td>Sequence ID</td>
    <td>Category</td>
    <td>Distance</td>
  </tr>
  <tr>
    <td>{expression/expr1}</td>
    <td>{expression/expr2}</td>
    <td>{expression/expr3}</td>
  </tr>
</tbody></table>

 

And here's one of the individual expressions:

var related = FeatureSetByRelationshipName($feature,"Lines")

var out_str = ''

for (var r in related){
    out_str += `${Round(r.distance)}\n`
}

return out_str

 

Which returns:

jcarlson_1-1623764929822.png

That's looking a little better! With additional formatting in the HTML for alignment, font, maybe column colors, etc, you could have a nice list of related records added to your popup.

- Josh Carlson
Kendall County GIS
0 Kudos
VitaRashchuk
New Contributor II

Thanks for your advice)

I will try to customize the popup using your examples.

0 Kudos