[openstreetmap/openstreetmap-website] Use dark mode map tiles in embed (PR #5522)

Holger Jeromin notifications at github.com
Wed Jan 22 18:33:56 UTC 2025


@HolgerJeromin commented on this pull request.



> @@ -37,17 +36,17 @@ window.onload = function () {
   map.attributionControl.setPrefix('');
   map.removeControl(map.attributionControl);
 
-  if (args.layer === "cyclosm") {
-    new L.OSM.CyclOSM().addTo(map);
-  } else if (args.layer === "cyclemap" || args.layer === "cycle map") {
-    new L.OSM.CycleMap(thunderforestOptions).addTo(map);
-  } else if (args.layer === "transportmap") {
-    new L.OSM.TransportMap(thunderforestOptions).addTo(map);
-  } else if (args.layer === "hot") {
-    new L.OSM.HOT().addTo(map);
-  } else {
-    new L.OSM.Mapnik(mapnikOptions).addTo(map);
-  }
+  var isDarkTheme = args.theme === "dark" || args.theme !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches;

Yes. Much easier.
The code formatter [prettier](https://prettier.io/playground/) returns this (with some line breaks):
```js
var isDarkTheme = args.theme === "dark" || (args.theme !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches);


-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5522#discussion_r1925790520
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5522/review/2567990014 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250122/9cb759a4/attachment-0001.htm>


More information about the rails-dev mailing list