Skip to content

Commit

Permalink
Change map filter when switching layers
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Dec 9, 2024
1 parent 7a70881 commit f660a1d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/assets/javascripts/leaflet.map.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,24 @@ L.OSM.Map = L.Map.extend({
},

updateLayers: function (layerParam) {
var layers = layerParam || "M",
layersAdded = "";
var layerCodes = layerParam || "M",
addedLayer;

for (var i = this.baseLayers.length - 1; i >= 0; i--) {
if (layers.indexOf(this.baseLayers[i].options.code) >= 0) {
if (layerCodes.indexOf(this.baseLayers[i].options.code) >= 0 && !addedLayer) {
this.addLayer(this.baseLayers[i]);
layersAdded = layersAdded + this.baseLayers[i].options.code;
} else if (i === 0 && layersAdded === "") {
addedLayer = this.baseLayers[i];
} else if (i === 0 && !addedLayer) {
this.addLayer(this.baseLayers[i]);
addedLayer = this.baseLayers[i];
} else {
this.removeLayer(this.baseLayers[i]);
}
}

if (addedLayer) {
$("body").css("--dark-mode-map-filter", addedLayer.options.darkFilter);
}
},

getLayersCode: function () {
Expand Down

0 comments on commit f660a1d

Please sign in to comment.