AnsweredAssumed Answered

visible layers with checkbox

Question asked by lmagudo on Apr 21, 2014
Latest reply on Apr 22, 2014 by timw1984dev
Hi everybody,

I´m trying to use checkbox in order to add or remove my layers on the map. I´m using dojo.on, when change my checkbox I use updateLayerVisibility function:

        map.addLayers([mangroves, coldcoral, marineEcoregions, pelagicProvinces, wmsLayer]);                  on(dom.byId("mangroves"), "change", updateLayerVisibility);         on(dom.byId("coldcoral"), "change", updateLayerVisibility);         on(dom.byId("marineEcoregions"), "change", updateLayerVisibility);         on(dom.byId("pelagicProvinces"), "change", updateLayerVisibility);          function updateLayerVisibility() {             //var visibleLayerIds = []                         var inputs = query(".list_item");             var inputCount = inputs.length;             map.removeAllLayers();             map.setBasemap("oceans");              for (var i = 0; i < inputCount; i++) {                 if (inputs[i].checked) {                     //visibleLayerIds.push(inputs[i].value);                     map.addLayer(inputs[i].value);                 }                 if (inputs[i].checked == false) {                     map.removeLayer(inputs[i].value)                 }             }         }


But I have a problem with the map.addLayer() sentence. When I checked/unchecked in this sentence I have a exception:

"uncaught exception: lang.hitch: scope["onLoad"] is null (scope="[object Window]")".

I can´t understand where is the error...:confused:

thank you..

Outcomes