diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-17 23:20:45 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-17 23:20:45 +0800 |
| commit | 924864fc7434518ee0ae688f9be9d3086ba4b3f5 (patch) | |
| tree | 578cc81e8aca85024efe06d47dfad98468490351 | |
| parent | 4dd0fa87859e6ffa1b230eedd1388098a8ba81a1 (diff) | |
fix: don't apply dumbymap twice
| -rw-r--r-- | addon/index.mjs | 22 | ||||
| -rw-r--r-- | src/dumbymap.mjs | 1 |
2 files changed, 17 insertions, 6 deletions
diff --git a/addon/index.mjs b/addon/index.mjs index 77716b6..4de11e0 100644 --- a/addon/index.mjs +++ b/addon/index.mjs | |||
| @@ -34,10 +34,20 @@ const simpleRender = window.mapclay.renderWith(config => ({ | |||
| 34 | }, | 34 | }, |
| 35 | })) | 35 | })) |
| 36 | 36 | ||
| 37 | window.generateMaps(document.querySelector('main') ?? document.body, { | 37 | if (!document.querySelector('.Dumby')) { |
| 38 | crs: url.searchParams.get('crs') ?? 'EPSG:4326', | 38 | window.generateMaps(document.querySelector('main') ?? document.body, { |
| 39 | addBlocks, | 39 | crs: url.searchParams.get('crs') ?? 'EPSG:4326', |
| 40 | initialLayout: 'sticky', | 40 | addBlocks, |
| 41 | render: simpleRender, | 41 | initialLayout: 'sticky', |
| 42 | autoMap: true, | 42 | render: simpleRender, |
| 43 | autoMap: true, | ||
| 44 | }) | ||
| 45 | } | ||
| 46 | |||
| 47 | new window.MutationObserver((ms) => { | ||
| 48 | for (const m of ms) { | ||
| 49 | console.log(m) | ||
| 50 | } | ||
| 51 | }).observe(document.querySelector('#doc'), { | ||
| 52 | childList: true, | ||
| 43 | }) | 53 | }) |
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 13f4574..e9cb473 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
| @@ -457,6 +457,7 @@ export const generateMaps = (container, { | |||
| 457 | const mapContainer = document.createElement('pre') | 457 | const mapContainer = document.createElement('pre') |
| 458 | mapContainer.className = 'mapclay-container' | 458 | mapContainer.className = 'mapclay-container' |
| 459 | mapContainer.textContent = '#Created by DumbyMap' | 459 | mapContainer.textContent = '#Created by DumbyMap' |
| 460 | mapContainer.style.cssText = 'display: none;' | ||
| 460 | htmlHolder.insertBefore(mapContainer, htmlHolder.firstElementChild) | 461 | htmlHolder.insertBefore(mapContainer, htmlHolder.firstElementChild) |
| 461 | elementsWithMapConfig.push(mapContainer) | 462 | elementsWithMapConfig.push(mapContainer) |
| 462 | } | 463 | } |