Two part question here. I was hoping to get some help expanding on the functionality of both the Home component and also the LayerList component.
#1 - How can you change a layer's visibility setting when the user clicks the Home button? (Example: the users has turned on all the layers and I would like the Home button to not only return to the default extent but also the default layers visible.)
#2 - I would like to add the ZoomTo button to the layers in the LayerList. I can add the symbol to the layer but can't get it to trigger.
I have been able to do these using widgets but struggling converting to components.
For simplicity sake the code I provided is just an expanded version of the code from ESRI's LayerList example
I appreciate any help
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<title>Map components LayerList Example</title>
<link rel="icon" href="data:;base64,=" />
<style>
html,
body {
margin: 0;
}
.tool-container {
display: flex;
gap: 0.5rem;
}
arcgis-map {
display: block;
height: 100vh;
}
</style>
<!-- Load Calcite Components-->
<!-- Load the ArcGIS Maps SDK for JavaScript -->
</head>
<body>
<arcgis-map
item-id="237b9584339446a0b56317b5962a4971">
<arcgis-home>
</arcgis-home>
<arcgis-layer-list
position="bottom-left">
</arcgis-layer-list>
</arcgis-map>
<script>
async function load() {
const Layer = await $arcgis.import("esri/layers/Layer");
// Reference the map component
const mapElem = document.querySelector("arcgis-map");
mapElem.addEventListener("arcgisViewReadyChange", () => {
}, { once: true });
};
load();
document.querySelector("arcgis-layer-list").listItemCreatedFunction = (event) => {
const { item } = event;
// Exclude group layers, otherwise the legend will be displayed twice
if (item.layer.type != "group") {
item.panel = {
content: "legend",
open: false,
};
}
}
</script>
(https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-layer-list/)