diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-28 10:42:46 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-28 12:24:12 +0800 |
commit | 65680175fc04e71b362458745727974af73f711c (patch) | |
tree | 2d1981658283457fab941af73c39bbdb5b79e378 /src/dumbyUtils.mjs | |
parent | 42136919f1e5ffe31b2c783e30a121741deac49d (diff) |
feat: set marker title by textContent or option
Diffstat (limited to 'src/dumbyUtils.mjs')
-rw-r--r-- | src/dumbyUtils.mjs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index 1993b02..c4f8d74 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs | |||
@@ -92,7 +92,7 @@ export function removeBlockFocus () { | |||
92 | * @param {Number[]} options.point - page XY | 92 | * @param {Number[]} options.point - page XY |
93 | * @param {HTMLElement} options.map | 93 | * @param {HTMLElement} options.map |
94 | */ | 94 | */ |
95 | export const addMarkerByPoint = ({ point, map }) => { | 95 | export const addMarkerByPoint = ({ point, map, title }) => { |
96 | const rect = map.getBoundingClientRect() | 96 | const rect = map.getBoundingClientRect() |
97 | const [lon, lat] = map.renderer | 97 | const [lon, lat] = map.renderer |
98 | .unproject([point[0] - rect.left, point[1] - rect.top]) | 98 | .unproject([point[0] - rect.left, point[1] - rect.top]) |
@@ -102,6 +102,7 @@ export const addMarkerByPoint = ({ point, map }) => { | |||
102 | xy: [lon, lat], | 102 | xy: [lon, lat], |
103 | }) | 103 | }) |
104 | marker.dataset.xy = `${lon},${lat}` | 104 | marker.dataset.xy = `${lon},${lat}` |
105 | if (title) marker.title = title | ||
105 | 106 | ||
106 | return marker | 107 | return marker |
107 | } | 108 | } |