Key changes:

- Add MapLibre GL JS viewer with light/dark themes, terrain layer,
  and embedded static map page for coordinate sharing
- Add map pin support with persistent map_pins.yaml config
- Add map region subscriptions and downloader with progress tracking,
  sourcing pre-extracted PMTiles from a cold CDN
- Add map export to PNG and GPS coordinate copy via context menu
- Add MapViewer React component alongside reworked Map page
- Add map catalog and region-building script (build_map_regions.py)
- Remove OSM import/render scripts, leaflet files, Apache configs,
  renderd service, and osm-map-dumper Docker container
- Update Caddyfile to serve PMTiles and map static assets
- Update build/install/repair scripts for Protomaps dependencies
- Drop map_file table, add/drop map_subscription table (alembic)
- Adding button to skip primary drive mounting during onboarding.
This commit is contained in:
Roland 2026-03-29 18:58:31 -06:00
parent 0a5fe7eebe
commit b8a532c8d9
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
102 changed files with 5033 additions and 2712 deletions

View file

@ -0,0 +1,93 @@
Copyright 2022 The Noto Project Authors (https://github.com/notofonts)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View file

@ -0,0 +1,739 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>WROLPi Map</title>
<link rel="stylesheet" href="/libs/maplibre-gl.css"/>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#map { width: 100%; height: 100%; }
/* Layer control panel */
#layer-panel {
position: absolute;
top: 10px;
left: 10px;
background: white;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
z-index: 1000;
max-height: calc(100vh - 20px);
overflow-y: auto;
min-width: 220px;
font-size: 14px;
}
#layer-toggle {
padding: 10px 14px;
cursor: pointer;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #eee;
user-select: none;
}
#layer-toggle:hover { background: #f5f5f5; }
#layer-toggle .arrow { transition: transform 0.2s; }
#layer-toggle .arrow.collapsed { transform: rotate(-90deg); }
#layer-content { padding: 8px 0; }
#layer-content.hidden { display: none; }
.layer-group { padding: 4px 14px; }
.layer-group-header {
display: flex;
align-items: center;
gap: 6px;
padding: 4px 0;
cursor: pointer;
font-weight: 500;
user-select: none;
}
.layer-group-header:hover { color: #1a73e8; }
.layer-group-header input { cursor: pointer; width: 16px; height: 16px; }
/* File selector */
#file-panel {
position: absolute;
top: 10px;
right: 50px;
background: white;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
z-index: 1000;
padding: 10px 14px;
font-size: 14px;
max-width: 300px;
}
#file-panel h3 { margin-bottom: 8px; font-size: 14px; }
.file-item {
display: flex;
align-items: center;
gap: 6px;
padding: 3px 0;
}
.file-item input { cursor: pointer; width: 16px; height: 16px; }
.file-item label { cursor: pointer; word-break: break-all; }
#no-files-msg {
color: #888;
font-style: italic;
padding: 4px 0;
}
/* Status bar */
#status {
position: absolute;
bottom: 30px;
left: 50%;
transform: translateX(-50%);
background: rgba(0,0,0,0.75);
color: white;
padding: 8px 16px;
border-radius: 6px;
font-size: 13px;
z-index: 1000;
display: none;
}
/* Context menu */
#context-menu {
position: absolute;
z-index: 1001;
background: white;
border-radius: 6px;
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
padding: 4px 0;
font-size: 13px;
min-width: 180;
display: none;
}
#context-menu .coords {
padding: 6px 12px;
color: #666;
font-size: 12px;
border-bottom: 1px solid #eee;
}
#context-menu .action {
padding: 8px 12px;
cursor: pointer;
user-select: none;
}
#context-menu .action:hover { background: #f0f0f0; }
</style>
</head>
<body>
<div id="map"></div>
<div id="layer-panel">
<div id="layer-toggle">
<span>Layers</span>
<span class="arrow">&#9660;</span>
</div>
<div id="layer-content"></div>
</div>
<div id="file-panel">
<h3>Map Files</h3>
<div id="file-list">
<div id="no-files-msg">Scanning...</div>
</div>
</div>
<div id="status"></div>
<div id="context-menu">
<div class="coords" id="context-coords"></div>
<div class="action" id="context-copy">Copy GPS coordinates</div>
<div class="action" id="context-export">Export as PNG</div>
</div>
<script src="/libs/pmtiles.js"></script>
<script src="/libs/maplibre-gl.js"></script>
<script src="/libs/protomaps-themes-base.js"></script>
<script src="/libs/maplibre-contour-pmtiles.js"></script>
<script>
(function() {
// --- Constants ---
var MAP_OVERVIEW_URL = "/blobs/map-overview.pmtiles";
var TERRAIN_PREFIX = "terrain-";
function isPlanetFile(name) {
if (name.indexOf("planet-") === 0) return true;
return /^\d{8}\.pmtiles$/.test(name);
}
var terrainFileName = null;
var STORAGE_KEY_LAYERS = "wrolpi-map-layers";
var STORAGE_KEY_SCALE = "wrolpi-map-scale";
var DEFAULT_HIDDEN = {"Hillshade": true, "Contours": true};
// --- PMTiles protocol ---
var protocol = new pmtiles.Protocol();
maplibregl.addProtocol("pmtiles", protocol.tile);
// --- Layer group definitions ---
var LAYER_GROUPS = {
"Hillshade": ["hillshade"],
"Contours": ["contour-lines", "contour-labels"],
"Water": ["water"],
"Land Cover": [
"landcover", "landuse_park", "landuse_urban_green", "landuse_beach",
"landuse_aerodrome", "landuse_hospital", "landuse_industrial",
"landuse_pedestrian", "landuse_pier", "landuse_school", "landuse_zoo"
],
"Buildings": ["buildings"],
"Roads - Highway": ["roads_highway"],
"Roads - Major": ["roads_major", "roads_link"],
"Roads - Minor": ["roads_minor", "roads_other"],
"Roads - Tunnels": ["roads_tunnels"],
"Roads - Bridges": ["roads_bridges"],
"Rail & Runways": ["roads_rail", "roads_runway", "roads_taxiway", "landuse_runway"],
"Boundaries": ["boundaries"],
"Labels": ["roads_labels", "places_", "address_label", "pois", "water_label", "water_waterway_label"],
};
// --- State ---
var map;
var scaleControl;
var demSource = null;
var activeSources = {};
var hasPlanetOverview = false;
var hasTerrain = false;
var contextMenuData = null;
// Load saved state from localStorage.
function getSavedVisibility() {
try {
var saved = localStorage.getItem(STORAGE_KEY_LAYERS);
if (saved) return JSON.parse(saved);
} catch(e) {}
var v = {};
for (var g in LAYER_GROUPS) v[g] = !DEFAULT_HIDDEN[g];
return v;
}
function getSavedScale() {
try { return localStorage.getItem(STORAGE_KEY_SCALE) || "metric"; } catch(e) { return "metric"; }
}
var groupVisibility = getSavedVisibility();
var currentScale = getSavedScale();
function getMapFlavor() {
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
// --- Build style ---
function buildStyle() {
var flavor = getMapFlavor();
var skipSecondary = {"background": true, "earth": true};
var sources = {};
var allLayers = [];
var si = 0;
// Planet overview as the primary base layer.
if (hasPlanetOverview) {
sources["map-overview"] = {
type: "vector",
url: "pmtiles://" + MAP_OVERVIEW_URL,
};
var baseLayers = protomaps_themes_base.default("map-overview", flavor);
allLayers = allLayers.concat(baseLayers);
si = 1;
}
// User files as additional sources.
var sourceNames = Object.keys(activeSources);
for (var fi = 0; fi < sourceNames.length; fi++) {
var filename = sourceNames[fi];
sources[filename] = {
type: "vector",
url: "pmtiles:///data/" + filename,
};
var fileLayers = protomaps_themes_base.default(filename, flavor);
if (si === 0 && fi === 0) {
allLayers = allLayers.concat(fileLayers);
} else {
for (var li = 0; li < fileLayers.length; li++) {
if (skipSecondary[fileLayers[li].id]) continue;
var layer = Object.assign({}, fileLayers[li]);
layer.id = filename + ":" + layer.id;
allLayers.push(layer);
}
}
}
// Terrain (hillshade + contours).
if (hasTerrain && demSource) {
var savedVis = getSavedVisibility();
var hillshadeVis = savedVis["Hillshade"] ? "visible" : "none";
var contourVis = savedVis["Contours"] ? "visible" : "none";
var isImperial = currentScale === "imperial";
var elevUnit = isImperial ? "ft" : "m";
sources["terrain-dem"] = {
type: "raster-dem",
url: "pmtiles://" + window.location.origin + "/data/" + terrainFileName,
encoding: "terrarium",
tileSize: 512,
};
var hillshadeSearch = allLayers.findIndex(function(l) { return l.id === "buildings"; });
var hillshadeIdx = hillshadeSearch === -1 ? allLayers.length : hillshadeSearch;
allLayers.splice(hillshadeIdx, 0, {
id: "hillshade",
type: "hillshade",
source: "terrain-dem",
layout: {visibility: hillshadeVis},
paint: {
"hillshade-shadow-color": "#000000",
"hillshade-illumination-anchor": "viewport",
"hillshade-exaggeration": 0.3,
},
});
var contourUrl = demSource.contourProtocolUrl({
overzoom: 1,
contourLayer: "contours",
elevationKey: "ele",
levelKey: "level",
multiplier: isImperial ? 3.28084 : 1,
thresholds: isImperial ? {
4: [1000, 5000], 5: [500, 2500], 6: [200, 1000], 7: [200, 1000], 8: [100, 500],
} : {
4: [500, 2500], 5: [200, 1000], 6: [100, 500], 7: [100, 500], 8: [50, 200],
},
});
sources["contours"] = { type: "vector", tiles: [contourUrl], maxzoom: 8 };
var textColor = flavor === "dark" ? "rgba(210,180,140,0.9)" : "rgba(150,100,50,0.8)";
var haloColor = flavor === "dark" ? "rgba(0,0,0,0.8)" : "rgba(255,255,255,0.8)";
allLayers.push(
{
id: "contour-lines", type: "line", source: "contours", "source-layer": "contours",
filter: ["!=", ["get", "level"], 1],
layout: {visibility: contourVis},
paint: {"line-color": "rgba(150,100,50,0.3)", "line-width": 0.5},
},
{
id: "contour-lines-major", type: "line", source: "contours", "source-layer": "contours",
filter: ["==", ["get", "level"], 1],
layout: {visibility: contourVis},
paint: {"line-color": "rgba(150,100,50,0.5)", "line-width": 1},
},
{
id: "contour-labels", type: "symbol", source: "contours", "source-layer": "contours",
filter: ["==", ["get", "level"], 1],
layout: {
visibility: contourVis,
"symbol-placement": "line",
"text-field": ["concat", ["get", "ele"], elevUnit],
"text-size": 10,
},
paint: {"text-color": textColor, "text-halo-color": haloColor, "text-halo-width": 1},
}
);
}
return {
version: 8,
glyphs: "/fonts/{fontstack}/{range}.pbf",
sprite: window.location.origin + "/sprites/" + flavor,
sources: sources,
layers: allLayers,
};
}
// --- Parse URL hash for coordinates ---
function parseHash() {
var hash = window.location.hash.replace("#", "");
if (!hash) return null;
var parts = hash.split(",");
if (parts.length >= 2) {
var lat = parseFloat(parts[0]);
var lon = parseFloat(parts[1]);
var zoom = parts.length >= 3 ? parseFloat(parts[2]) : 10;
if (!isNaN(lat) && !isNaN(lon) && lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180) {
return {lat: lat, lon: lon, zoom: zoom};
}
}
return null;
}
function initMap() {
var initial = parseHash();
var center = initial ? [initial.lon, initial.lat] : [0, 0];
var zoom = initial ? initial.zoom : 2;
map = new maplibregl.Map({
container: "map",
style: buildStyle(),
center: center,
zoom: zoom,
attributionControl: true,
preserveDrawingBuffer: true,
});
map.addControl(new maplibregl.NavigationControl(), "top-right");
map.addControl(new maplibregl.FullscreenControl(), "top-right");
scaleControl = new maplibregl.ScaleControl({maxWidth: 200, unit: currentScale});
map.addControl(scaleControl, "bottom-left");
var geolocate = new maplibregl.GeolocateControl({
positionOptions: {enableHighAccuracy: true},
trackUserLocation: true,
showUserHeading: true,
showAccuracyCircle: true,
});
map.addControl(geolocate, "top-right");
// Update URL hash on pan/zoom.
map.on("moveend", function() {
var c = map.getCenter();
var z = map.getZoom();
window.location.hash = c.lat.toFixed(4) + "," + c.lng.toFixed(4) + "," + z.toFixed(1);
});
// Right-click context menu.
map.on("contextmenu", function(e) {
contextMenuData = {lat: e.lngLat.lat, lon: e.lngLat.lng};
var menu = document.getElementById("context-menu");
var z = map.getZoom();
var d = z < 4 ? 1 : z < 8 ? 2 : z < 12 ? 3 : 4;
document.getElementById("context-coords").textContent =
contextMenuData.lat.toFixed(d) + ", " + contextMenuData.lon.toFixed(d);
menu.style.left = e.point.x + "px";
menu.style.top = e.point.y + "px";
menu.style.display = "block";
});
map.on("click", function() { document.getElementById("context-menu").style.display = "none"; });
map.on("movestart", function() { document.getElementById("context-menu").style.display = "none"; });
// Long-press context menu (mobile).
var longPressTimer = null;
var touchStartPos = null;
var canvas = map.getCanvas();
canvas.addEventListener("touchstart", function(e) {
if (e.touches.length !== 1) return;
touchStartPos = {x: e.touches[0].clientX, y: e.touches[0].clientY};
longPressTimer = setTimeout(function() {
var rect = canvas.getBoundingClientRect();
var px = touchStartPos.x - rect.left;
var py = touchStartPos.y - rect.top;
var lngLat = map.unproject([px, py]);
contextMenuData = {lat: lngLat.lat, lon: lngLat.lng};
var menu = document.getElementById("context-menu");
var z = map.getZoom();
var d = z < 4 ? 1 : z < 8 ? 2 : z < 12 ? 3 : 4;
document.getElementById("context-coords").textContent =
contextMenuData.lat.toFixed(d) + ", " + contextMenuData.lon.toFixed(d);
menu.style.left = px + "px";
menu.style.top = py + "px";
menu.style.display = "block";
}, 500);
}, {passive: true});
canvas.addEventListener("touchmove", function(e) {
if (longPressTimer && touchStartPos) {
var dx = e.touches[0].clientX - touchStartPos.x;
var dy = e.touches[0].clientY - touchStartPos.y;
if (Math.abs(dx) > 10 || Math.abs(dy) > 10) {
clearTimeout(longPressTimer);
longPressTimer = null;
}
}
});
canvas.addEventListener("touchend", function() {
clearTimeout(longPressTimer);
longPressTimer = null;
});
map.on("load", function() {
buildLayerControls();
});
}
// --- Context menu copy ---
document.getElementById("context-copy").addEventListener("click", function() {
if (!contextMenuData || !map) return;
var z = map.getZoom();
var d = z < 4 ? 1 : z < 8 ? 2 : z < 12 ? 3 : 4;
var text = contextMenuData.lat.toFixed(d) + ", " + contextMenuData.lon.toFixed(d);
if (navigator.clipboard) {
navigator.clipboard.writeText(text).catch(function() {
window.prompt("Copy coordinates:", text);
});
} else {
window.prompt("Copy coordinates:", text);
}
document.getElementById("context-menu").style.display = "none";
});
// --- Context menu export ---
document.getElementById("context-export").addEventListener("click", function() {
if (!map) return;
document.getElementById("context-menu").style.display = "none";
// Force a fresh render, then capture.
map.once("render", function() {
var c = map.getCenter();
var z = map.getZoom();
var filename = "wrolpi-map_" + c.lat.toFixed(4) + "_" + c.lng.toFixed(4) + "_z" + z.toFixed(0) + ".png";
map.getCanvas().toBlob(function(blob) {
if (!blob) return;
var url = URL.createObjectURL(blob);
var a = document.createElement("a");
a.href = url;
a.download = filename;
a.click();
URL.revokeObjectURL(url);
});
});
map.triggerRepaint();
});
// --- Layer control ---
function matchesGroup(layerId, prefixes) {
var baseId = layerId.indexOf(":") >= 0 ? layerId.split(":").slice(1).join(":") : layerId;
return prefixes.some(function(prefix) {
return baseId.indexOf(prefix) >= 0;
});
}
function setGroupVisibility(groupName, visible) {
groupVisibility[groupName] = visible;
try { localStorage.setItem(STORAGE_KEY_LAYERS, JSON.stringify(groupVisibility)); } catch(e) {}
if (!map || !map.getStyle()) return;
var prefixes = LAYER_GROUPS[groupName];
var allLayers = map.getStyle().layers || [];
for (var i = 0; i < allLayers.length; i++) {
if (matchesGroup(allLayers[i].id, prefixes)) {
map.setLayoutProperty(allLayers[i].id, "visibility", visible ? "visible" : "none");
}
}
}
function buildLayerControls() {
var container = document.getElementById("layer-content");
container.innerHTML = "";
for (var groupName in LAYER_GROUPS) {
var div = document.createElement("div");
div.className = "layer-group";
var header = document.createElement("label");
header.className = "layer-group-header";
var checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.checked = groupVisibility[groupName] !== false;
checkbox.addEventListener("change", (function(name) {
return function(e) { setGroupVisibility(name, e.target.checked); };
})(groupName));
var label = document.createTextNode(groupName);
header.appendChild(checkbox);
header.appendChild(label);
div.appendChild(header);
container.appendChild(div);
}
// Scale unit toggle.
var scaleDiv = document.createElement("div");
scaleDiv.className = "layer-group";
scaleDiv.style.borderTop = "1px solid #eee";
scaleDiv.style.marginTop = "4px";
scaleDiv.style.paddingTop = "4px";
var scaleLabel = document.createElement("label");
scaleLabel.className = "layer-group-header";
var scaleCheckbox = document.createElement("input");
scaleCheckbox.type = "checkbox";
scaleCheckbox.checked = currentScale === "imperial";
scaleCheckbox.addEventListener("change", function(e) {
currentScale = e.target.checked ? "imperial" : "metric";
scaleText.textContent = e.target.checked ? "Imperial" : "Metric";
try { localStorage.setItem(STORAGE_KEY_SCALE, currentScale); } catch(e2) {}
if (map && scaleControl) {
map.removeControl(scaleControl);
scaleControl = new maplibregl.ScaleControl({maxWidth: 200, unit: currentScale});
map.addControl(scaleControl, "bottom-left");
}
// Rebuild style for contour unit change.
if (hasTerrain) reloadMap();
});
var scaleText = document.createTextNode(currentScale === "imperial" ? "Imperial" : "Metric");
scaleLabel.appendChild(scaleCheckbox);
scaleLabel.appendChild(scaleText);
scaleDiv.appendChild(scaleLabel);
container.appendChild(scaleDiv);
}
// Toggle layer panel
document.getElementById("layer-toggle").addEventListener("click", function() {
var content = document.getElementById("layer-content");
var arrow = this.querySelector(".arrow");
content.classList.toggle("hidden");
arrow.classList.toggle("collapsed");
});
// --- File management ---
function showStatus(msg) {
var el = document.getElementById("status");
el.textContent = msg;
el.style.display = "block";
setTimeout(function() { el.style.display = "none"; }, 3000);
}
function reloadMap() {
if (!map) { initMap(); return; }
var center = map.getCenter();
var zoom = map.getZoom();
var bearing = map.getBearing();
var pitch = map.getPitch();
map.setStyle(buildStyle());
map.once("style.load", function() {
map.setCenter(center);
map.setZoom(zoom);
map.setBearing(bearing);
map.setPitch(pitch);
// Re-apply visibility for groups that were toggled off.
for (var groupName in groupVisibility) {
if (!groupVisibility[groupName]) {
setGroupVisibility(groupName, false);
}
}
buildLayerControls();
});
}
function toggleFile(filename, enabled) {
if (enabled) { activeSources[filename] = true; }
else { delete activeSources[filename]; }
reloadMap();
showStatus(enabled ? "Added " + filename : "Removed " + filename);
}
function renderFileList(files) {
var container = document.getElementById("file-list");
container.innerHTML = "";
if (files.length === 0) {
container.innerHTML = '<div id="no-files-msg">No .pmtiles files found in map/ directory</div>';
return;
}
files.forEach(function(file) {
var div = document.createElement("div");
div.className = "file-item";
var checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.id = "file-" + file;
checkbox.checked = !!activeSources[file];
checkbox.addEventListener("change", function(e) {
toggleFile(file, e.target.checked);
});
var label = document.createElement("label");
label.htmlFor = "file-" + file;
label.textContent = file;
div.appendChild(checkbox);
div.appendChild(label);
container.appendChild(div);
});
}
function scanFiles() {
// Fetch user's map files first to determine what base layer is needed.
fetch("/api/map/files")
.then(function(r) { return r.json(); })
.then(function(data) {
var allFiles = (data.files || []).sort(function(a, b) { return a.name.localeCompare(b.name); });
// Separate files into planet, terrain, and regional extracts.
var planetFile = null;
var regionFiles = [];
for (var i = 0; i < allFiles.length; i++) {
var f = allFiles[i];
if (f.name.startsWith(TERRAIN_PREFIX) && f.name.endsWith('.pmtiles')) {
terrainFileName = f.name;
hasTerrain = true;
} else if (isPlanetFile(f.name)) {
if (!planetFile || f.size > planetFile.size) {
planetFile = f;
}
} else {
regionFiles.push(f);
}
}
var pmtilesFiles;
if (planetFile) {
// Planet covers everything — sole vector source, no overview needed.
pmtilesFiles = [planetFile.name];
hasPlanetOverview = false;
return pmtilesFiles;
}
// Use regional extracts.
pmtilesFiles = regionFiles.map(function(f) { return f.name; });
// Check for planet overview blob as low-zoom base layer.
return fetch(MAP_OVERVIEW_URL, {method: "HEAD"})
.then(function(r) { hasPlanetOverview = r.ok; })
.catch(function() { hasPlanetOverview = false; })
.then(function() { return pmtilesFiles; });
})
.then(function(pmtilesFiles) {
// Initialize contour source if terrain available.
if (hasTerrain && !demSource) {
demSource = new mlcontour.DemSource({
url: "pmtiles://" + window.location.origin + "/data/" + terrainFileName,
encoding: "terrarium",
maxzoom: 8,
worker: true,
});
demSource.setupMaplibre(maplibregl);
}
renderFileList(pmtilesFiles);
if (pmtilesFiles.length > 0 && Object.keys(activeSources).length === 0) {
activeSources[pmtilesFiles[0]] = true;
renderFileList(pmtilesFiles);
reloadMap();
} else if (hasPlanetOverview || hasTerrain) {
reloadMap();
} else if (Object.keys(activeSources).length === 0) {
initMap();
}
})
.catch(function(err) {
console.error("Failed to scan files:", err);
document.getElementById("file-list").innerHTML =
'<div id="no-files-msg">Error scanning for map files</div>';
initMap();
});
}
// --- Listen for system theme changes ---
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", function() {
if (map) reloadMap();
});
// --- Start ---
scanFiles();
})();
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"NL:S-road-1char":{"height":21,"pixelRatio":1,"width":21,"x":0,"y":36},"NL:S-road-2char":{"height":21,"pixelRatio":1,"width":22,"x":38,"y":21},"NL:S-road-3char":{"height":21,"pixelRatio":1,"width":25,"x":202,"y":18},"NL:S-road-4char":{"height":21,"pixelRatio":1,"width":29,"x":173,"y":0},"NL:S-road-5char":{"height":21,"pixelRatio":1,"width":32,"x":79,"y":0},"US:I-1char":{"height":21,"pixelRatio":1,"width":20,"x":84,"y":21},"US:I-2char":{"height":21,"pixelRatio":1,"width":23,"x":227,"y":18},"US:I-3char":{"height":21,"pixelRatio":1,"width":30,"x":143,"y":0},"US:I-4char":{"height":21,"pixelRatio":1,"width":32,"x":111,"y":0},"US:I-5char":{"height":21,"pixelRatio":1,"width":34,"x":45,"y":0},"aerodrome":{"height":19,"pixelRatio":1,"width":19,"x":60,"y":39},"animal":{"height":19,"pixelRatio":1,"width":19,"x":21,"y":42},"arrow":{"height":19,"pixelRatio":1,"width":19,"x":0,"y":57},"artwork":{"height":19,"pixelRatio":1,"width":19,"x":40,"y":42},"attraction":{"height":19,"pixelRatio":1,"width":19,"x":104,"y":21},"bar":{"height":19,"pixelRatio":1,"width":19,"x":123,"y":21},"beach":{"height":19,"pixelRatio":1,"width":19,"x":142,"y":21},"beauty":{"height":19,"pixelRatio":1,"width":19,"x":161,"y":21},"bench":{"height":19,"pixelRatio":1,"width":19,"x":180,"y":21},"books":{"height":19,"pixelRatio":1,"width":19,"x":199,"y":39},"building":{"height":17,"pixelRatio":1,"width":17,"x":193,"y":77},"bus_stop":{"height":19,"pixelRatio":1,"width":19,"x":218,"y":39},"cafe":{"height":19,"pixelRatio":1,"width":19,"x":237,"y":39},"capital":{"height":10,"pixelRatio":1,"width":10,"x":210,"y":77},"clothes":{"height":19,"pixelRatio":1,"width":19,"x":104,"y":40},"convenience":{"height":19,"pixelRatio":1,"width":19,"x":79,"y":42},"drinking_water":{"height":19,"pixelRatio":1,"width":19,"x":59,"y":58},"electronics":{"height":19,"pixelRatio":1,"width":19,"x":19,"y":61},"fast_food":{"height":19,"pixelRatio":1,"width":19,"x":0,"y":76},"ferry_terminal":{"height":19,"pixelRatio":1,"width":19,"x":38,"y":61},"forest":{"height":19,"pixelRatio":1,"width":19,"x":123,"y":40},"garden":{"height":19,"pixelRatio":1,"width":19,"x":142,"y":40},"generic_shield-1char":{"height":18,"pixelRatio":1,"width":19,"x":235,"y":0},"generic_shield-2char":{"height":18,"pixelRatio":1,"width":24,"x":60,"y":21},"generic_shield-3char":{"height":18,"pixelRatio":1,"width":33,"x":202,"y":0},"generic_shield-4char":{"height":18,"pixelRatio":1,"width":38,"x":0,"y":18},"generic_shield-5char":{"height":18,"pixelRatio":1,"width":45,"x":0,"y":0},"library":{"height":19,"pixelRatio":1,"width":19,"x":161,"y":40},"marina":{"height":19,"pixelRatio":1,"width":19,"x":180,"y":40},"museum":{"height":19,"pixelRatio":1,"width":19,"x":199,"y":58},"park":{"height":19,"pixelRatio":1,"width":19,"x":218,"y":58},"peak":{"height":19,"pixelRatio":1,"width":19,"x":237,"y":58},"post_office":{"height":19,"pixelRatio":1,"width":19,"x":98,"y":59},"restaurant":{"height":19,"pixelRatio":1,"width":19,"x":78,"y":61},"school":{"height":19,"pixelRatio":1,"width":19,"x":57,"y":77},"stadium":{"height":19,"pixelRatio":1,"width":19,"x":19,"y":80},"supermarket":{"height":19,"pixelRatio":1,"width":19,"x":0,"y":95},"theatre":{"height":19,"pixelRatio":1,"width":19,"x":38,"y":80},"toilets":{"height":19,"pixelRatio":1,"width":19,"x":117,"y":59},"townspot":{"height":10,"pixelRatio":1,"width":10,"x":220,"y":77},"train_station":{"height":19,"pixelRatio":1,"width":19,"x":136,"y":59},"university":{"height":19,"pixelRatio":1,"width":19,"x":155,"y":59},"zoo":{"height":19,"pixelRatio":1,"width":19,"x":174,"y":59}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -0,0 +1 @@
{"NL:S-road-1char":{"height":42,"pixelRatio":2,"width":42,"x":0,"y":72},"NL:S-road-2char":{"height":42,"pixelRatio":2,"width":44,"x":76,"y":42},"NL:S-road-3char":{"height":42,"pixelRatio":2,"width":50,"x":404,"y":36},"NL:S-road-4char":{"height":42,"pixelRatio":2,"width":58,"x":346,"y":0},"NL:S-road-5char":{"height":42,"pixelRatio":2,"width":64,"x":158,"y":0},"US:I-1char":{"height":42,"pixelRatio":2,"width":40,"x":168,"y":42},"US:I-2char":{"height":42,"pixelRatio":2,"width":46,"x":454,"y":36},"US:I-3char":{"height":42,"pixelRatio":2,"width":60,"x":286,"y":0},"US:I-4char":{"height":42,"pixelRatio":2,"width":64,"x":222,"y":0},"US:I-5char":{"height":42,"pixelRatio":2,"width":68,"x":90,"y":0},"aerodrome":{"height":38,"pixelRatio":2,"width":38,"x":120,"y":78},"animal":{"height":38,"pixelRatio":2,"width":38,"x":42,"y":84},"arrow":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":114},"artwork":{"height":38,"pixelRatio":2,"width":38,"x":80,"y":84},"attraction":{"height":38,"pixelRatio":2,"width":38,"x":208,"y":42},"bar":{"height":38,"pixelRatio":2,"width":38,"x":246,"y":42},"beach":{"height":38,"pixelRatio":2,"width":38,"x":284,"y":42},"beauty":{"height":38,"pixelRatio":2,"width":38,"x":322,"y":42},"bench":{"height":38,"pixelRatio":2,"width":38,"x":360,"y":42},"books":{"height":38,"pixelRatio":2,"width":38,"x":398,"y":78},"building":{"height":34,"pixelRatio":2,"width":34,"x":386,"y":154},"bus_stop":{"height":38,"pixelRatio":2,"width":38,"x":436,"y":78},"cafe":{"height":38,"pixelRatio":2,"width":38,"x":474,"y":78},"capital":{"height":20,"pixelRatio":2,"width":20,"x":420,"y":154},"clothes":{"height":38,"pixelRatio":2,"width":38,"x":208,"y":80},"convenience":{"height":38,"pixelRatio":2,"width":38,"x":158,"y":84},"drinking_water":{"height":38,"pixelRatio":2,"width":38,"x":118,"y":116},"electronics":{"height":38,"pixelRatio":2,"width":38,"x":38,"y":122},"fast_food":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":152},"ferry_terminal":{"height":38,"pixelRatio":2,"width":38,"x":76,"y":122},"forest":{"height":38,"pixelRatio":2,"width":38,"x":246,"y":80},"garden":{"height":38,"pixelRatio":2,"width":38,"x":284,"y":80},"generic_shield-1char":{"height":36,"pixelRatio":2,"width":38,"x":470,"y":0},"generic_shield-2char":{"height":36,"pixelRatio":2,"width":48,"x":120,"y":42},"generic_shield-3char":{"height":36,"pixelRatio":2,"width":66,"x":404,"y":0},"generic_shield-4char":{"height":36,"pixelRatio":2,"width":76,"x":0,"y":36},"generic_shield-5char":{"height":36,"pixelRatio":2,"width":90,"x":0,"y":0},"library":{"height":38,"pixelRatio":2,"width":38,"x":322,"y":80},"marina":{"height":38,"pixelRatio":2,"width":38,"x":360,"y":80},"museum":{"height":38,"pixelRatio":2,"width":38,"x":398,"y":116},"park":{"height":38,"pixelRatio":2,"width":38,"x":436,"y":116},"peak":{"height":38,"pixelRatio":2,"width":38,"x":474,"y":116},"post_office":{"height":38,"pixelRatio":2,"width":38,"x":196,"y":118},"restaurant":{"height":38,"pixelRatio":2,"width":38,"x":156,"y":122},"school":{"height":38,"pixelRatio":2,"width":38,"x":114,"y":154},"stadium":{"height":38,"pixelRatio":2,"width":38,"x":38,"y":160},"supermarket":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":190},"theatre":{"height":38,"pixelRatio":2,"width":38,"x":76,"y":160},"toilets":{"height":38,"pixelRatio":2,"width":38,"x":234,"y":118},"townspot":{"height":20,"pixelRatio":2,"width":20,"x":440,"y":154},"train_station":{"height":38,"pixelRatio":2,"width":38,"x":272,"y":118},"university":{"height":38,"pixelRatio":2,"width":38,"x":310,"y":118},"zoo":{"height":38,"pixelRatio":2,"width":38,"x":348,"y":118}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View file

