if (!featureLayerB) { }
featureLayerB.show()
featureLayerB.hide()
Thanks Jeff i try it.
Create a list of layers with HTML.For each layer there should be a checkbox (input element) and an associated labelAdd a data-layerid attribute to the checkbox with the id of the associated layer. (You can call this attribute whatever you want as long as it starts with data-)Create a single event handler function for the checkboxes' click events. This function will do the following:Get the layer ID from the data-layerid attribute of the checkbox that was clicked. (The specific checkbox can be accessed in the function via the this keyword.)Retrieve the associated layer from the map using the layer id.Either show or hide the layer, depending on if the checkbox is checked or not.Add the event handler to the checkboxes.If you don't have to worry about supporting old versions of IE, use addEventListenerIf you need to support old versions of IE, use jQuery's event handling code (i think it's called .click())
thanks guys for the answer.I saw these examples but I'm trying to create a layer list for mobile with jquery mobile and using these examples is changed the style of my check box. I'm a flex developer and i'm new of javascript world.Is there any example for layer list in mobile device?Thanks
If you're looking to turn off a single layer within the map service, take a look at nliu's Table of Contents(TOC)/Legend Widget.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.