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 = {};
|
||||
|
||||
Map.domParser = new DOMParser;
|
||||
|
||||
Map.init = function(mapContainerId) {
|
||||
let baseMap = new L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxNativeZoom : config.map.maxZoom,
|
||||
@ -22,15 +24,17 @@ Map.init = function(mapContainerId) {
|
||||
baseMap.addTo(map);
|
||||
|
||||
config.markers.forEach(marker => {
|
||||
L.marker(marker.coords).addTo(map)
|
||||
.bindPopup(marker.popup)
|
||||
.openPopup();
|
||||
|
||||
let btn = document.querySelector(`#${marker.id}`);
|
||||
btn.addEventListener('click', () => {
|
||||
const popup = this.domParser.parseFromString(marker.popup, 'text/html')
|
||||
.querySelector('div');
|
||||
popup.querySelector('button').onclick = () => {
|
||||
Scene.openScene(marker);
|
||||
map.getContainer().classList.toggle('d-none');
|
||||
});
|
||||
};
|
||||
|
||||
L.marker(marker.coords).addTo(map)
|
||||
.bindPopup(popup)
|
||||
.openPopup();
|
||||
|
||||
});
|
||||
|
||||
AppState.map = map;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user