@fusion.dev/helix-docs 0.113.0 → 0.115.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/maps.mdx CHANGED
@@ -193,7 +193,7 @@ licenses require the credit to stay visible, so Helix never hides it.
193
193
  `mapSnapshot(view)` draws the map on your server as an SVG, from the same tiles
194
194
  and in the same colors as `mapLibreStyle`. Put it in the frame after the element
195
195
  MapLibre draws in, and the page shows a map from its first paint. `connectMap`
196
- fades it out once MapLibre has drawn its tiles.
196
+ fades it out once MapLibre has drawn the map whole.
197
197
 
198
198
  ```js
199
199
  import { mapSnapshot } from '@fusion.dev/helix-map/snapshot'
@@ -227,6 +227,32 @@ removing it to your framework.
227
227
  A snapshot is a flat map. A map zoomed out past about 6 is a globe in MapLibre,
228
228
  so draw snapshots of city and street views.
229
229
 
230
+ ## Show the map once it is drawn
231
+
232
+ MapLibre draws a map in stages: the streets, then the imagery tile by tile,
233
+ then the ground rising where there is terrain. `connectMap` tells the frame when
234
+ the map is drawn whole, with every tile the view needs and the ground in place.
235
+ The frame then sends `helix-map-ready` and matches `:state(ready)`. Its `ready`
236
+ property is `true` from then on, for code that runs after the event.
237
+
238
+ To show a map only once it is finished, fade it in on the state:
239
+
240
+ ```css
241
+ helix-map #map {
242
+ opacity: 0;
243
+ transition: opacity 0.3s;
244
+ }
245
+
246
+ helix-map:state(ready) #map {
247
+ opacity: 1;
248
+ }
249
+ ```
250
+
251
+ The routes and areas the frame draws are not part of "drawn whole", so a route
252
+ that moves along its progress does not hold the map back. A page that draws its
253
+ own map without `connectMap` calls `drawn()` on the frame when its map is
254
+ finished.
255
+
230
256
  ## What you can add to a map
231
257
 
232
258
  | Element | What it adds |
@@ -299,6 +325,29 @@ service such as OSRM or Valhalla.
299
325
  - `distancesAlong(points)` measures a route the same way the connector does, so
300
326
  something you move along the route and the lighter part stay in step.
301
327
 
328
+ An area is a shape, such as a delivery zone or a search sector. Set `caption` to
329
+ write a few words on the map with it:
330
+
331
+ ```html
332
+ <helix-map-area
333
+ caption="A"
334
+ label="Sector A"
335
+ points="30.2693,-97.7745 30.2693,-97.7700 30.2655,-97.7700 30.2655,-97.7745"
336
+ tone="success"
337
+ ></helix-map-area>
338
+ ```
339
+
340
+ The caption stands inside the area, at the point furthest from its edges. Set
341
+ `caption-placement="outside"` to stand it above the area's northernmost point
342
+ instead, clear of what the area holds. It is drawn in the area's color, brought
343
+ toward the theme's text color until it reaches a 4.5:1 contrast ratio against
344
+ the map, with a halo of the map's land around it. A caption is drawn, not
345
+ focusable, so it adds nothing to the tab order. A screen reader hears the area's
346
+ `label` in the frame's list of layers.
347
+
348
+ On Leaflet, pass `L`, as `leafletDriver(map, L)`, and the caption is drawn as a
349
+ marker that nobody can press or reach with the keyboard.
350
+
302
351
  ### Live positions
303
352
 
304
353
  ```html