mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-30 11:56:18 -05:00
The map draws any PMTiles file as an overlay, in any sub-directory (#962)
Any PMTiles file under the map directory, at any depth, can be shown. The API reads each file's header and metadata and says what it is (basemap, terrain, overlay, unreadable). Overlays are offered in the layer control under the name the file gives itself, hidden until turned on, with a checkbox per vector layer, and are drawn generically. Map files are named by their path within the map directory everywhere, and unfinished downloads are no longer listed. A file can be ignored from the Manage page; ignored files are kept in a new maps.yaml config. PMTiles metadata is not decompressed past its size limit, and the standalone viewer encodes map file paths.
This commit is contained in:
parent
4072ac30ed
commit
adb0adbd94
27 changed files with 2115 additions and 170 deletions
|
|
@ -29,15 +29,21 @@
|
|||
var sources = {};
|
||||
var allLayers = [];
|
||||
|
||||
// Add user's PMTiles files (skip terrain). Includes map-overview if present.
|
||||
// Add user's basemap PMTiles files: not terrain, overlays, or files the user ignores.
|
||||
var files = (data.files || []).filter(function(f) {
|
||||
return f.name.indexOf("terrain") !== 0;
|
||||
if (f.visible === false) return false;
|
||||
return f.kind ? f.kind === "basemap" : f.name.indexOf("terrain") !== 0;
|
||||
});
|
||||
files.forEach(function(f, i) {
|
||||
sources[f.name] = {type: "vector", url: "pmtiles:///data/" + f.name};
|
||||
var layers = protomaps_themes_base.default(f.name, flavor);
|
||||
// A file is named by its path in the map directory; it may be in a sub-directory.
|
||||
var mapPath = f.map_path || f.name;
|
||||
// Each part of the path is encoded: a `#` or `?` in a file name would otherwise end the
|
||||
// path, and another file (or none) would be asked for.
|
||||
var dataPath = "/data/" + String(mapPath).split("/").map(encodeURIComponent).join("/");
|
||||
sources[mapPath] = {type: "vector", url: "pmtiles://" + dataPath};
|
||||
var layers = protomaps_themes_base.default(mapPath, flavor);
|
||||
if (i > 0) {
|
||||
layers.forEach(function(l) { l.id = f.name + ":" + l.id; });
|
||||
layers.forEach(function(l) { l.id = mapPath + ":" + l.id; });
|
||||
}
|
||||
allLayers = allLayers.concat(layers);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue