diff options
-rw-r--r-- | src/dumbyUtils.mjs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index c0f4a0a..647ab9f 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs | |||
@@ -102,15 +102,21 @@ const getMarkersFromMaps = link => { | |||
102 | .filter(map => link.targets ? link.targets.includes(map.id) : true) | 102 | .filter(map => link.targets ? link.targets.includes(map.id) : true) |
103 | .map(map => { | 103 | .map(map => { |
104 | const renderer = map.renderer | 104 | const renderer = map.renderer |
105 | const markerTitle = `${link.targets ?? 'all'}@${link.dataset.xy}` | ||
106 | const lonLat = [Number(link.dataset.lon), Number(link.dataset.lat)] | 105 | const lonLat = [Number(link.dataset.lon), Number(link.dataset.lat)] |
107 | 106 | ||
108 | return map.querySelector(`.marker[title="${markerTitle}"]`) ?? | 107 | const marker = map.querySelector(`.marker[data-xy="${lonLat}"]`) ?? |
109 | renderer.addMarker({ | 108 | renderer.addMarker({ |
110 | xy: lonLat, | 109 | xy: lonLat, |
111 | title: markerTitle, | ||
112 | type: link.type, | 110 | type: link.type, |
113 | }) | 111 | }) |
112 | marker.dataset.xy = lonLat | ||
113 | marker.title = new URLSearchParams(link.search).get('xy') ?? lonLat | ||
114 | const crs = link.dataset.crs | ||
115 | if (crs && crs !== 'EPSG:4326') { | ||
116 | marker.title += '@' + link.dataset.crs | ||
117 | } | ||
118 | |||
119 | return marker | ||
114 | }) | 120 | }) |
115 | } | 121 | } |
116 | 122 | ||
@@ -153,9 +159,9 @@ export const createGeoLink = (link) => { | |||
153 | if (!xy || isNaN(xy[0]) || isNaN(xy[1])) return false | 159 | if (!xy || isNaN(xy[0]) || isNaN(xy[1])) return false |
154 | 160 | ||
155 | // Geo information in link | 161 | // Geo information in link |
156 | link.dataset.xy = xy | ||
157 | link.dataset.lon = lon | 162 | link.dataset.lon = lon |
158 | link.dataset.lat = lat | 163 | link.dataset.lat = lat |
164 | link.dataset.crs = params.get('crs') | ||
159 | link.classList.add('with-leader-line', 'geolink') | 165 | link.classList.add('with-leader-line', 'geolink') |
160 | // TODO refactor as data attribute | 166 | // TODO refactor as data attribute |
161 | link.targets = params.get('id')?.split(',') ?? null | 167 | link.targets = params.get('id')?.split(',') ?? null |
@@ -319,11 +325,11 @@ export const addAnchorByPoint = ({ | |||
319 | const desc = window.prompt('Description', anchorName) ?? anchorName | 325 | const desc = window.prompt('Description', anchorName) ?? anchorName |
320 | 326 | ||
321 | const link = `geo:${y},${x}?xy=${x},${y}&id=${map.id}&type=circle` | 327 | const link = `geo:${y},${x}?xy=${x},${y}&id=${map.id}&type=circle` |
322 | map.renderer.addMarker({ | 328 | const marker = map.renderer.addMarker({ |
323 | xy: [x, y], | 329 | xy: [x, y], |
324 | title: `${map.id}@${x},${y}`, | ||
325 | type: 'circle', | 330 | type: 'circle', |
326 | }) | 331 | }) |
332 | marker.dataset.xy = `${x},${y}` | ||
327 | 333 | ||
328 | return { ref: anchorName, link, title: desc } | 334 | return { ref: anchorName, link, title: desc } |
329 | } | 335 | } |