AnsweredAssumed Answered

TOC widget - group layers across multiple services

Question asked by ingenue3911 on Dec 14, 2016
Latest reply on Jan 25, 2017 by ingenue3911

This question is about NLiu's TOC widget. If i've understood correctly, the layerInfos for the TOC takes dynamic map services and feature layers. Our app includes services from various cities, with a service for each city's particular data category (e.g. City1_Water, City1_Electric, City1_Gas, City2_Water, City2_Electric, City2_Gas). I've integrated each as a dynamic map service.

 

So I currently added them to the TOC with success in this way. However, I'm looking to group things one level further, by City. Is there any way to do this out of the box? If not, any suggestions on tweaking the widget to do so?

toc = new TOC({
map: window.myMap,
layerInfos: [
 {
layer: City1_Water,
title: "City1_Water",
collapsed: true
},
{
layer: City1_Electric,
title: "City1_Electric",
collapsed: true
},
{
layer: City1_Gas,
title: "City1_Gas",
collapsed: true
},
{
layer: City2_Water,
title: "City2_Water",
collapsed: true
},
{
layer: City2_Electric,
title: "City2_Electric",
collapsed: true
},
{
layer: City2_Gas,
title: "City2_Gas",
collapsed: true
}
]
}, 'legendDiv');

Outcomes