Skip to content

Commit 7436f41

Browse files
authored
Merge pull request #104 from louwers/interactive-demo-maplibre
Add interactive demo for Versatiles styles using MapLibre GL JS
2 parents f84bb0a + 241355e commit 7436f41

15 files changed

+43
-30
lines changed

shortbread-website/content/styles/_index.md

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,51 @@ You can either write your style in this JSON format or use a visual style editor
2323

2424
The following open source rendering styles are available for Shortbread vector tiles.
2525

26-
### VersaTiles Colorful
27-
28-
[VersaTiles Colorful](https://github.com/versatiles-org/versatiles-style) is a colorful, full featured map written for the MapLibre rendering engine.
29-
[Demo](https://versatiles.org/) using [VersaTiles](https://versatiles.org/), a completely FLOSS stack for generating, distributing and using map tiles based on OpenStreetMap data, free of any commercial interests.
30-
31-
<div class="example-images">
32-
33-
![VersaTiles Colorful at zoom level 3](versatiles-colorful-z3.webp)
34-
![VersaTiles Colorful at zoom level 5](versatiles-colorful-z5.webp)
35-
![VersaTiles Colorful at zoom level 7](versatiles-colorful-z7.webp)
36-
![VersaTiles Colorful at zoom level 9](versatiles-colorful-z9.webp)
37-
![VersaTiles Colorful at zoom level 11](versatiles-colorful-z11.webp)
38-
![VersaTiles Colorful at zoom level 13](versatiles-colorful-z13.webp)
39-
![VersaTiles Colorful at zoom level 15](versatiles-colorful-z15.webp)
40-
26+
### VersaTiles Styles
27+
28+
[VersaTiles Styles](https://github.com/versatiles-org/versatiles-style) are map styles written for the MapLibre rendering engine. [VersaTiles](https://versatiles.org/) is a completely FLOSS stack for generating, distributing and using map tiles based on OpenStreetMap data, free of any commercial interests.
29+
30+
<div id="map-container" style="position: relative; width: 100%; height: 600px; margin: 2rem 0; border: 2px solid #ccc; border-radius: 8px;">
31+
<div id="style-toggle" style="position: absolute; top: 10px; left: 10px; z-index: 1000; background: white; padding: 10px; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.2);">
32+
<label for="style-select" style="display: block; margin-bottom: 5px; font-weight: bold;">Style:</label>
33+
<select id="style-select" style="padding: 5px 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;">
34+
<option value="colorful">Colorful</option>
35+
<option value="graybeard">Graybeard</option>
36+
<option value="eclipse">Eclipse</option>
37+
<option value="neutrino">Neutrino</option>
38+
</select>
39+
</div>
40+
<div id="map" style="width: 100%; height: 100%;"></div>
4141
</div>
4242

43-
### VersaTiles Neutrino
44-
45-
[VersaTiles Neutrino](https://github.com/versatiles-org/versatiles-style) is a light basemap style written for the MapLibre rendering engine.
46-
47-
<div class="example-images">
48-
49-
![VersaTiles Neutrino at zoom level 3](versatiles-neutrino-z3.webp)
50-
![VersaTiles Neutrino at zoom level 5](versatiles-neutrino-z5.webp)
51-
![VersaTiles Neutrino at zoom level 7](versatiles-neutrino-z7.webp)
52-
![VersaTiles Neutrino at zoom level 9](versatiles-neutrino-z9.webp)
53-
![VersaTiles Neutrino at zoom level 11](versatiles-neutrino-z11.webp)
54-
![VersaTiles Neutrino at zoom level 13](versatiles-neutrino-z13.webp)
55-
![VersaTiles Neutrino at zoom level 15](versatiles-neutrino-z15.webp)
56-
57-
</div>
43+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/maplibre-gl@5.12.0/dist/maplibre-gl.css">
44+
45+
<script type="module">
46+
import maplibre from 'https://cdn.jsdelivr.net/npm/maplibre-gl@5.12.0/+esm';
47+
48+
const styleUrls = {
49+
colorful: 'https://tiles.versatiles.org/assets/styles/colorful/style.json',
50+
graybeard: 'https://tiles.versatiles.org/assets/styles/graybeard/style.json',
51+
eclipse: 'https://tiles.versatiles.org/assets/styles/eclipse/style.json',
52+
neutrino: 'https://tiles.versatiles.org/assets/styles/neutrino/style.json'
53+
};
54+
55+
// Initialize map
56+
const map = new maplibre.Map({
57+
container: 'map',
58+
style: styleUrls.colorful,
59+
center: [8.5, 47.4], // Switzerland
60+
zoom: 10
61+
});
62+
63+
map.addControl(new maplibre.FullscreenControl(), 'top-right');
64+
65+
const styleSelect = document.getElementById('style-select');
66+
styleSelect.addEventListener('change', (e) => {
67+
const selectedStyle = e.target.value;
68+
map.setStyle(styleUrls[selectedStyle]);
69+
});
70+
</script>
5871

5972
## Shortbread-Demo-MapLibre
6073

-137 KB
Binary file not shown.
-240 KB
Binary file not shown.
-212 KB
Binary file not shown.
-111 KB
Binary file not shown.
-124 KB
Binary file not shown.
-207 KB
Binary file not shown.
-268 KB
Binary file not shown.
-97.5 KB
Binary file not shown.
-121 KB
Binary file not shown.

0 commit comments

Comments
 (0)