I am trying to make a map media query for phones and make the zoom decrease to 8. However, this doesn't seem to work, the map doesn't decrease zoom when I set the width, is there any error in this code?
window.addEventListener('resize', function(event){
var width = this.document.documentElement.clientWidth;
console.log(width);
if (width < 376) {
map.setZoom(8);
} else {
map.setZoom(10);
}
});