mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
website
This commit is contained in:
BIN
website/assets/berlin.png
Normal file
BIN
website/assets/berlin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
BIN
website/assets/berlin.webp
Normal file
BIN
website/assets/berlin.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 205 KiB |
|
Before Width: | Height: | Size: 288 KiB After Width: | Height: | Size: 288 KiB |
@@ -1,3 +1,17 @@
|
||||
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
|
||||
|
||||
@@ -5,10 +19,10 @@ function initMap() {
|
||||
|
||||
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,
|
||||
@@ -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
|
||||
|
||||
@@ -169,7 +169,7 @@ code {
|
||||
#map-container {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
margin-bottom: 2em;
|
||||
margin-bottom: 24px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user