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
The global name "$layer" is misleading. It actually represents the FeatureSet of all features in the same layer as the Popup's feature:
I suggest adding a feature attribute for the id/title.
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!