diff options
Diffstat (limited to 'src/Link.mjs')
-rw-r--r-- | src/Link.mjs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Link.mjs b/src/Link.mjs index 61aa5f8..2ff1123 100644 --- a/src/Link.mjs +++ b/src/Link.mjs | |||
@@ -1,5 +1,6 @@ | |||
1 | import LeaderLine from 'leader-line' | 1 | import LeaderLine from 'leader-line' |
2 | import { insideWindow, insideParent } from './utils' | 2 | import { insideWindow, insideParent } from './utils' |
3 | import * as markers from './marker.mjs' | ||
3 | 4 | ||
4 | /** VAR: pattern for coodinates */ | 5 | /** VAR: pattern for coodinates */ |
5 | export const coordPattern = /^geo:([-]?[0-9.]+),([-]?[0-9.]+)/ | 6 | export const coordPattern = /^geo:([-]?[0-9.]+),([-]?[0-9.]+)/ |
@@ -106,11 +107,19 @@ export class GeoLink extends window.HTMLAnchorElement { | |||
106 | .map(map => { | 107 | .map(map => { |
107 | const renderer = map.renderer | 108 | const renderer = map.renderer |
108 | const lonLat = [Number(this.dataset.lon), Number(this.dataset.lat)] | 109 | const lonLat = [Number(this.dataset.lon), Number(this.dataset.lat)] |
110 | const type = params.get('type') ?? 'pin' | ||
111 | const svg = markers[type] | ||
112 | const element = document.createElement('div') | ||
113 | element.style.cssText = `width: ${svg.size[0]}px; height: ${svg.size[1]}px;` | ||
114 | element.innerHTML = svg.html | ||
109 | 115 | ||
110 | const marker = map.querySelector(`.marker[data-xy="${lonLat}"]`) ?? | 116 | const marker = map.querySelector(`.marker[data-xy="${lonLat}"]`) ?? |
111 | renderer.addMarker({ | 117 | renderer.addMarker({ |
112 | xy: lonLat, | 118 | xy: lonLat, |
113 | type: params.get('type') ?? null, | 119 | element, |
120 | type, | ||
121 | anchor: svg.anchor, | ||
122 | size: svg.size, | ||
114 | }) | 123 | }) |
115 | marker.dataset.xy = lonLat | 124 | marker.dataset.xy = lonLat |
116 | marker.title = new URLSearchParams(this.search).get('xy') ?? lonLat | 125 | marker.title = new URLSearchParams(this.search).get('xy') ?? lonLat |