Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pull/5507'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Jan 18, 2025
2 parents 8312ddf + e066ed3 commit 09aa3cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/assets/javascripts/leaflet.map.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ L.OSM.Map = L.Map.extend({
layerOptions.apikey = OSM[value];
} else if (property === "leafletOsmId") {
layerConstructor = L.OSM[value];
} else if (property === "leafletOsmDarkId" && OSM.isDarkMap() && L.OSM[value]) {
layerConstructor = L.OSM[value];
} else {
layerOptions[property] = value;
}
Expand Down Expand Up @@ -386,6 +388,14 @@ L.extend(L.Icon.Default.prototype, {
}
});

OSM.isDarkMap = function () {
var mapTheme = $("body").attr("data-map-theme");
if (mapTheme) return mapTheme === "dark";
var siteTheme = $("html").attr("data-bs-theme");
if (siteTheme) return siteTheme === "dark";
return window.matchMedia("(prefers-color-scheme: dark)").matches;
};

OSM.getUserIcon = function (url) {
return L.icon({
iconUrl: url || OSM.MARKER_RED,
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

body {
font-size: $typeheight;
--dark-mode-map-filter: brightness(.8);
--dark-mode-map-filter: none;
}

time[title] {
Expand Down
1 change: 1 addition & 0 deletions config/layers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
href: "https://www.thunderforest.com/"

- leafletOsmId: "TransportMap"
leafletOsmDarkId: "TransportDarkMap"
code: "T"
layerId: "transportmap"
nameId: "transport_map"
Expand Down

0 comments on commit 09aa3cc

Please sign in to comment.