Fix stupid popup button...
This commit is contained in:
parent
a77a99f056
commit
54373cfe96
18
js/map.js
18
js/map.js
@ -6,6 +6,8 @@ import { AppState } from './state.js';
|
|||||||
|
|
||||||
const Map = {};
|
const Map = {};
|
||||||
|
|
||||||
|
Map.domParser = new DOMParser;
|
||||||
|
|
||||||
Map.init = function(mapContainerId) {
|
Map.init = function(mapContainerId) {
|
||||||
let baseMap = new L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
let baseMap = new L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
maxNativeZoom : config.map.maxZoom,
|
maxNativeZoom : config.map.maxZoom,
|
||||||
@ -22,15 +24,17 @@ Map.init = function(mapContainerId) {
|
|||||||
baseMap.addTo(map);
|
baseMap.addTo(map);
|
||||||
|
|
||||||
config.markers.forEach(marker => {
|
config.markers.forEach(marker => {
|
||||||
L.marker(marker.coords).addTo(map)
|
const popup = this.domParser.parseFromString(marker.popup, 'text/html')
|
||||||
.bindPopup(marker.popup)
|
.querySelector('div');
|
||||||
.openPopup();
|
popup.querySelector('button').onclick = () => {
|
||||||
|
|
||||||
let btn = document.querySelector(`#${marker.id}`);
|
|
||||||
btn.addEventListener('click', () => {
|
|
||||||
Scene.openScene(marker);
|
Scene.openScene(marker);
|
||||||
map.getContainer().classList.toggle('d-none');
|
map.getContainer().classList.toggle('d-none');
|
||||||
});
|
};
|
||||||
|
|
||||||
|
L.marker(marker.coords).addTo(map)
|
||||||
|
.bindPopup(popup)
|
||||||
|
.openPopup();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AppState.map = map;
|
AppState.map = map;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user