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;
}
}
});
- map._objectLayer.interestingNode = function (node, ways, relations) {
+ map._objectLayer.interestingNode = function (node, wayNodes, relationNodes) {
if (object.type === "node") {
return true;
} else if (object.type === "relation") {
- for (var i = 0; i < relations.length; i++) {
- if (relations[i].members.indexOf(node) !== -1) return true;
- }
+ return Boolean(relationNodes[node.id]);
} else {
return false;
}
}
});
+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,