I want to change the background color on zoom.my current background color of the map is blue which I have assigned in the CSS file. on my map I have some markers .when I click on marker it zooms to a specific location on raster tiles. when my map zooms to raster tiles I want to change the map background color to white. How can I change map background color after a certain zoom level
1 Answer
Listen on the zoom event and then add the css class for the zoom.
L.DomUtil.addClass(map.getContainer(),'blue-bg');
map.on('zoom',(e)=>{
var zoom = map.getZoom();
if(zoom > 13){
L.DomUtil.addClass(map.getContainer(),'white-bg');
L.DomUtil.removeClass(map.getContainer(),'blue-bg');
}else{
L.DomUtil.removeClass(map.getContainer(),'white-bg');
L.DomUtil.addClass(map.getContainer(),'blue-bg');
}
});
-
Falke Design Thank you so much. This solved my problem. You are a Saviour. Sep 1, 2020 at 8:29