Skip to content

Commit

Permalink
website
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperknot committed Jun 12, 2024
1 parent 1ce5c85 commit 087ab64
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 deletions.
Binary file added website/assets/berlin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/assets/berlin.webp
Binary file not shown.
File renamed without changes
42 changes: 30 additions & 12 deletions website/assets/map_howto.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
const london3d = {
center: [-0.114, 51.506],
zoom: 14.2,
bearing: 55.2,
pitch: 60,
}

const berlin = {
center: [13.388, 52.517],
zoom: 9.5,
bearing: 0,
pitch: 0,
}

function initMap() {
if (window.map) return

document.getElementById('mapbg-image').style.opacity = '0.2'

const map = new maplibregl.Map({
style: 'https://tiles.openfreemap.org/styles/liberty',
center: [-0.114, 51.506],
zoom: 14.2,
bearing: 55.2,
pitch: 60,
center: berlin.center,
zoom: berlin.zoom,
bearing: berlin.bearing,
pitch: berlin.pitch,
container: mapDiv,
boxZoom: false,
// doubleClickZoom: false,
Expand Down Expand Up @@ -42,21 +56,25 @@ mapDiv.onclick = function () {

// initMap()

let movedTo2d = false
// let movedTo2d = false

function selectStyle(event, style) {
initMap()
toggleButtonSelection(event.target)

const styleUrl = 'https://tiles.openfreemap.org/styles/' + style
const styleUrl = 'https://tiles.openfreemap.org/styles/' + style.split('-')[0]
map.setStyle(styleUrl)

if (!movedTo2d) {
map.setCenter({ lng: 13.388, lat: 52.517 })
map.setPitch(0)
map.setBearing(0)
map.setZoom(9.5)
movedTo2d = true
if (style === 'liberty-3d') {
map.setCenter(london3d.center)
map.setPitch(london3d.pitch)
map.setBearing(london3d.bearing)
map.setZoom(london3d.zoom)
} else if (map.getBearing() !== 0) {
map.setCenter(berlin.center)
map.setPitch(berlin.pitch)
map.setBearing(berlin.bearing)
map.setZoom(berlin.zoom)
}

document.getElementById('style-url-code').innerText = styleUrl
Expand Down
4 changes: 2 additions & 2 deletions website/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ code {
#map-container {
width: 100%;
height: 500px;
margin-bottom: 2em;
margin-bottom: 24px;
position: relative;
}

Expand All @@ -178,7 +178,7 @@ code {
height: 100%;
position: absolute;
z-index: 1;
background-image: url('mapbg.jpg');
background-image: url('berlin.webp');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
Expand Down
1 change: 1 addition & 0 deletions website/blocks/map_howto.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<button onclick="selectStyle(event, 'positron')" class="btn">Positron</button>
<button onclick="selectStyle(event, 'bright')" class="btn">Bright</button>
<button onclick="selectStyle(event, 'liberty')" class="btn selected">Liberty</button>
<button onclick="selectStyle(event, 'liberty-3d')" class="btn">3D</button>
</div>

<p>Use the following style in a MapLibre map:</p>
Expand Down
2 changes: 1 addition & 1 deletion website/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def copy_assets():
'favicon.ico',
'github.svg',
'x.svg',
'mapbg.jpg',
'berlin.webp',
]:
shutil.copyfile(ASSETS_DIR / file, OUT_DIR / file)

Expand Down

0 comments on commit 087ab64

Please sign in to comment.