Select to view content in your preferred language

Popup Content with Layer ID

316
2
09-14-2022 05:55 AM
MichaelK1
New Contributor III

Is it possible to show layer id in a popup's template ?

layer expression:

{
name: "layer",
title: "layer",
expression: "$layer.id"
}

https://codepen.io/michaelk95/pen/NWwyxyE

0 Kudos
2 Replies
DougLogsdon2
New Contributor III

The global name "$layer" is misleading. It actually represents the FeatureSet of all features in the same layer as the Popup's feature:

ArcGIS Arcade > FeatureSet

I suggest adding a feature attribute for the id/title.

0 Kudos
LaurenBoyd
Esri Contributor

Hi @MichaelK1 -

You could access the layer ID of the current selected feature by creating your content from a function like this: 

layer.popupTemplate = {
    title: "{ObjectId} | {length}",
    expressionInfos: [{
        name: "length",
        expression: "$feature.length"
    }],
    // Create content from function and refernece the feature's layer id
    content: ((event) => {
        return `{length} | ${event.graphic.layer.id}`;
    })
};

You can still reference expressions within the function as well. Here's an updated codepen: https://codepen.io/laurenb14/pen/gOzLExz?editors=1000

Hope this helps!

Lauren
0 Kudos