I am trying to add and remove layers2
layer when checkbox is changed. How can I do it with jquery?
Following my way i get: Uncaught ReferenceError: layers is not defined
var wmsLayer2 = new ol.layer.Image({
source: wmsSource2
});
$("#Buildings_chkbx").change(function(){
var bool = !bool;
if(bool)
layers.push(wmsLayer2);
else
//remove layer...
});
var map = new ol.Map({
target: 'map',
layers: [baseLayer, wmsLayer],
view: new ol.View({
center: ol.proj.fromLonLat([33.33386, 35.14710]),
zoom: 14
})
});
Uncaught ReferenceError: layers is not defined
layers
? Where do you define it?