@ -0,0 +1 @@
{"NL:S-road-1char":{"height":21,"pixelRatio":1,"width":21,"x":0,"y":36},"NL:S-road-2char":{"height":21,"pixelRatio":1,"width":22,"x":38,"y":21},"NL:S-road-3char":{"height":21,"pixelRatio":1,"width":25,"x":202,"y":18},"NL:S-road-4char":{"height":21,"pixelRatio":1,"width":29,"x":173,"y":0},"NL:S-road-5char":{"height":21,"pixelRatio":1,"width":32,"x":79,"y":0},"US:I-1char":{"height":21,"pixelRatio":1,"width":20,"x":84,"y":21},"US:I-2char":{"height":21,"pixelRatio":1,"width":23,"x":227,"y":18},"US:I-3char":{"height":21,"pixelRatio":1,"width":30,"x":143,"y":0},"US:I-4char":{"height":21,"pixelRatio":1,"width":32,"x":111,"y":0},"US:I-5char":{"height":21,"pixelRatio":1,"width":34,"x":45,"y":0},"aerodrome":{"height":19,"pixelRatio":1,"width":19,"x":60,"y":39},"animal":{"height":19,"pixelRatio":1,"width":19,"x":21,"y":42},"arrow":{"height":19,"pixelRatio":1,"width":19,"x":0,"y":57},"artwork":{"height":19,"pixelRatio":1,"width":19,"x":40,"y":42},"attraction":{"height":19,"pixelRatio":1,"width":19,"x":104,"y":21},"bar":{"height":19,"pixelRatio":1,"width":19,"x":123,"y":21},"beach":{"height":19,"pixelRatio":1,"width":19,"x":142,"y":21},"beauty":{"height":19,"pixelRatio":1,"width":19,"x":161,"y":21},"bench":{"height":19,"pixelRatio":1,"width":19,"x":180,"y":21},"books":{"height":19,"pixelRatio":1,"width":19,"x":199,"y":39},"building":{"height":17,"pixelRatio":1,"width":17,"x":193,"y":77},"bus_stop":{"height":19,"pixelRatio":1,"width":19,"x":218,"y":39},"cafe":{"height":19,"pixelRatio":1,"width":19,"x":237,"y":39},"capital":{"height":10,"pixelRatio":1,"width":10,"x":210,"y":77},"clothes":{"height":19,"pixelRatio":1,"width":19,"x":104,"y":40},"convenience":{"height":19,"pixelRatio":1,"width":19,"x":79,"y":42},"drinking_water":{"height":19,"pixelRatio":1,"width":19,"x":59,"y":58},"electronics":{"height":19,"pixelRatio":1,"width":19,"x":19,"y":61},"fast_food":{"height":19,"pixelRatio":1,"width":19,"x":0,"y":76},"ferry_terminal":{"height":19,"pixelRatio":1,"width":19,"x":38,"y":61},"forest":{"height":19,"pixelRatio":1,"width":19,"x":123,"y":40},"garden":{"height":19,"pixelRatio":1,"width":19,"x":142,"y":40},"generic_shield-1char":{"height":18,"pixelRatio":1,"width":19,"x":235,"y":0},"generic_shield-2char":{"height":18,"pixelRatio":1,"width":24,"x":60,"y":21},"generic_shield-3char":{"height":18,"pixelRatio":1,"width":33,"x":202,"y":0},"generic_shield-4char":{"height":18,"pixelRatio":1,"width":38,"x":0,"y":18},"generic_shield-5char":{"height":18,"pixelRatio":1,"width":45,"x":0,"y":0},"library":{"height":19,"pixelRatio":1,"width":19,"x":161,"y":40},"marina":{"height":19,"pixelRatio":1,"width":19,"x":180,"y":40},"museum":{"height":19,"pixelRatio":1,"width":19,"x":199,"y":58},"park":{"height":19,"pixelRatio":1,"width":19,"x":218,"y":58},"peak":{"height":19,"pixelRatio":1,"width":19,"x":237,"y":58},"post_office":{"height":19,"pixelRatio":1,"width":19,"x":98,"y":59},"restaurant":{"height":19,"pixelRatio":1,"width":19,"x":78,"y":61},"school":{"height":19,"pixelRatio":1,"width":19,"x":57,"y":77},"stadium":{"height":19,"pixelRatio":1,"width":19,"x":19,"y":80},"supermarket":{"height":19,"pixelRatio":1,"width":19,"x":0,"y":95},"theatre":{"height":19,"pixelRatio":1,"width":19,"x":38,"y":80},"toilets":{"height":19,"pixelRatio":1,"width":19,"x":117,"y":59},"townspot":{"height":10,"pixelRatio":1,"width":10,"x":220,"y":77},"train_station":{"height":19,"pixelRatio":1,"width":19,"x":136,"y":59},"university":{"height":19,"pixelRatio":1,"width":19,"x":155,"y":59},"zoo":{"height":19,"pixelRatio":1,"width":19,"x":174,"y":59}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -0,0 +1 @@
{"NL:S-road-1char":{"height":42,"pixelRatio":2,"width":42,"x":0,"y":72},"NL:S-road-2char":{"height":42,"pixelRatio":2,"width":44,"x":76,"y":42},"NL:S-road-3char":{"height":42,"pixelRatio":2,"width":50,"x":404,"y":36},"NL:S-road-4char":{"height":42,"pixelRatio":2,"width":58,"x":346,"y":0},"NL:S-road-5char":{"height":42,"pixelRatio":2,"width":64,"x":158,"y":0},"US:I-1char":{"height":42,"pixelRatio":2,"width":40,"x":168,"y":42},"US:I-2char":{"height":42,"pixelRatio":2,"width":46,"x":454,"y":36},"US:I-3char":{"height":42,"pixelRatio":2,"width":60,"x":286,"y":0},"US:I-4char":{"height":42,"pixelRatio":2,"width":64,"x":222,"y":0},"US:I-5char":{"height":42,"pixelRatio":2,"width":68,"x":90,"y":0},"aerodrome":{"height":38,"pixelRatio":2,"width":38,"x":120,"y":78},"animal":{"height":38,"pixelRatio":2,"width":38,"x":42,"y":84},"arrow":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":114},"artwork":{"height":38,"pixelRatio":2,"width":38,"x":80,"y":84},"attraction":{"height":38,"pixelRatio":2,"width":38,"x":208,"y":42},"bar":{"height":38,"pixelRatio":2,"width":38,"x":246,"y":42},"beach":{"height":38,"pixelRatio":2,"width":38,"x":284,"y":42},"beauty":{"height":38,"pixelRatio":2,"width":38,"x":322,"y":42},"bench":{"height":38,"pixelRatio":2,"width":38,"x":360,"y":42},"books":{"height":38,"pixelRatio":2,"width":38,"x":398,"y":78},"building":{"height":34,"pixelRatio":2,"width":34,"x":386,"y":154},"bus_stop":{"height":38,"pixelRatio":2,"width":38,"x":436,"y":78},"cafe":{"height":38,"pixelRatio":2,"width":38,"x":474,"y":78},"capital":{"height":20,"pixelRatio":2,"width":20,"x":420,"y":154},"clothes":{"height":38,"pixelRatio":2,"width":38,"x":208,"y":80},"convenience":{"height":38,"pixelRatio":2,"width":38,"x":158,"y":84},"drinking_water":{"height":38,"pixelRatio":2,"width":38,"x":118,"y":116},"electronics":{"height":38,"pixelRatio":2,"width":38,"x":38,"y":122},"fast_food":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":152},"ferry_terminal":{"height":38,"pixelRatio":2,"width":38,"x":76,"y":122},"forest":{"height":38,"pixelRatio":2,"width":38,"x":246,"y":80},"garden":{"height":38,"pixelRatio":2,"width":38,"x":284,"y":80},"generic_shield-1char":{"height":36,"pixelRatio":2,"width":38,"x":470,"y":0},"generic_shield-2char":{"height":36,"pixelRatio":2,"width":48,"x":120,"y":42},"generic_shield-3char":{"height":36,"pixelRatio":2,"width":66,"x":404,"y":0},"generic_shield-4char":{"height":36,"pixelRatio":2,"width":76,"x":0,"y":36},"generic_shield-5char":{"height":36,"pixelRatio":2,"width":90,"x":0,"y":0},"library":{"height":38,"pixelRatio":2,"width":38,"x":322,"y":80},"marina":{"height":38,"pixelRatio":2,"width":38,"x":360,"y":80},"museum":{"height":38,"pixelRatio":2,"width":38,"x":398,"y":116},"park":{"height":38,"pixelRatio":2,"width":38,"x":436,"y":116},"peak":{"height":38,"pixelRatio":2,"width":38,"x":474,"y":116},"post_office":{"height":38,"pixelRatio":2,"width":38,"x":196,"y":118},"restaurant":{"height":38,"pixelRatio":2,"width":38,"x":156,"y":122},"school":{"height":38,"pixelRatio":2,"width":38,"x":114,"y":154},"stadium":{"height":38,"pixelRatio":2,"width":38,"x":38,"y":160},"supermarket":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":190},"theatre":{"height":38,"pixelRatio":2,"width":38,"x":76,"y":160},"toilets":{"height":38,"pixelRatio":2,"width":38,"x":234,"y":118},"townspot":{"height":20,"pixelRatio":2,"width":20,"x":440,"y":154},"train_station":{"height":38,"pixelRatio":2,"width":38,"x":272,"y":118},"university":{"height":38,"pixelRatio":2,"width":38,"x":310,"y":118},"zoo":{"height":38,"pixelRatio":2,"width":38,"x":348,"y":118}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB