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:
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?
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP