Sample to get the list of available layers on servers and show checkbox list

817
6
06-17-2014 12:17 AM
BiranchiPanda
New Contributor
I want to get list of layers (like roads/ports etc) from ArcGIS server and show them using a checkbox list on the map. I was unable to find samples on how to retrieve the available layers list. Any examples demonstrating this would be of much help...
0 Kudos
6 Replies
ManishkumarPatel
Occasional Contributor II
0 Kudos
BiranchiPanda
New Contributor
Hi, While the above example is helpful is toggling the layers list, I'm looking for he following things as well:
1. Getting list of available layers on server
2. Showing them on an accordion like control on the maps whose visibility can be toggled.

Thanks for your answer!
0 Kudos
KenBuja
MVP Esteemed Contributor
Take a look at this example that shows how checkboxes for all visible layers are added from multiple services.
0 Kudos
BiranchiPanda
New Contributor
Hey Ken,

Thanks for the great reply! It saved me a lot of time.


I'm now stuck and looking for the following features.

1. I want the layers checkbox to be visible but don't want to show them by default on page load. I tried doing the following, but this resulted in not showing the checkbox at all 😞

    map.on("layers-add-result", function (evt) {
        $.each(evt.layers[0], function (i, layer) {
            $.each(layer.layerInfos, function (index, info) {
                info.defaultVisibility = false;
            });
        });
        buildLayerList(evt);
    });


2. I want to show the checkboxes in a accordion like control inside the map area itself. To start with I placed the checkbox div inside the map div, but that resulted in blocking up the entire horizontal space for that much height. I tried with fixed width and relative/absolute placement... none worked.

Any hint/example would be of great help and would be much appreciated.

Thanks,
Biranchi
0 Kudos
KenBuja
MVP Esteemed Contributor
Are you trying to do something like this with an accordian panel?
0 Kudos
BiranchiPanda
New Contributor

Hi Ken Buja,

Sorry for the late reply. yes, I want to show the layers list in an accordion on the map itself. Any sample would be of great help!

Thanks,

Biranchi

0 Kudos