I have an html toggle button and try to toggle update between two layers (baselayer and earthlayer) when it's changed.
I am assigning a variable and change the value to the corresponding layer. Perhaps something is wrong and the layer is not getting updated.
var MapView = baseLayer;
$("#mapview").change(function () {//when toggle button is changed
if ($(this).is(':checked'))
MapView = earthlayer;
else
MapView = baseLayer;
});
var map = new ol.Map({
target: 'map',
layers: [MapView],
view: new ol.View({
center: ol.proj.fromLonLat([33.33386, 35.14710]),
zoom: 14
})
});