Skip to content

Commit

Permalink
Let the main map pass its filters to the keys
Browse files Browse the repository at this point in the history
  • Loading branch information
hlfan authored Dec 12, 2024
1 parent 61e8f83 commit 47e252d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions vendor/assets/leaflet/leaflet.osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ L.OSM.TileLayer = L.TileLayer.extend({

initialize: function (options) {
isDarkMap = OSM.isDarkMap();
options.filter = (isDarkMap ? options.darkFilter : options.lightFilter) || options.filter;
options.filter = (isDarkMap ? options.darkFilter : options.lightFilter) || options.filter || 'none';
options = L.Util.setOptions(this, options);
url = isDarkMap ? options.darkUrl : options.lightUrl;
if (url) this.schemeClass = isDarkMap ? 'dark' : 'light';
L.TileLayer.prototype.initialize.call(this, url || options.url);
this.on('add', function () {
if (this._container && this.schemeClass) this._container.classList.add(this.schemeClass);
if (this._container && this.options.filter) this._container.style.setProperty('--dark-mode-map-filter', this.options.filter);
if (this._container) {
if (this.schemeClass) this._container.classList.add(this.schemeClass);
this._container.style.setProperty('--dark-mode-map-filter', this.options.filter);
if (document.getElementById('map').contains(this._container)) document.querySelector('.key-ui').style.setProperty('--dark-mode-map-filter', this.options.filter);
}
});
}
});
Expand Down

0 comments on commit 47e252d

Please sign in to comment.