Hi,
In one of my projects, I have a relationship between two layers (child → parent). This works fine, but I would like to display different popup content depending on the following cases:
- Child layer popup is displayed inside the parent popup: The user clicks on a parent feature, and the parent popup is displayed along with the child content popup embedded within it.
- Child layer popup is displayed “normally”: The user clicks directly on a feature of the child layer.
For example, I would like to display children in a compact way inside the parent popup, while also being able to have a different style or include more content if the child popup is displayed independently.
Below is an example: I have a parent layer named “Groupes Habitations” with a child layer (“Parcelles Exemples”) listing the parcels associated with this “Groupes Habitations.” I also have a layer named “Parcelles Exemple.” Currently, the popup content is the same in both cases. However, I would like to customize the popup content for “Parcelles Exemple” when displayed independently.
Do you have any suggestions on how I could achieve this?
Have you considered using the new web component available since LWC 3.8 :
See original PR: New Lizmap web component lizmap-features-table to display a compact list of features by mdouchin · Pull Request #4502 · 3liz/lizmap-web-client · GitHub
See demo (click on a quarter to display its popup): https://sandbox.lizmap.com/lizmap_3_8/index.php/view/map?repository=tests&project=lizmap_features_table
This will display a compact list of features, and you can click on one feature to see its popup.
We plan to allow the editor to choose this new compact display as a replacement of the current list of child popup in the plugin.
1 Like
That’s really interesting! I wasn’t aware of this new feature, and it’s exactly what I’ve been looking for.
In your example, the value is hard-coded. I’ve tried this feature with a hard-coded value, and it works perfectly. However, I’m struggling to understand how to use the filter attribute with values from the parent layer. How can I reference a “parent” value in this context?
For example, in my case, the relationship between the parent and child is N:M. I need to filter my join table using the parent ID to retrieve all the child IDs. In other words, I have a list of parcel IDs associated with the parent, and I need to check if the current parcel ID is in that list.
Here’s the expression I’m using. I’ve tried different one (using attribute(@parent,'id')
for example) but without success:
with_variable(
'id_groupe',
"id", -- This is the parent ID
array_contains(
aggregate(
layer:='many_groupes_habitations_has_many_gh_parcelles', -- This is my join table
aggregate:='array_agg',
expression:="id_gh_parcelles", -- Parcel IDs in the join table
filter:="id_groupes_habitations" = @id_groupe -- Filter the join table using the parent ID
), id) -- Check if the parcel ID is in the list. But does `id` here actually refer to the child ID?
)
I’ve tried different filters, but I keep getting the error message:
“An error occurred while getting the display name for the features!”
Could you provide an example of how to properly reference a parent value in the filter expression?
Thanks in advance for your help!
Hi @kimaidou,
I would like to know if you could me to understand how the filter expression works. I don’t understand very well how to refer to the parent.
Please, would it be possible to give m an example ?
Thanks