diff options
-rw-r--r-- | src/dumbyUtils.mjs | 4 | ||||
-rw-r--r-- | src/dumbymap.mjs | 12 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index 5de5b05..d0a3501 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs | |||
@@ -101,10 +101,10 @@ const getMarkersFromMaps = link => { | |||
101 | .map(map => { | 101 | .map(map => { |
102 | const renderer = map.renderer | 102 | const renderer = map.renderer |
103 | 103 | ||
104 | return map.querySelector(`.marker[title="${link.title}"]`) ?? | 104 | return map.querySelector(`.marker[title="${link.xy}"]`) ?? |
105 | renderer.addMarker({ | 105 | renderer.addMarker({ |
106 | xy: link.xy, | 106 | xy: link.xy, |
107 | title: link.title | 107 | title: link.xy |
108 | }) | 108 | }) |
109 | }) | 109 | }) |
110 | } | 110 | } |
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 512409b..7489b1a 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
@@ -49,20 +49,18 @@ export const markdown2HTML = (container, mdContent) => { | |||
49 | .use(MarkdownItInjectLinenumbers) | 49 | .use(MarkdownItInjectLinenumbers) |
50 | 50 | ||
51 | // Create links with geo scheme | 51 | // Create links with geo scheme |
52 | const coordinateRegex = /^(\D*)(-?\d+\.?\d*)\s*([,\x2F\uFF0C])\s*(-?\d+\.?\d*)/g | 52 | const coordinateRegex = /^(\D*)(-?\d+\.?\d*)\s*([,\x2F\uFF0C])\s*(-?\d+\.?\d*)/ |
53 | const coordinateValue = { | 53 | const coordinateValue = { |
54 | validate: coordinateRegex, | 54 | validate: coordinateRegex, |
55 | normalize: function (match) { | 55 | normalize: function (match) { |
56 | const matches = [...match.raw.matchAll(coordinateRegex)] | 56 | const [, , x, sep, y] = match.text.match(coordinateRegex) |
57 | if (!matches[0]) return match | ||
58 | const [, , x, sep, y] = matches[0] | ||
59 | match.url = `geo:${y},${x}?xy=${x},${y}` | 57 | match.url = `geo:${y},${x}?xy=${x},${y}` |
60 | match.text = `${x}${sep}${y}` | 58 | match.text = `${x}${sep} ${y}` |
61 | match.index = match.raw.indexOf(x) | 59 | match.index += match.text.indexOf(x) + 1 |
62 | return match | 60 | return match |
63 | } | 61 | } |
64 | } | 62 | } |
65 | const patterns = ['(', '📍', '\uFF08', '@', 'geo:', 'twd'] | 63 | const patterns = ['[', '(', '📍', '\uFF08', '@', 'geo:', 'twd'] |
66 | patterns.forEach(prefix => | 64 | patterns.forEach(prefix => |
67 | md.linkify.add(prefix, coordinateValue) | 65 | md.linkify.add(prefix, coordinateValue) |
68 | ) | 66 | ) |