diff --git a/website/assets/map_howto.js b/website/assets/map_howto.js index cf9073e..56230d9 100644 --- a/website/assets/map_howto.js +++ b/website/assets/map_howto.js @@ -40,14 +40,22 @@ const mapDiv = document.getElementById('map-container') initMap() -function selectStyle(style) { - // initMap() +function selectStyle(event, style) { + toggleButtonSelection(event.target) const styleUrl = 'https://tiles.openfreemap.org/styles/' + style map.setStyle(styleUrl) map.setPitch(0) map.setBearing(0) + map.setZoom(12.5) - const spans = document.querySelectorAll('#style-url-code span') - spans[2].innerText = '/' + style + document.getElementById('style-url-code').innerText = styleUrl +} + +function toggleButtonSelection(clickedButton) { + clickedButton.classList.add('selected') + + Array.from(clickedButton.parentElement.children) + .filter(child => child !== clickedButton) + .forEach(button => button.classList.remove('selected')) } diff --git a/website/assets/style.css b/website/assets/style.css index 19c7fc5..2837a8d 100644 --- a/website/assets/style.css +++ b/website/assets/style.css @@ -185,6 +185,10 @@ code { align-items: center; } +.btn.selected { + background: #4892d9; +} + .button-container { margin: 0 auto 0.6em; max-width: 600px; diff --git a/website/blocks/map_howto.html b/website/blocks/map_howto.html index a259650..bfb9fd1 100644 --- a/website/blocks/map_howto.html +++ b/website/blocks/map_howto.html @@ -4,21 +4,21 @@

Choose a style:

- - - + + +

Use the following style in a MapLibre map:

-
https://tiles.openfreemap.org/styles/liberty
+
https://tiles.openfreemap.org/styles/liberty

Include - MapLibre GL JS in the - <head>. If you are using npm, you can install the + MapLibre GL JS + in the <head>. If you are using npm, you can install the maplibre-gl package. Make sure to import the CSS as well.

<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>