diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-12 23:17:12 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-13 11:06:46 +0800 |
| commit | 0bb795fb1d3fb4c5e7a963fa2fb31904d2cc0f83 (patch) | |
| tree | 73b48ffc5b6d94cf79f8311230ce583693be466c | |
| parent | 528036f50d5dac0076b479c266350812a39180b5 (diff) | |
feat: use middle click to remove marker
| -rw-r--r-- | src/dumbyUtils.mjs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index e8fb982..c0f4a0a 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs | |||
| @@ -163,7 +163,7 @@ export const createGeoLink = (link) => { | |||
| 163 | 163 | ||
| 164 | link.lines = [] | 164 | link.lines = [] |
| 165 | 165 | ||
| 166 | // LeaderLine | 166 | // Hover link for LeaderLine |
| 167 | link.onmouseover = () => { | 167 | link.onmouseover = () => { |
| 168 | if (link.dataset.valid === 'false') return | 168 | if (link.dataset.valid === 'false') return |
| 169 | 169 | ||
| @@ -176,6 +176,8 @@ export const createGeoLink = (link) => { | |||
| 176 | }) | 176 | }) |
| 177 | } | 177 | } |
| 178 | link.onmouseout = () => removeLeaderLines(link) | 178 | link.onmouseout = () => removeLeaderLines(link) |
| 179 | |||
| 180 | // Click to move camera | ||
| 179 | link.onclick = (event) => { | 181 | link.onclick = (event) => { |
| 180 | event.preventDefault() | 182 | event.preventDefault() |
| 181 | if (link.dataset.valid === 'false') return | 183 | if (link.dataset.valid === 'false') return |
| @@ -187,6 +189,15 @@ export const createGeoLink = (link) => { | |||
| 187 | Number(link.dataset.lat), | 189 | Number(link.dataset.lat), |
| 188 | ])) | 190 | ])) |
| 189 | } | 191 | } |
| 192 | |||
| 193 | // Use middle click to remove markers | ||
| 194 | link.onauxclick = (e) => { | ||
| 195 | if (e.which !== 2) return | ||
| 196 | e.preventDefault() | ||
| 197 | removeLeaderLines(link) | ||
| 198 | getMarkersFromMaps(link) | ||
| 199 | .forEach(marker => marker.remove()) | ||
| 200 | } | ||
| 190 | return true | 201 | return true |
| 191 | } | 202 | } |
| 192 | 203 | ||