mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-22 14:32:15 +00:00
map fix
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
function initMap(div) {
|
function initMap() {
|
||||||
|
if (window.map) return
|
||||||
|
|
||||||
const map = new maplibregl.Map({
|
const map = new maplibregl.Map({
|
||||||
style: 'https://tiles.openfreemap.org/styles/liberty',
|
style: 'https://tiles.openfreemap.org/styles/liberty',
|
||||||
center: [-0.114, 51.506],
|
center: [-0.114, 51.506],
|
||||||
zoom: 14.2,
|
zoom: 14.2,
|
||||||
bearing: 55.2,
|
bearing: 55.2,
|
||||||
pitch: 60,
|
pitch: 60,
|
||||||
container: div,
|
container: mapDiv,
|
||||||
// boxZoom: false,
|
// boxZoom: false,
|
||||||
// doubleClickZoom: false,
|
// doubleClickZoom: false,
|
||||||
// scrollZoom: false,
|
// scrollZoom: false,
|
||||||
@@ -21,12 +23,14 @@ function initMap(div) {
|
|||||||
new maplibregl.Marker().setLngLat([-0.119, 51.507]).addTo(map)
|
new maplibregl.Marker().setLngLat([-0.119, 51.507]).addTo(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDiv = document.getElementById('map')
|
const mapDiv = document.getElementById('map-container')
|
||||||
mapDiv.onclick = function () {
|
mapDiv.onclick = function () {
|
||||||
initMap(mapDiv)
|
initMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectStyle(style) {
|
function selectStyle(style) {
|
||||||
|
initMap()
|
||||||
|
|
||||||
const styleUrl = 'https://tiles.openfreemap.org/styles/' + style
|
const styleUrl = 'https://tiles.openfreemap.org/styles/' + style
|
||||||
map.setStyle(styleUrl)
|
map.setStyle(styleUrl)
|
||||||
map.setPitch(0)
|
map.setPitch(0)
|
||||||
|
|||||||
@@ -156,13 +156,13 @@ code {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#map {
|
#map-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 500px;
|
height: 500px;
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#map:not(.maplibregl-map) {
|
#map-container:not(.maplibregl-map) {
|
||||||
background-image: url('mapbg.jpg');
|
background-image: url('mapbg.jpg');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div id="map"></div>
|
<div id="map-container"></div>
|
||||||
|
|
||||||
<p>Choose a style:</p>
|
<p>Choose a style:</p>
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
|
|||||||
Reference in New Issue
Block a user