Skip to content

Commit 087ab64

Browse files
committed
website
1 parent 1ce5c85 commit 087ab64

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

website/assets/berlin.png

1.79 MB
Loading

website/assets/berlin.webp

205 KB
Binary file not shown.
File renamed without changes.

website/assets/map_howto.js

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1+
const london3d = {
2+
center: [-0.114, 51.506],
3+
zoom: 14.2,
4+
bearing: 55.2,
5+
pitch: 60,
6+
}
7+
8+
const berlin = {
9+
center: [13.388, 52.517],
10+
zoom: 9.5,
11+
bearing: 0,
12+
pitch: 0,
13+
}
14+
115
function initMap() {
216
if (window.map) return
317

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

620
const map = new maplibregl.Map({
721
style: 'https://tiles.openfreemap.org/styles/liberty',
8-
center: [-0.114, 51.506],
9-
zoom: 14.2,
10-
bearing: 55.2,
11-
pitch: 60,
22+
center: berlin.center,
23+
zoom: berlin.zoom,
24+
bearing: berlin.bearing,
25+
pitch: berlin.pitch,
1226
container: mapDiv,
1327
boxZoom: false,
1428
// doubleClickZoom: false,
@@ -42,21 +56,25 @@ mapDiv.onclick = function () {
4256

4357
// initMap()
4458

45-
let movedTo2d = false
59+
// let movedTo2d = false
4660

4761
function selectStyle(event, style) {
4862
initMap()
4963
toggleButtonSelection(event.target)
5064

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

54-
if (!movedTo2d) {
55-
map.setCenter({ lng: 13.388, lat: 52.517 })
56-
map.setPitch(0)
57-
map.setBearing(0)
58-
map.setZoom(9.5)
59-
movedTo2d = true
68+
if (style === 'liberty-3d') {
69+
map.setCenter(london3d.center)
70+
map.setPitch(london3d.pitch)
71+
map.setBearing(london3d.bearing)
72+
map.setZoom(london3d.zoom)
73+
} else if (map.getBearing() !== 0) {
74+
map.setCenter(berlin.center)
75+
map.setPitch(berlin.pitch)
76+
map.setBearing(berlin.bearing)
77+
map.setZoom(berlin.zoom)
6078
}
6179

6280
document.getElementById('style-url-code').innerText = styleUrl

website/assets/style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ code {
169169
#map-container {
170170
width: 100%;
171171
height: 500px;
172-
margin-bottom: 2em;
172+
margin-bottom: 24px;
173173
position: relative;
174174
}
175175

@@ -178,7 +178,7 @@ code {
178178
height: 100%;
179179
position: absolute;
180180
z-index: 1;
181-
background-image: url('mapbg.jpg');
181+
background-image: url('berlin.webp');
182182
background-size: cover;
183183
background-position: center;
184184
background-repeat: no-repeat;

website/blocks/map_howto.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<button onclick="selectStyle(event, 'positron')" class="btn">Positron</button>
1414
<button onclick="selectStyle(event, 'bright')" class="btn">Bright</button>
1515
<button onclick="selectStyle(event, 'liberty')" class="btn selected">Liberty</button>
16+
<button onclick="selectStyle(event, 'liberty-3d')" class="btn">3D</button>
1617
</div>
1718

1819
<p>Use the following style in a MapLibre map:</p>

website/generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def copy_assets():
4949
'favicon.ico',
5050
'github.svg',
5151
'x.svg',
52-
'mapbg.jpg',
52+
'berlin.webp',
5353
]:
5454
shutil.copyfile(ASSETS_DIR / file, OUT_DIR / file)
5555

0 commit comments

Comments
 (0)