diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-28 19:28:51 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-28 19:44:05 +0800 |
commit | 92dc83240b31455b8282242fafb0471681538fbe (patch) | |
tree | 4be15d264a5e0de1604d322cd85db3aa1a528ffc | |
parent | e62f5229be38afcdaa6514d4e158b464a2feab51 (diff) |
docs: jsdoc
-rw-r--r-- | src/Link.mjs | 3 | ||||
-rw-r--r-- | src/dumbymap.mjs | 21 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/Link.mjs b/src/Link.mjs index 7947152..92aaacf 100644 --- a/src/Link.mjs +++ b/src/Link.mjs | |||
@@ -3,8 +3,7 @@ import { insideWindow, insideParent } from './utils' | |||
3 | import * as markers from './marker.mjs' | 3 | import * as markers from './marker.mjs' |
4 | 4 | ||
5 | /** | 5 | /** |
6 | * GeoLink: anchor element with geo scheme and properties about maps | 6 | * @typedef {Object} GeoLink - anchor element with geo scheme and properties about maps |
7 | * @typedef {Object} GeoLink | ||
8 | * @extends HTMLAnchorElement | 7 | * @extends HTMLAnchorElement |
9 | * @property {string[]} targets - ids of target map elements | 8 | * @property {string[]} targets - ids of target map elements |
10 | * @property {LeaderLine[]} lines | 9 | * @property {LeaderLine[]} lines |
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index aaf0ad7..f538d0d 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
@@ -128,19 +128,22 @@ const defaultRender = mapclay.renderWith(config => ({ | |||
128 | * Generates maps based on the provided configuration | 128 | * Generates maps based on the provided configuration |
129 | * | 129 | * |
130 | * @param {HTMLElement} container - The container element for the maps | 130 | * @param {HTMLElement} container - The container element for the maps |
131 | * @param {Object} options - Configuration options | 131 | * @param {Object} options |
132 | * @param {String} options.contentSelector - CSS selector for Semantic HTML | ||
132 | * @param {string} options.crs - CRS in EPSG/ESRI code, see epsg.io | 133 | * @param {string} options.crs - CRS in EPSG/ESRI code, see epsg.io |
133 | * @param {number} [options.delay=1000] - Delay before rendering maps (in milliseconds) | 134 | * @param {string} options.initialLayout |
134 | * @param {Function} options.mapCallback - Callback function to be called after map rendering | 135 | * @param {number} [options.delay=1000] mapDelay - Delay before rendering maps (in milliseconds) |
136 | * @param {Function} options.render - Render function for maps | ||
137 | * @param {Function} options.renderCallback - Callback function to be called after map rendering | ||
135 | */ | 138 | */ |
136 | export const generateMaps = (container, { | 139 | export const generateMaps = (container, { |
140 | contentSelector, | ||
137 | crs = 'EPSG:4326', | 141 | crs = 'EPSG:4326', |
138 | initialLayout, | 142 | initialLayout, |
139 | layouts = [], | 143 | layouts = [], |
140 | mapDelay = 1000, | 144 | mapDelay = 1000, |
141 | renderCallback, | ||
142 | contentSelector, | ||
143 | render = defaultRender, | 145 | render = defaultRender, |
146 | renderCallback = () => null, | ||
144 | } = {}) => { | 147 | } = {}) => { |
145 | /** Prepare: Contaner */ | 148 | /** Prepare: Contaner */ |
146 | if (container.classList.contains('Dumby')) return | 149 | if (container.classList.contains('Dumby')) return |
@@ -534,7 +537,7 @@ export const generateMaps = (container, { | |||
534 | if (!block && !map && !linkWithLine) return | 537 | if (!block && !map && !linkWithLine) return |
535 | e.preventDefault() | 538 | e.preventDefault() |
536 | 539 | ||
537 | // Add menu element | 540 | /** Add HTMLElement for menu */ |
538 | const menu = document.createElement('div') | 541 | const menu = document.createElement('div') |
539 | menu.classList.add('menu', 'dumby-menu') | 542 | menu.classList.add('menu', 'dumby-menu') |
540 | menu.onclick = (e) => { | 543 | menu.onclick = (e) => { |
@@ -584,7 +587,7 @@ export const generateMaps = (container, { | |||
584 | return | 587 | return |
585 | } | 588 | } |
586 | 589 | ||
587 | // Menu Items for map | 590 | /** Menu Items for map */ |
588 | if (map) { | 591 | if (map) { |
589 | const rect = map.getBoundingClientRect() | 592 | const rect = map.getBoundingClientRect() |
590 | const [x, y] = [e.x - rect.left, e.y - rect.top] | 593 | const [x, y] = [e.x - rect.left, e.y - rect.top] |
@@ -612,13 +615,13 @@ export const generateMaps = (container, { | |||
612 | })) | 615 | })) |
613 | } | 616 | } |
614 | } else { | 617 | } else { |
615 | // Toggle block focus | 618 | /** Toggle block focus */ |
616 | if (block) { | 619 | if (block) { |
617 | menu.appendChild(menuItem.toggleBlockFocus(block)) | 620 | menu.appendChild(menuItem.toggleBlockFocus(block)) |
618 | } | 621 | } |
619 | } | 622 | } |
620 | 623 | ||
621 | // Menu Items for map/block/layout | 624 | /** Menu Items for picking map/block/layout */ |
622 | if (!map || map.closest('.Showcase')) { | 625 | if (!map || map.closest('.Showcase')) { |
623 | if (dumbymap.utils.renderedMaps().length > 0) { | 626 | if (dumbymap.utils.renderedMaps().length > 0) { |
624 | menu.appendChild(menuItem.pickMapItem(dumbymap)) | 627 | menu.appendChild(menuItem.pickMapItem(dumbymap)) |