diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2025-06-15 13:26:30 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2025-06-15 13:49:27 +0200 |
commit | 0fc7bdd8bf374c36fa0ba27702d1fafed09277ac (patch) | |
tree | b8c81445d179725d0ae3ff6bff31963f06e5d456 /src/popover.js | |
parent | d6981601de753dbb996f1808dcf34bcaab588d34 (diff) |
Factor out map setup into separate file.
This allows importing `map` in other modules, thereby eliminating the
need for creating and exporting functions that would be called only
once.
Diffstat (limited to 'src/popover.js')
-rw-r--r-- | src/popover.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/popover.js b/src/popover.js index 74e79d6..7080711 100644 --- a/src/popover.js +++ b/src/popover.js @@ -23,6 +23,7 @@ import VectorTileLayer from 'ol/layer/VectorTile.js'; import { Popover } from 'bootstrap'; +import { map } from './map.js'; /* return an <a> tag with the given URL and optional text */ const reURL = new RegExp('^https?://', 'i'); @@ -989,13 +990,13 @@ const formatFeaturePropertiesToHTML = function(properties) { /* Initialize popup overlay with the give map and HTML element */ let popupOverlay = null; -export const initPopupOverLay = function(map, element) { +(function() { popupOverlay = new Overlay({ stopEvent: true, - element: element, + element: document.getElementById('popup'), }); map.addOverlay(popupOverlay); -}; +})(); let featureOverlayLayer = null; let overlayAttributes = [], @@ -1023,7 +1024,7 @@ export const disposePopover = function() { }; /* Initialize popover on the given map */ -export const initPopover = function(map) { +(function() { featureOverlayLayer = new VectorTileLayer({ zIndex: 65535, declutter: false, @@ -1344,4 +1345,4 @@ export const initPopover = function(map) { document.body.classList.remove('inprogress'); }); }); -}; +})(); |