This commit is contained in:
Zsolt Ero
2024-01-19 21:20:44 +01:00
parent 7429a52f8b
commit 7f64243aaf
3 changed files with 11 additions and 7 deletions

View File

@@ -1,11 +1,13 @@
function initMap(div) {
function initMap() {
if (window.map) return
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,
container: div,
container: mapDiv,
// boxZoom: false,
// doubleClickZoom: false,
// scrollZoom: false,
@@ -21,12 +23,14 @@ function initMap(div) {
new maplibregl.Marker().setLngLat([-0.119, 51.507]).addTo(map)
}
const mapDiv = document.getElementById('map')
const mapDiv = document.getElementById('map-container')
mapDiv.onclick = function () {
initMap(mapDiv)
initMap()
}
function selectStyle(style) {
initMap()
const styleUrl = 'https://tiles.openfreemap.org/styles/' + style
map.setStyle(styleUrl)
map.setPitch(0)