@fusion.dev/helix-docs 0.112.0 → 0.114.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
@@ -106,6 +106,19 @@ It also draws landmarks, highway signs, and neighborhood names:
106
106
  roads.
107
107
  - Neighborhoods are in spaced capitals, quieter than the towns.
108
108
 
109
+ Pass `landmarks` to choose which kinds the map draws. `false` draws none, for a
110
+ map whose own markers are the places a reader is looking for. A list draws only
111
+ those kinds:
112
+
113
+ ```js
114
+ mapLibreStyle(colors, { landmarks: ['nature', 'transit'] })
115
+ ```
116
+
117
+ The kinds are `culture`, `food`, `health`, `learning`, `lodging`, `nature`,
118
+ `shopping`, `sport`, and `transit`, and `MAP_LANDMARKS` lists them. The option
119
+ holds when `followTheme` restyles the map, because it builds the style from the
120
+ same options.
121
+
109
122
  The same call builds a light map for a light theme and a dark map for a dark
110
123
  theme. Map labels meet a contrast target of 4.5 against the land. Pass
111
124
  `contrast` to change it, `language` to choose which name each place is labeled
@@ -139,12 +152,48 @@ changes its theme another way, such as by replacing a stylesheet, call
139
152
  a frame or two after the page loads. If the colors never become available, it
140
153
  reports which one is missing.
141
154
 
155
+ ## Put a map behind your content
156
+
157
+ Set `fill` to lay a map behind your page's own content, such as a hero whose
158
+ words decide its height. The frame covers its container instead of taking a
159
+ height of its own, and draws no border or corners, because the container's edge
160
+ is the map's. Give the container a position, such as `position: relative`:
161
+
162
+ ```html
163
+ <section class="hero">
164
+ <helix-map fill credit-placement="bottom-end" label="Downtown Austin">
165
+ <div id="map"></div>
166
+ </helix-map>
167
+ <div class="hero-words">
168
+ <h1>Every stop, one map</h1>
169
+ </div>
170
+ </section>
171
+ ```
172
+
173
+ ```css
174
+ .hero,
175
+ .hero-words {
176
+ position: relative;
177
+ }
178
+ ```
179
+
180
+ Content after the map, with a position of its own, is drawn over it. Give that
181
+ content a ground of its own, such as a translucent panel, so it reads over any
182
+ part of the map.
183
+
184
+ `credit-placement` draws the map's credit in a corner over the map instead of in
185
+ a strip under it. Use `bottom-end` or `bottom-start`, and keep it away from the
186
+ corner your controls are in. The credit is one line until it is pointed at or
187
+ its links are focused, and then it shows in full. That compact form is the one
188
+ OpenStreetMap's attribution guidance accepts for a small credit. Most tile
189
+ licenses require the credit to stay visible, so Helix never hides it.
190
+
142
191
  ## Draw the map before it loads
143
192
 
144
193
  `mapSnapshot(view)` draws the map on your server as an SVG, from the same tiles
145
194
  and in the same colors as `mapLibreStyle`. Put it in the frame after the element
146
195
  MapLibre draws in, and the page shows a map from its first paint. `connectMap`
147
- fades it out once MapLibre has drawn its tiles.
196
+ fades it out once MapLibre has drawn the map whole.
148
197
 
149
198
  ```js
150
199
  import { mapSnapshot } from '@fusion.dev/helix-map/snapshot'
@@ -178,6 +227,32 @@ removing it to your framework.
178
227
  A snapshot is a flat map. A map zoomed out past about 6 is a globe in MapLibre,
179
228
  so draw snapshots of city and street views.
180
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
+
181
256
  ## What you can add to a map
182
257
 
183
258
  | Element | What it adds |