diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-04 16:01:22 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-04 19:36:50 +0800 |
commit | e4f6b7ecd5872d1ec80d3aa961ffa93708291224 (patch) | |
tree | 7dea3fc33bf54be82ebc4ffc6fa300aecc41c5be /README.md | |
parent | dbd3b03ec842c446488135853ed380f5a75adb27 (diff) |
docs: update README
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 129 |
1 files changed, 117 insertions, 12 deletions
@@ -20,20 +20,124 @@ document.body.append(container) | |||
20 | markdown2HTML(container, '# Heading\n\n```map\nid: foo\nuse: Maplibre\n```\n') | 20 | markdown2HTML(container, '# Heading\n\n```map\nid: foo\nuse: Maplibre\n```\n') |
21 | 21 | ||
22 | // Gernerate maps from code block | 22 | // Gernerate maps from code block |
23 | generateMaps(container) | 23 | const dumbymap = generateMaps(container) |
24 | ``` | 24 | ``` |
25 | 25 | ||
26 | Browser (CDN): | 26 | Browser (CDN): |
27 | - unpkg: https://unpkg.com/dumbymap@latest/dist/dumbymap.mjs | 27 | - unpkg: https://unpkg.com/dumbymap@latest/dist/dumbymap.mjs |
28 | 28 | ||
29 | ## Semantic HTML | ||
30 | |||
31 | Dumbymap adds several features by Semantic HTML: | ||
32 | |||
33 | ### Code Block for map | ||
34 | |||
35 | Generated from Element fits CSS Selector `:has(.language-map)` | ||
36 | |||
37 | It generates maps by `textContent` in YAML format, done by [`mapclay`](/outdoorsafetylab/mapclay). | ||
38 | |||
39 | For example: | ||
40 | ~~~markdown | ||
41 | <!-- Markdown Text --> | ||
42 | ```map | ||
43 | use: Maplibre | ||
44 | width: 200px | ||
45 | ``` | ||
46 | |||
47 | <!-- HTML --> | ||
48 | <pre><code class="language-map">use: Maplibre | ||
49 | width: 200px</code></pre> | ||
50 | ~~~ | ||
51 | |||
52 | ### DocLink | ||
53 | |||
54 | Generated from anchor element which: | ||
55 | 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). | ||
56 | 2. With title starts from `=>` | ||
57 | 3. The following text in title would be treated as CSS selector of target element | ||
58 | |||
59 | It shows leader-line to target element on hover, for example: | ||
60 | |||
61 | ```markdown | ||
62 | <!-- Markdown Text --> | ||
63 | [link](#TEXT "=>.random-class") | ||
64 | |||
65 | <!-- Anchor Element --> | ||
66 | <a href="#TEXT" title="=>.random-class">link</a> | ||
67 | ``` | ||
68 | |||
69 | Generated from anchor element which: | ||
70 | 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). | ||
71 | 2. With title starts from `=>` | ||
72 | 3. The following text of title would be treated as CSS selector of target element | ||
73 | |||
74 | Class name `with-leader-line` and `doclink` would be added to element. | ||
75 | |||
76 | It shows leader-line to target element on hover, for example: | ||
77 | |||
78 | ```markdown | ||
79 | <!-- Markdown Text --> | ||
80 | [link](#TEXT "=>.random-class") | ||
81 | |||
82 | <!-- Anchor Element --> | ||
83 | <a href="#TEXT" title="=>.random-class">link</a> | ||
84 | |||
85 | |||
86 | <!-- Links above is transfered to this --> | ||
87 | <a class="with-leader-line doclink" href="#TEXT" title="=>.random-class">link</a> | ||
88 | ``` | ||
89 | |||
90 | ### GeoLink | ||
91 | |||
92 | Generated from anchor element with [geo URI scheme](https://en.wikipedia.org/wiki/Geo_URI_scheme). | ||
93 | Class name `with-leader-line` and `geolink` would be added to element. | ||
94 | |||
95 | It show leader-line to coordinates in target map elements, for example: | ||
96 | |||
97 | ```markdown | ||
98 | <!-- markdown text --> | ||
99 | [Taiwan](geo:24,121) | ||
100 | |||
101 | <!-- anchor element --> | ||
102 | <a href="geo:24,121" title="Here it is!">Taiwan</a> | ||
103 | |||
104 | |||
105 | <!-- Links above is transfered to this --> | ||
106 | <a class="with-leader-line geolink" href="geo:24,121" title="Here it is!">Taiwan</a> | ||
107 | ``` | ||
108 | |||
109 | It changes behaviors by query parameters in link: | ||
110 | 1. If `xy` is specified, GeoLink would use its value instead of value in geo URI scheme | ||
111 | 2. If `id` is specified, GeoLink would only points to map with its value. Can use comma to add multiple id | ||
112 | |||
113 | For example: | ||
114 | ```html | ||
115 | <!-- The following link points to coordinates [274527,2665529] in map element "map1" and "map2" | ||
116 | <a href="geo:24,121?xy=274527,2665529&id=map1,map2" title="Here it is!">Taiwan</a> | ||
117 | ``` | ||
118 | |||
29 | ## Structure | 119 | ## Structure |
30 | 120 | ||
31 | After `generateMaps()`, the container has the following structure: | 121 | After `generateMaps()`, the container has the following structure: |
32 | 122 | ||
33 |  | 123 |  |
34 | 124 | ||
125 | ## Layouts | ||
126 | |||
127 | Dumbymap switch layouts by attribute `data-layout` of container. Most of the features are done by pure CSS. | ||
128 | |||
129 | You can add custom layout by options `layouts`: | ||
130 | |||
131 | ```js | ||
132 | generateMaps(container, { | ||
133 | layouts: [ | ||
134 | "LAYOUT-NAME" | ||
135 | ] | ||
136 | }) | ||
137 | ``` | ||
138 | |||
35 | 139 | ||
36 | ## Depandencies | 140 | ## Dependencies |
37 | 141 | ||
38 | - [leader-line](https://anseki.github.io/leader-line/) | 142 | - [leader-line](https://anseki.github.io/leader-line/) |
39 | - [plain-draggable](https://anseki.github.io/plain-draggable/) | 143 | - [plain-draggable](https://anseki.github.io/plain-draggable/) |
@@ -42,14 +146,15 @@ After `generateMaps()`, the container has the following structure: | |||
42 | - [EasyMDE](https://github.com/Ionaru/easy-markdown-editor) | 146 | - [EasyMDE](https://github.com/Ionaru/easy-markdown-editor) |
43 | 147 | ||
44 | 148 | ||
45 | ## TODOs | 149 | ## Motivation |
150 | |||
151 | * Respect Semantic HTML | ||
152 | * User Friendly: The target audience includes Hikers, Outdoor Workers | ||
153 | * Easy to Extend: Can co-work with various of Modern Map Libraries, no one dominates | ||
154 | * [Designed to Last](https://jeffhuang.com/designed_to_last/) | ||
155 | |||
156 | ## See Also | ||
46 | 157 | ||
47 | - Semantic HTML | 158 | * [obsidian-map-view](https://github.com/esm7/obsidian-map-view) |
48 | - context menu for add geolinks | 159 | * [odyssey.js](http://cartodb.github.io/odyssey.js/) |
49 | - Editor | 160 | * [StoryMapJS](https://storymap.knightlab.com/) |
50 | - Reduce fontawesome resources | ||
51 | - Better way to edit table in markdown | ||
52 | - Export | ||
53 | - Executable HTML file with data URI | ||
54 | - Misc | ||
55 | - Add favicon | ||