require(["dojo/on", "dojo/dom"], function (on, dom) { function updateLayerVisibility() { ... } on(dom.byId("myCheckbox"),"click",updateLayerVisibility); });
require(["dojo/dom"], function (dom) { Dom.byId(); // This will fail because its using a capital, dom.byId(); // This is the right way });
"esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/ImageParameters"
function(...ArcGISDynamicMapServiceLayer, ImageParameters,...)
var layer, map, visible = [];
//Use the ImageParameters to set the visible layers in the map service during ArcGISDynamicMapServiceLayer construction. var imageParameters = new esri.layers.ImageParameters(); imageParameters.layerIds = [0]; imageParameters.layerOption = esri.layers.ImageParameters.LAYER_OPTION_SHOW; //can also be: LAYER_OPTION_EXCLUDE, LAYER_OPTION_HIDE, LAYER_OPTION_INCLUDE layer = esri.layers.ArcGISDynamicMapServiceLayer("http://my/MapServer", {"imageParameters":imageParameters}); map.addLayer(layer);
function updateLayerVisibility() { var inputs = dojo.query(".list_item"), input; //in this application layer 2 is always on. visible = [0]; for (var i=0, il=inputs.length; i<il; i++) { if (inputs.checked) { visible.push(inputs.id); } } //if there aren't any layers visible set the array value to = -1 if(visible.length === 0){ visible.push(-1); } layer.setVisibleLayers(visible); }
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.