diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-17 12:40:50 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-17 21:32:49 +0800 |
commit | 4dd0fa87859e6ffa1b230eedd1388098a8ba81a1 (patch) | |
tree | bd1c163a4091c812cfe6b569aeb38c439f97b56c /addon/index.mjs | |
parent | 5cbe9c55eca1b5b0a264414f9a255ea2d019d6e2 (diff) |
feat: set "sticky" as one of default layouts
* move function addDraggable() into module scope
* showcase in sticky layout is draggable now
* add query paramerter for "use"
* FIX: set initialLayout after observer is set
Diffstat (limited to 'addon/index.mjs')
-rw-r--r-- | addon/index.mjs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/addon/index.mjs b/addon/index.mjs index b5d71ba..77716b6 100644 --- a/addon/index.mjs +++ b/addon/index.mjs | |||
@@ -1,4 +1,5 @@ | |||
1 | const url = new URL(window.location) | 1 | const url = new URL(window.location) |
2 | const use = url.searchParams.get('use') | ||
2 | if (url.host === 'www.ptt.cc') { | 3 | if (url.host === 'www.ptt.cc') { |
3 | const content = document.querySelector('#main-content') | 4 | const content = document.querySelector('#main-content') |
4 | Array.from(content.childNodes) | 5 | Array.from(content.childNodes) |
@@ -22,7 +23,7 @@ const addBlocks = blockSelector | |||
22 | : undefined | 23 | : undefined |
23 | 24 | ||
24 | const simpleRender = window.mapclay.renderWith(config => ({ | 25 | const simpleRender = window.mapclay.renderWith(config => ({ |
25 | use: 'Leaflet', | 26 | use: use ?? 'Leaflet', |
26 | width: '100%', | 27 | width: '100%', |
27 | height: '200px', | 28 | height: '200px', |
28 | XYZ: 'https://tile.openstreetmap.jp/styles/osm-bright/512/{z}/{x}/{y}.png', | 29 | XYZ: 'https://tile.openstreetmap.jp/styles/osm-bright/512/{z}/{x}/{y}.png', |
@@ -36,7 +37,7 @@ const simpleRender = window.mapclay.renderWith(config => ({ | |||
36 | window.generateMaps(document.querySelector('main') ?? document.body, { | 37 | window.generateMaps(document.querySelector('main') ?? document.body, { |
37 | crs: url.searchParams.get('crs') ?? 'EPSG:4326', | 38 | crs: url.searchParams.get('crs') ?? 'EPSG:4326', |
38 | addBlocks, | 39 | addBlocks, |
39 | initialLayout: '', | 40 | initialLayout: 'sticky', |
40 | render: simpleRender, | 41 | render: simpleRender, |
41 | autoMap: true, | 42 | autoMap: true, |
42 | }) | 43 | }) |