Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"maxZoom": 19,
"attribution": "<a href='https://github.com/freifunk/meshviewer/issues' target='_blank'>Report Bug</a> | Map data &copy; <a href\"http://openstreetmap.org\">OpenStreetMap</a> contributor"
}
},
{
"name": "BaseMap.de (Vektor)",
"url": "https://sgx.geodatenzentrum.de/gdz_basemapworld_vektor/styles/bm_web_wld_col.json",
"type": "vector",
"config": {
"attribution": "&copy; basemap.de / <a href='https://www.bkg.bund.de'>BKG</a> (2025) <a href='https://creativecommons.org/licenses/by/4.0/'>CC BY 4.0</a>; Datenquellen: &copy; GeoBasis-DE / <a href='https://www.bkg.bund.de'>BKG</a> (2025) <a href='https://creativecommons.org/licenses/by/4.0/'>CC BY 4.0</a>; außerhalb Deutschlands: &copy; <a href='https://www.openstreetmap.org/copyright'>Open Street Map Mitwirkende ODbL v. 1.0</a> ; © <a href='https://openmaptiles.org/'>OpenMapTiles</a>"
}
}
],
"fixedCenter": [
Expand Down
1 change: 1 addition & 0 deletions lib/config_default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface Link {
export interface MapLayer {
name: string;
url: string;
type?: string;
config: GridLayerOptions & {
start?: number; // Hour
end?: number; // Hour
Expand Down
22 changes: 14 additions & 8 deletions lib/map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as L from "leaflet";
import "@maplibre/maplibre-gl-leaflet";

import { ClientLayer } from "./map/clientlayer.js";
import { LabelLayer } from "./map/labellayer.js";
Expand Down Expand Up @@ -47,7 +48,7 @@ export const Map = function (linkScale: (t: any) => any, sidebar: ReturnType<typ
function mapActiveArea() {
map.setActiveArea({
position: "absolute",
left: sidebar.getWidth() + "px",
left: 0,
right: 0,
top: 0,
bottom: 0,
Expand Down Expand Up @@ -83,13 +84,18 @@ export const Map = function (linkScale: (t: any) => any, sidebar: ReturnType<typ
let layers = config.mapLayers.map(function (layer) {
return {
name: layer.name,
layer: L.tileLayer(
layer.url.replace(
"{format}",
document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp") === 0 ? "webp" : "png",
),
layer.config,
),
layer:
layer.type == "vector"
? L.maplibreGL({ style: layer.url, attributionControl: { customAttribution: layer.config.attribution } })
: L.tileLayer(
layer.url.replace(
"{format}",
document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp") === 0
? "webp"
: "png",
),
layer.config,
),
};
});

Expand Down
Loading