Select to view content in your preferred language

Change title text on arcgis-layer-list component

310
5
Jump to solution
05-09-2025 10:41 AM
PeterK
by
Occasional Contributor

I'm trying to change the top level text on the arcgis-layer-list component from 'Layer List' to 'Anything else' and can't figure out how to do it. 

PeterK_0-1746812299649.png

I don't see any properties other than 'label' which don't do it.  I've tried using Jquery to find the header tag elements and also tried searching for "heading" class and I can't seem to get to it.  I'm new to the calcite framework so I'm wondering what I'm missing.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Sage_Wall
Esri Regular Contributor

Hi @PeterK , this isn't currently possible, but I can see that it would be better if it were.  We'll take this under consideration and possibly add a property to set the header text in the future.

View solution in original post

0 Kudos
5 Replies
Sage_Wall
Esri Regular Contributor

Hi @PeterK , this isn't currently possible, but I can see that it would be better if it were.  We'll take this under consideration and possibly add a property to set the header text in the future.

0 Kudos
PeterK
by
Occasional Contributor

Thanks for the clarification, being new to web components I wasn't sure if I was missing some way to access the text.

0 Kudos
PeterK
by
Occasional Contributor

I was able to change the title text on the Layer List using the following method.  I'm not sure if this is the way to interact with web components but it seems to work.

Markup:

<arcgis-map basemap="arcgis/topographic" center="-111, 33" zoom="13" >
<arcgis-layer-list position="top-right" show-collapse-button show-heading visibility-appearance="checkbox" icon="legend-plus"></arcgis-layer-list>
</arcgis-map>

In require block:

setTimeout(function () {
const theLayerListHeader = document.querySelectorAll("calcite-flow-item")[0].shadowRoot.querySelectorAll('calcite-panel')[0].shadowRoot.querySelector('h2');
theLayerListHeader.innerText = 'Legend'
theLayerListHeader.style.fontSize = '17px';
}, 1000)

I tried using the argisReady event and onComponentReady promise methods but the layer list was not fully loaded as far as I could tell, so I fell back to a setTimeout block.  Many of the arcgisReady and onComponent methods don't seem to have a fully ready component, bit I may be missing something.

0 Kudos
Sage_Wall
Esri Regular Contributor

`arcgisReady` and `componentOnReady()` should fire off when all the publicly documented stuff is ready but we're venturing into the undocumented here 🙂.   I'm glad you figured something out though.

Just thinking about this a little more another option would be to wrap your `arcgis-layer-list` in a `calcite-block` or `calcite-panel`.  Then if you turn off the header in the layer list you could add whatever you wanted as the heading in the calcite component.

https://codepen.io/sagewall/pen/zxxVdam

 

0 Kudos
PeterK
by
Occasional Contributor

That works too, thanks for the alternate solution!

0 Kudos