@fusion.dev/helix-docs 0.104.1 → 0.106.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/accessibility.mdx +92 -71
- package/content/angular.mdx +26 -24
- package/content/browser-support.mdx +61 -58
- package/content/building-on-the-headless-tier.mdx +100 -74
- package/content/charting.mdx +98 -79
- package/content/coding-agents.mdx +87 -69
- package/content/color-modes.mdx +40 -37
- package/content/color.mdx +67 -54
- package/content/composition.mdx +85 -83
- package/content/elevation-and-material.mdx +32 -29
- package/content/events.mdx +77 -65
- package/content/forms.mdx +69 -58
- package/content/iconography.mdx +75 -71
- package/content/installation.mdx +77 -68
- package/content/intent-reference.mdx +59 -54
- package/content/introduction.mdx +25 -23
- package/content/localization.mdx +122 -82
- package/content/maps.mdx +431 -0
- package/content/metrics.mdx +296 -299
- package/content/motion.mdx +44 -36
- package/content/other-frameworks.mdx +33 -31
- package/content/overlays.mdx +72 -54
- package/content/overriding-a-component.mdx +85 -74
- package/content/react.mdx +72 -64
- package/content/recipes.mdx +64 -47
- package/content/routing.mdx +100 -93
- package/content/sandbox.mdx +39 -39
- package/content/server-rendering.mdx +95 -84
- package/content/shape-and-borders.mdx +44 -37
- package/content/size-and-density.mdx +51 -46
- package/content/space-and-size.mdx +41 -34
- package/content/state-and-control.mdx +63 -51
- package/content/surfaces-and-separation.mdx +55 -53
- package/content/svelte.mdx +20 -19
- package/content/theme-builder.mdx +42 -31
- package/content/theming.mdx +58 -51
- package/content/tiers.mdx +69 -61
- package/content/tokens.mdx +72 -53
- package/content/typography.mdx +47 -47
- package/content/using-helix-with-an-agent.mdx +147 -115
- package/content/using-the-elements.mdx +55 -50
- package/content/versioning.mdx +42 -35
- package/content/visual-axes.mdx +168 -146
- package/content/vue.mdx +24 -24
- package/content/without-a-bundler.mdx +40 -23
- package/dist/pages.generated.js +49 -43
- package/dist/sources.generated.js +3548 -2682
- package/package.json +3 -3
package/content/maps.mdx
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Add interactive maps to your site, styled with your theme and drawn by MapLibre or Leaflet.
|
|
3
|
+
section: Essentials
|
|
4
|
+
title: Maps
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Maps
|
|
8
|
+
|
|
9
|
+
Helix Maps puts a frame around a map drawn by MapLibre, Leaflet, or a renderer of
|
|
10
|
+
your own. The frame adds a column of controls and a place for the map credit. You
|
|
11
|
+
add places, routes, areas, live positions, and data as elements inside the
|
|
12
|
+
frame, and `@fusion.dev/helix-map` connects the frame to the renderer and styles
|
|
13
|
+
the map with your theme.
|
|
14
|
+
|
|
15
|
+
## Add a map
|
|
16
|
+
|
|
17
|
+
Install Helix, the map connector, and MapLibre:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
bun add @fusion.dev/helix @fusion.dev/helix-map maplibre-gl
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Add the map frame, an element for MapLibre to draw in, and your places:
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<helix-map label="Our stores">
|
|
27
|
+
<div id="map"></div>
|
|
28
|
+
<helix-map-marker
|
|
29
|
+
label="Flagship"
|
|
30
|
+
lat="30.2672"
|
|
31
|
+
lng="-97.7431"
|
|
32
|
+
></helix-map-marker>
|
|
33
|
+
</helix-map>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Create the map with a style from your theme, then connect it to the frame:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import '@fusion.dev/helix'
|
|
40
|
+
import 'maplibre-gl/dist/maplibre-gl.css'
|
|
41
|
+
import { colorsReady, connectMap } from '@fusion.dev/helix-map'
|
|
42
|
+
import { followTheme, mapLibreDriver, mapLibreStyle } from '@fusion.dev/helix-map/maplibre'
|
|
43
|
+
import maplibregl from 'maplibre-gl'
|
|
44
|
+
|
|
45
|
+
const frame = document.querySelector('helix-map')
|
|
46
|
+
const style = (colors) => mapLibreStyle(colors)
|
|
47
|
+
const map = new maplibregl.Map({
|
|
48
|
+
attributionControl: false,
|
|
49
|
+
container: 'map',
|
|
50
|
+
style: style(await colorsReady(frame)),
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const connection = connectMap(frame, mapLibreDriver(map))
|
|
54
|
+
connection.fit({ animate: false })
|
|
55
|
+
followTheme(map, frame, style)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## What the connector does
|
|
59
|
+
|
|
60
|
+
`connectMap` links the frame to the renderer:
|
|
61
|
+
|
|
62
|
+
- The frame's pan, zoom, rotate, and tilt buttons and keys move the map, using
|
|
63
|
+
your theme's motion settings. The map moves without animation when a user has asked for
|
|
64
|
+
reduced motion.
|
|
65
|
+
- The renderer's own keyboard handling and zoom buttons are turned off, so the
|
|
66
|
+
frame's controls are the only ones.
|
|
67
|
+
- The renderer's credit is shown in the frame's footer.
|
|
68
|
+
- `connection.fit()` frames every place on the map.
|
|
69
|
+
- `connection.disconnect()` puts back everything `connectMap` changed.
|
|
70
|
+
|
|
71
|
+
Use `mapLibreDriver(map)` for MapLibre GL JS 5 and `leafletDriver(map, L)` for
|
|
72
|
+
Leaflet 1.9. Neither renderer is bundled with Helix, so you can use the version
|
|
73
|
+
you already have. Leaflet draws routes, areas, and points only when you pass it
|
|
74
|
+
`L`.
|
|
75
|
+
|
|
76
|
+
## Style the map with your theme
|
|
77
|
+
|
|
78
|
+
`mapLibreStyle(colors)` builds a MapLibre style from five colors in your theme:
|
|
79
|
+
|
|
80
|
+
- Land uses `surface`.
|
|
81
|
+
- Water uses `info`.
|
|
82
|
+
- Parks use `success`.
|
|
83
|
+
- Main roads use `primary`, your brand color.
|
|
84
|
+
- Smaller roads, buildings, borders, and labels use `foreground`.
|
|
85
|
+
|
|
86
|
+
It also draws landmarks, highway signs, and neighborhood names:
|
|
87
|
+
|
|
88
|
+
- A landmark is an icon on a disc and its name, in a color for its kind:
|
|
89
|
+
parks, museums, schools, hotels, hospitals, stations, and stadiums from zoom
|
|
90
|
+
14, and food and shops from zoom 16. Each color is a fixed hue at your brand
|
|
91
|
+
color's lightness, so the kinds stay apart in any theme.
|
|
92
|
+
- A highway's number is on its sign, drawn to the Federal Highway
|
|
93
|
+
Administration's outlines: the red and blue Interstate shield, the white US
|
|
94
|
+
route shield, the white circle of a state route, and a plain plate for other
|
|
95
|
+
roads.
|
|
96
|
+
- Neighborhoods are in spaced capitals, quieter than the towns.
|
|
97
|
+
|
|
98
|
+
The same call builds a light map for a light theme and a dark map for a dark
|
|
99
|
+
theme. Map labels meet a contrast target of 4.5 against the land. Pass
|
|
100
|
+
`contrast` to change it, `language` to choose which name each place is labeled
|
|
101
|
+
with, and `tiles` and `glyphs` to use your own tile server.
|
|
102
|
+
|
|
103
|
+
Pass `font` to draw the labels in your theme's typeface. MapLibre draws the
|
|
104
|
+
letters in the page from the font your page has loaded, so there are no glyph
|
|
105
|
+
files to fetch. `mapFontFrom(frame)` reads the typeface from your theme, and
|
|
106
|
+
`fontReady(font)` waits until its weights are loaded. Wait for it before you
|
|
107
|
+
create the map, because MapLibre keeps each letter as first drawn:
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
const font = mapFontFrom(frame)
|
|
111
|
+
await fontReady(font)
|
|
112
|
+
const map = new maplibregl.Map({ container: 'map', style: mapLibreStyle(colors, { font }) })
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The style draws the world as a globe when the map is zoomed out. The globe turns
|
|
116
|
+
into the flat map as the map zooms in. `connectMap` hides markers on the far side
|
|
117
|
+
of the globe, and a keyboard user who moves to one turns the globe to show it.
|
|
118
|
+
Pass `globe: false` for a flat map at every zoom. MapLibre 4 has no globe, so
|
|
119
|
+
pass it there too.
|
|
120
|
+
|
|
121
|
+
`followTheme(map, frame, style)` restyles the map when your theme changes. It
|
|
122
|
+
watches for a new color mode, class, or theme value on the frame or its
|
|
123
|
+
ancestors, and for a change in the system's light or dark setting. If your page
|
|
124
|
+
changes its theme another way, such as by replacing a stylesheet, call
|
|
125
|
+
`update()` on the object `followTheme` returns.
|
|
126
|
+
|
|
127
|
+
`colorsReady(frame)` waits until your theme's colors can be read, which can take
|
|
128
|
+
a frame or two after the page loads. If the colors never become available, it
|
|
129
|
+
reports which one is missing.
|
|
130
|
+
|
|
131
|
+
## What you can add to a map
|
|
132
|
+
|
|
133
|
+
| Element | What it adds |
|
|
134
|
+
|---|---|
|
|
135
|
+
| `helix-map-marker` | A named place on the map |
|
|
136
|
+
| `helix-map-route` | A line, such as a delivery route |
|
|
137
|
+
| `helix-map-area` | A shape, such as a delivery zone |
|
|
138
|
+
| `helix-map-position` | A moving point or arrow, such as a vehicle |
|
|
139
|
+
| `helix-map-points` | Thousands of places loaded from GeoJSON |
|
|
140
|
+
| `helix-map-buildings` | The map's buildings, raised to their heights in 3D |
|
|
141
|
+
| `helix-map-raster` | Map tiles over the map, such as weather radar or satellite imagery |
|
|
142
|
+
| `helix-map-terrain` | Hills and mountains, shaded and raised in 3D |
|
|
143
|
+
| `helix-map-contours` | Contour lines, each at one height |
|
|
144
|
+
| `helix-map-landcover` | What covers the ground: forest, grass, farmland, sand, rock, and ice |
|
|
145
|
+
|
|
146
|
+
Each element takes `tone`, such as `primary` or `danger`, for its color.
|
|
147
|
+
|
|
148
|
+
### Markers
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<helix-map-marker
|
|
152
|
+
label="Texas Capitol"
|
|
153
|
+
lat="30.2747"
|
|
154
|
+
lng="-97.7405"
|
|
155
|
+
shape="ring"
|
|
156
|
+
>
|
|
157
|
+
<span slot="icon">B</span>
|
|
158
|
+
</helix-map-marker>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
A marker is a button placed at its latitude and longitude. Its `label` appears
|
|
162
|
+
when you hover over or focus the marker. The `icon` slot holds a letter, a
|
|
163
|
+
number, or an icon, and `shape` sets the marker's form: `ring`, `rounded`,
|
|
164
|
+
`square`, `diamond`, or `pin`. Pressing a marker sends `helix-activate` from the
|
|
165
|
+
frame with the marker's `name`, or its `label` if it has no name.
|
|
166
|
+
|
|
167
|
+
To show that a place has been visited, add `passed`. The marker is drawn in a
|
|
168
|
+
muted color, and screen readers hear its name followed by "passed". Use
|
|
169
|
+
`passed-label` to change that word.
|
|
170
|
+
|
|
171
|
+
### Clusters
|
|
172
|
+
|
|
173
|
+
Add `cluster` to the frame to combine markers that would overlap into one
|
|
174
|
+
count. The count splits apart as you zoom in, and pressing it zooms in to its
|
|
175
|
+
places. Places at the same location, such as two businesses at one address,
|
|
176
|
+
spread out around that point when you press their count. Press Escape to
|
|
177
|
+
combine them again.
|
|
178
|
+
|
|
179
|
+
To handle a pressed cluster yourself, for example by listing its places in a
|
|
180
|
+
panel, pass `clusterZoom: false` to `connectMap` and listen for
|
|
181
|
+
`helix-map-cluster`.
|
|
182
|
+
|
|
183
|
+
### Routes and areas
|
|
184
|
+
|
|
185
|
+
```html
|
|
186
|
+
<helix-map-route
|
|
187
|
+
description="4.2 km"
|
|
188
|
+
label="Depot to Mission"
|
|
189
|
+
points="37.7955,-122.3937 37.7644,-122.427"
|
|
190
|
+
progress="0.4"
|
|
191
|
+
></helix-map-route>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Write `points` as `lat,lng` pairs separated by spaces. A route draws straight
|
|
195
|
+
lines between its points, so to follow streets, pass the path from a routing
|
|
196
|
+
service such as OSRM or Valhalla.
|
|
197
|
+
|
|
198
|
+
- `progress`, from 0 to 1, draws the part already traveled in a lighter color.
|
|
199
|
+
- `variant="dotted"` draws a route as dots, for a walk off the road network.
|
|
200
|
+
- `distancesAlong(points)` measures a route the same way the connector does, so
|
|
201
|
+
something you move along the route and the lighter part stay in step.
|
|
202
|
+
|
|
203
|
+
### Live positions
|
|
204
|
+
|
|
205
|
+
```html
|
|
206
|
+
<helix-map-position
|
|
207
|
+
accuracy="30"
|
|
208
|
+
description="Two stops away"
|
|
209
|
+
heading="90"
|
|
210
|
+
label="Van 12"
|
|
211
|
+
lat="37.78"
|
|
212
|
+
lng="-122.41"
|
|
213
|
+
></helix-map-position>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Update `lat`, `lng`, and `heading` as the position moves. `heading` turns it
|
|
217
|
+
into an arrow, and `accuracy` draws a ring with a radius of that many meters. Screen
|
|
218
|
+
readers announce its `description` when it changes, at most once every
|
|
219
|
+
`announce-every` milliseconds. Its movement is not announced.
|
|
220
|
+
|
|
221
|
+
### Thousands of points
|
|
222
|
+
|
|
223
|
+
```html
|
|
224
|
+
<helix-map-points
|
|
225
|
+
cluster
|
|
226
|
+
label="Food and drink"
|
|
227
|
+
src="/places.geojson"
|
|
228
|
+
></helix-map-points>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Use `helix-map-points` for more places than markers can handle. MapLibre draws
|
|
232
|
+
all of them as one layer, loaded from a GeoJSON file in `src` or from data you
|
|
233
|
+
set on `data`. With `cluster`, nearby points combine into counts, and pressing a
|
|
234
|
+
count zooms in to it. Pressing a point sends `helix-activate` from the layer
|
|
235
|
+
with the point's id, or with the property named by `name-key`. Leaflet draws
|
|
236
|
+
each point on its own, which works for hundreds of points.
|
|
237
|
+
|
|
238
|
+
### Buildings in 3D
|
|
239
|
+
|
|
240
|
+
```html
|
|
241
|
+
<helix-map-buildings></helix-map-buildings>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
`helix-map-buildings` raises the buildings in the map's tiles to the heights the
|
|
245
|
+
tiles record, in your theme's raised surface color. Set `tone` to color them by
|
|
246
|
+
meaning. The buildings appear from zoom 13. To see their height, tilt the map by
|
|
247
|
+
setting `pitch` when you create it:
|
|
248
|
+
|
|
249
|
+
```js
|
|
250
|
+
const map = new maplibregl.Map({ container: 'map', pitch: 55, style, zoom: 15.5 })
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
To let users tilt the map, add `tilt` to the frame's `controls`:
|
|
254
|
+
|
|
255
|
+
```html
|
|
256
|
+
<helix-map
|
|
257
|
+
controls="zoom compass tilt fullscreen"
|
|
258
|
+
label="Downtown Austin in 3D"
|
|
259
|
+
>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The 3D button is a toggle. Pressed, it tilts the map 50 degrees toward the
|
|
263
|
+
horizon and raises the buildings. Pressed again, it makes the map flat, and the
|
|
264
|
+
buildings are the map's own flat footprints. Raised terrain lies flat with them,
|
|
265
|
+
and keeps its shading. The compass's needle points north as the map turns, and
|
|
266
|
+
pressing the compass turns the map back to north.
|
|
267
|
+
|
|
268
|
+
Leaflet draws maps flat and does not rotate, so a Leaflet map shows no
|
|
269
|
+
buildings, and the compass and the 3D button do nothing.
|
|
270
|
+
|
|
271
|
+
### Weather and other tile overlays
|
|
272
|
+
|
|
273
|
+
```html
|
|
274
|
+
<helix-map-raster
|
|
275
|
+
attribution="Radar from Example Weather"
|
|
276
|
+
frames="https://tiles.example/radar-50m/{z}/{x}/{y}.png https://tiles.example/radar-now/{z}/{x}/{y}.png"
|
|
277
|
+
label="Weather radar"
|
|
278
|
+
></helix-map-raster>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
`helix-map-raster` draws map tiles over the land and roads, and under your
|
|
282
|
+
routes, areas, and place names. Set `src` to one tile URL, or `frames` to
|
|
283
|
+
several, and set `playing` to show the frames in order, `interval` milliseconds
|
|
284
|
+
each. Every frame's tiles load once, so the loop plays without a blank frame.
|
|
285
|
+
|
|
286
|
+
- Put the tile provider's credit in `attribution`. The frame shows it beside
|
|
287
|
+
the map's credit.
|
|
288
|
+
- The frames do not play while the user has asked for reduced motion.
|
|
289
|
+
- Content that moves for more than five seconds needs a way to pause it, so
|
|
290
|
+
give `playing` a control on your page.
|
|
291
|
+
|
|
292
|
+
### Satellite imagery and map types
|
|
293
|
+
|
|
294
|
+
```html
|
|
295
|
+
<helix-map-raster
|
|
296
|
+
attribution="Imagery from USGS The National Map"
|
|
297
|
+
ground
|
|
298
|
+
label="Satellite imagery"
|
|
299
|
+
max-zoom="16"
|
|
300
|
+
opacity="1"
|
|
301
|
+
src="https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}"
|
|
302
|
+
></helix-map-raster>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Set `ground` on `helix-map-raster` to make its tiles the map's imagery. Imagery
|
|
306
|
+
is a map type, which the frame's `map-type` attribute chooses:
|
|
307
|
+
|
|
308
|
+
- Absent, the Standard map: your themed map, without the imagery.
|
|
309
|
+
- `hybrid`: the imagery in place of the map's land, under its roads and names.
|
|
310
|
+
- `satellite`: the imagery alone, without the roads and names.
|
|
311
|
+
|
|
312
|
+
With `layers` in the frame's `controls`, the layers menu opens with a card for
|
|
313
|
+
each map type, showing a picture of the map in it. Set `max-zoom` to the deepest
|
|
314
|
+
zoom your provider has tiles for, and the map enlarges those tiles when a user
|
|
315
|
+
zooms in further.
|
|
316
|
+
|
|
317
|
+
The imagery above is from the U.S. Geological Survey. It is in the public domain
|
|
318
|
+
and covers the United States. Some providers put `{y}` before `{x}` in their
|
|
319
|
+
tile URLs, as this one does.
|
|
320
|
+
|
|
321
|
+
### Terrain
|
|
322
|
+
|
|
323
|
+
```html
|
|
324
|
+
<helix-map-terrain
|
|
325
|
+
attribution="Elevation from 3DEP and SRTM data, courtesy of the U.S. Geological Survey"
|
|
326
|
+
max-zoom="15"
|
|
327
|
+
raised
|
|
328
|
+
src="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"
|
|
329
|
+
></helix-map-terrain>
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
`helix-map-terrain` shades the land by its slopes, so hills and valleys show on a
|
|
333
|
+
flat map. Set `raised` to raise the ground to its real height as well, and tilt
|
|
334
|
+
the map to see it. Set `exaggeration` to raise it more than its real height,
|
|
335
|
+
such as `1.5`. Routes, areas, and buildings lie on the raised ground.
|
|
336
|
+
|
|
337
|
+
The elevation tiles above are Terrain Tiles on AWS, which are free to use and
|
|
338
|
+
cover the world. Their tiles store heights in the `terrarium` encoding, which is
|
|
339
|
+
the default. For tiles in the Mapbox encoding, set `encoding="mapbox"`. Credit
|
|
340
|
+
the sources your map shows: in the United States, the U.S. Geological Survey.
|
|
341
|
+
|
|
342
|
+
Leaflet draws maps flat, so a Leaflet map shows no terrain.
|
|
343
|
+
|
|
344
|
+
### Contour lines
|
|
345
|
+
|
|
346
|
+
```html
|
|
347
|
+
<helix-map-contours
|
|
348
|
+
max-zoom="15"
|
|
349
|
+
src="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"
|
|
350
|
+
unit="feet"
|
|
351
|
+
></helix-map-contours>
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
`helix-map-contours` draws lines of equal height from the same elevation tiles
|
|
355
|
+
as terrain. The lines are closer together as the map zooms in, from 500 meters
|
|
356
|
+
apart over a region to 5 meters at street level. Every fifth line is heavier and
|
|
357
|
+
labeled with its height, in meters, or in feet with `unit="feet"`. They show
|
|
358
|
+
from zoom 9, and lie on the ground when it is raised.
|
|
359
|
+
|
|
360
|
+
### Land cover
|
|
361
|
+
|
|
362
|
+
```html
|
|
363
|
+
<helix-map-landcover></helix-map-landcover>
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
`helix-map-landcover` colors the ground by what covers it: forest and grass in
|
|
367
|
+
greens, farmland in wheat, wetland in teal, sand in tan, rock in gray, and ice
|
|
368
|
+
in pale blue. Each color is mixed into your theme's land color. It draws over
|
|
369
|
+
parks and under water and roads, so a park shows its meadows and forests.
|
|
370
|
+
|
|
371
|
+
### Turn layers on and off
|
|
372
|
+
|
|
373
|
+
```html
|
|
374
|
+
<helix-map
|
|
375
|
+
controls="zoom compass layers fullscreen"
|
|
376
|
+
label="Downtown Austin"
|
|
377
|
+
>
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Add `layers` to the frame's `controls` for a layers button. It opens a menu with
|
|
381
|
+
a tile for each layer: a picture of what the layer draws, and its `label`. A
|
|
382
|
+
tile is lit while its layer is shown. Pressing a tile sets its layer's `hidden`
|
|
383
|
+
attribute, and `connectMap` does not draw a hidden layer. Write `hidden` on a
|
|
384
|
+
layer to start it turned off.
|
|
385
|
+
|
|
386
|
+
Give layers the same `group` to show them as one tile, such as a route and the
|
|
387
|
+
dotted legs at its ends. The tile takes the name of the first layer in the
|
|
388
|
+
group, and shows or hides every layer in it. Keep labels short, such as
|
|
389
|
+
"Walking route", and put the rest in `description`, which screen readers read
|
|
390
|
+
after the label.
|
|
391
|
+
|
|
392
|
+
## Keyboard and screen readers
|
|
393
|
+
|
|
394
|
+
- The frame is one tab stop. Arrow keys pan the map, and the plus and minus keys
|
|
395
|
+
zoom it. Shift with Left or Right rotates the map, and Shift with Up or Down
|
|
396
|
+
tilts it.
|
|
397
|
+
- The markers are one tab stop. Arrow keys move between them in the order you
|
|
398
|
+
wrote them. The map pans to show a marker that is off screen.
|
|
399
|
+
- A points layer is one tab stop over the points and counts in view. Arrow keys
|
|
400
|
+
move top to bottom and along each line. Enter on a count zooms in to it.
|
|
401
|
+
- Screen readers find the map's shown layers in a list inside the frame, named
|
|
402
|
+
by their `label` and `description`.
|
|
403
|
+
- With a pointer, dragging is the only way to move and turn the map. Where your
|
|
404
|
+
map has to work without dragging, as WCAG 2.2 asks at level AA, add `pan` and
|
|
405
|
+
`rotate` to `controls` for buttons around the compass that move and turn it.
|
|
406
|
+
- In the layers menu, Tab moves between the tiles, Space or Enter turns a layer
|
|
407
|
+
on or off, and Escape closes the menu.
|
|
408
|
+
|
|
409
|
+
## Write a driver
|
|
410
|
+
|
|
411
|
+
To use another renderer, write a driver: an object with two methods.
|
|
412
|
+
|
|
413
|
+
- `panBy(x, y, motion)` moves the map by a number of pixels.
|
|
414
|
+
- `zoomBy(direction, motion)` zooms in for `1` and out for `-1`.
|
|
415
|
+
|
|
416
|
+
`motion` is your theme's `{ duration, easing }`, or `null` to move without
|
|
417
|
+
animation. Each optional method turns on a feature:
|
|
418
|
+
|
|
419
|
+
| Method | Turns on |
|
|
420
|
+
|---|---|
|
|
421
|
+
| `project`, `onView` | Placing markers and positions |
|
|
422
|
+
| `show` | Bringing a focused marker into view |
|
|
423
|
+
| `fit` | `connection.fit()` and zooming in to clusters |
|
|
424
|
+
| `layers` | Drawing routes, areas, and points |
|
|
425
|
+
| `credits` | The map credit in the frame's footer |
|
|
426
|
+
| `silenceKeyboard`, `focusTarget`, `replaceZoom` | Using the frame's keys and zoom buttons |
|
|
427
|
+
| `bearing` | Arrows that stay correct when the map is rotated, and the Face north arrow |
|
|
428
|
+
| `rotate`, `tilt` | The rotate, Face north, and tilt buttons and keys |
|
|
429
|
+
|
|
430
|
+
Without `project`, markers stay hidden. To animate a move your page makes
|
|
431
|
+
itself, read the same motion with `motionOf(element, pace)`.
|