TransWikia.com

How to configure grouped layers in the LayerList widget with feature layers

Geographic Information Systems Asked on June 21, 2021

This applies to the ArcGIS Server JavaScript API v4.x.

This LayerList widget example code contains grouped layers, whereby the San Francisco parent checkbox also controls its child layers:

enter image description here

The example code uses a WebScene document as the source for the layers, but in my case I’m manually creating the layers as FeatureLayer objects, and adding them to a Map object, using the pattern:

const myMap = new Map({basemap: "streets-vector"});
const layer1 = new FeatureLayer({url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"});
const layer2 = new FeatureLayer({url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/1"});
myMap.addMany([layer1,layer2]);

Using this pattern, is it possible to create layer groups/hierarchies, ie create a parent checkbox for layer1 and layer2?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP