1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
# Dumbymap
This library generate web maps from [Semantic HTML], just play around with [demo page](https://outdoorsafetylab.github.io/dumbymap/)
> [!IMPORTANT]
> For build steps about firefox addon, please visit `DEVELOPING.md`
> [!CAUTION]
> DumbyMap is not in production stage. API is not stable now, use it carefully
## Getting Started
Browser (CDN):
- unpkg: https://unpkg.com/dumbymap@latest/dist/dumbymap.mjs
Node.js:
```bash
npm install dumbymap
```
```js
import { markdown2HTML, generateMaps } from 'dumbymap'
// Create container element
const container = document.createElement('div')
document.body.append(container)
// Convert markdown text into Semantic HTML
markdown2HTML(container, '# Heading\n\n```map\nid: foo\nuse: Maplibre\n```\n')
// Gernerate maps from code block
const dumbymap = generateMaps(container, options ?? {})
```
For more information, please visie [docs page](https://outdoorsafetylab.github.io/dumbymap/docs/global.html#generateMaps)
## Semantic HTML
Dumbymap adds several features from contents of Semantic HTML:
### Code Block for map
Generated from Element fits CSS Selector `:has(.language-map)` (by default)
It generates maps by `textContent` in YAML format, done by [mapclay]
For example:
~~~markdown
<!-- Markdown Text -->
```map
use: Maplibre
width: 200px
```
<!-- HTML -->
<pre><code class="language-map">use: Maplibre
width: 200px</code></pre>
~~~
### DocLink
Generated from anchor element which:
1. With has link for [document fragment](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#linking_to_an_element_on_the_same_page).
2. With title starts from `=>`
3. The following text in title would be treated as CSS selector of target element
It shows leader-line to target element on hover, for example:
```markdown
<!-- Markdown Text -->
[link](#TEXT "=>.random-class")
<!-- Anchor Element -->
<a href="#TEXT" title="=>.random-class">link</a>
```
Generated from anchor element which:
1. With has link for [document fragment](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#linking_to_an_element_on_the_same_page).
2. With title starts from `=>`
3. The following text of title would be treated as CSS selector of target element
Class name `with-leader-line` and `doclink` would be added to element.
It shows leader-line to target element on hover, for example:
```markdown
<!-- Markdown Text -->
[link](#TEXT "=>.random-class")
<!-- Anchor Element -->
<a href="#TEXT" title="=>.random-class">link</a>
<!-- Links above is transfered to this -->
<a class="with-leader-line doclink" href="#TEXT" title="=>.random-class">link</a>
```
### GeoLink
Generated from anchor element with [geo URI scheme](https://en.wikipedia.org/wiki/Geo_URI_scheme).
Class name `with-leader-line` and `geolink` would be added to element.
It show leader-line to coordinates in target map elements, for example:
```markdown
<!-- markdown text -->
[Taiwan](geo:24,121)
<!-- anchor element -->
<a href="geo:24,121">Taiwan</a>
<!-- Links above is transfered to this -->
<a class="with-leader-line geolink" href="geo:24,121">Taiwan</a>
```
It changes behaviors by query parameters in link:
1. If `xy` is specified, GeoLink would use its value instead of value in geo URI scheme
1. If `id` is specified, GeoLink would only points to map with its value. Can use comma to add multiple id
1. If `type` is specified, anchor on map changes appearance (now only support `type=circle`)
For example:
```html
<!-- The following link points to coordinates [274527,2665529] in map element "map1" and "map2"
<a href="geo:24,121?xy=274527,2665529&id=map1,map2">Taiwan</a>
```
If `title` of element is specified, leader-line use it as label, for example:
```markdown
<!-- markdown text -->
[Taiwan](geo:24,121 "Here it is!")
<!-- anchor element -->
<a href="geo:24,121" title="Here it is!">Taiwan</a>
```
## Structure
After `generateMaps()`, the container has the following structure:

For each element:
* `class="Dumby"`: Container of DumbyMap Contents. It uses attribute `data-layout` to switch layout
* `class="SemanticHtml"`: Container of Semantic HTML
* `class="Showcase"`: Container of map with `class="focus"`. Some layouts use it to display focused map
* `class="dumby-block"`: Block contains part of contents of Semantic HTML.
* `class="mapclay"`: Map generated by [mapclay]
## Layouts
Dumbymap switch layouts by attribute `data-layout` of container. Most of the features are done by pure CSS.
You can add custom layout by options `layouts`. For example, the following code add a new layout `sticky` to stick `Showcase` at bottom right corner:
```css
.Dumby[data-layout='sticky'] {
max-width: 80em;
.Showcase {
display: block;
width: 20vw;
height: 40vh;
position: absolute;
right: 20px;
bottom: 20px;
background: red;
}
}
```
```js
generateMaps(container, { layouts: "sticky" })
```
<details><summary>Result:</summary>

</details>
## Dependencies
- [leader-line](https://anseki.github.io/leader-line/)
- [plain-draggable](https://anseki.github.io/plain-draggable/)
- [markdown-it](https://github.com/markdown-it/markdown-it/)
- [mapclay]
- [EasyMDE](https://github.com/Ionaru/easy-markdown-editor)
## Motivation
* Respect Semantic HTML
* User Friendly: The target audience includes Hikers, Outdoor Workers
* Easy to Extend: Can co-work with various of Modern Map Libraries, no one dominates
* [Designed to Last](https://jeffhuang.com/designed_to_last/)
## See Also
* [obsidian-map-view](https://github.com/esm7/obsidian-map-view)
* [odyssey.js](http://cartodb.github.io/odyssey.js/)
* [StoryMapJS](https://storymap.knightlab.com/)
[mapclay]: https://github.com/outdoorsafetylab/mapclay
[Semantic HTML]: https://developer.mozilla.org/en-US/docs/Glossary/Semantics#semantics_in_html
|