mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 06:56:18 -05:00
The standalone map viewer draws overlays, as the map does (#966)
The standalone viewer (port 8084) drew basemaps only: a map file which is not a basemap was skipped. It now offers each overlay in its layer panel, hidden until turned on, with a checkbox per layer, draws it with the style beside it when there is one, and shows a feature's attributes on a click. The overlay logic is the map viewer's own. It moved to dependency-free modules (app/src/map-shared) which a browser can load as they are; the standalone viewer, which has no build step, loads copies of them from modules/map/static/js. A test fails while a copy differs from its module (`npm run sync:map-shared` makes the copies). What differs between the viewers is passed in: where a map file and its style are fetched from, and whether a layer can be checked before MapLibre is given it. The standalone viewer cannot check a layer first, so it adds an overlay's layers to the map one at a time once the style has loaded: MapLibre refuses a whole style over one layer it cannot draw, but only that layer when it is added by itself. The API also names a style by its path within the map directory, which is what the standalone viewer is served. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
113e70a402
commit
177d0dba4b
15 changed files with 1754 additions and 506 deletions
|
|
@ -286,6 +286,10 @@ def test_sidecar_style(test_directory, make_pmtiles):
|
|||
|
||||
files = {i['map_path']: i for i in lib.get_pmtiles_files()}
|
||||
assert files['extras/own.pmtiles']['style_path'] == 'map/extras/own.style.json'
|
||||
# The style is also named within the map directory, for the viewer which is served only that.
|
||||
assert files['extras/own.pmtiles']['style_map_path'] == 'extras/own.style.json'
|
||||
assert files['extras/shared.pmtiles']['style_map_path'] == 'extras/style.json'
|
||||
assert files['elsewhere.pmtiles']['style_map_path'] is None
|
||||
assert files['extras/shared.pmtiles']['style_path'] == 'map/extras/style.json'
|
||||
assert files['elsewhere.pmtiles']['style_path'] is None
|
||||
assert {i['has_sprite'] for i in files.values()} == {False}
|
||||
|
|
@ -328,3 +332,15 @@ def test_sidecar_sprite_resolution(test_directory, make_pmtiles):
|
|||
(extras / 'sprite.json').unlink()
|
||||
assert lib.find_sidecar_sprite(path, 'png') == extras / 'sprite@2x.png'
|
||||
assert lib.find_sidecar_sprite(path, 'json') == extras / 'sprite@2x.json'
|
||||
|
||||
|
||||
def test_sidecar_style_custom_map_directory(test_directory, make_pmtiles, test_wrolpi_config):
|
||||
"""The style's path within the map directory does not depend on what the map directory is called."""
|
||||
get_wrolpi_config().map_destination = 'atlas'
|
||||
make_pmtiles('atlas/extras/features.pmtiles', vector_metadata('towers'))
|
||||
(test_directory / 'atlas/extras/style.json').write_text('{}')
|
||||
|
||||
file, = lib.get_pmtiles_files()
|
||||
assert file['map_path'] == 'extras/features.pmtiles'
|
||||
assert file['style_path'] == 'atlas/extras/style.json'
|
||||
assert file['style_map_path'] == 'extras/style.json'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue