@reuters-graphics/graphics-components 3.10.0 → 4.0.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/dist/components/Analytics/GTM.svelte.d.ts +3 -3
- package/dist/components/BlogPost/BlogPost.svelte +6 -5
- package/dist/components/BlogPost/BlogPost.svelte.d.ts +3 -2
- package/dist/components/BlogPost/CopyLink.svelte +7 -4
- package/dist/components/BlogPost/CopyLink.svelte.d.ts +5 -2
- package/dist/components/BlogPost/PostHeadline.svelte +7 -4
- package/dist/components/BlogPost/PostHeadline.svelte.d.ts +5 -2
- package/dist/components/BlogPost/utils.d.ts +2 -1
- package/dist/components/BlogPost/utils.js +8 -2
- package/dist/components/BlogTOC/BlogTOC.svelte +7 -4
- package/dist/components/BlogTOC/BlogTOC.svelte.d.ts +8 -5
- package/dist/components/BlogTOC/TOCList.svelte.d.ts +3 -3
- package/dist/components/Headpile/Headpile.svelte +2 -2
- package/dist/components/Headpile/Headpile.svelte.d.ts +2 -2
- package/dist/components/LanguageButton/LanguageButton.svelte +10 -7
- package/dist/components/LanguageButton/LanguageButton.svelte.d.ts +5 -2
- package/dist/components/SEO/SEO.svelte.d.ts +3 -3
- package/dist/components/Video/Video.svelte +2 -2
- package/dist/llm-docs/components/AdSlot.md +11 -0
- package/dist/llm-docs/components/Analytics.md +89 -0
- package/dist/llm-docs/components/Article.md +183 -0
- package/dist/llm-docs/components/BeforeAfter.md +170 -0
- package/dist/llm-docs/components/BioBox.md +74 -0
- package/dist/llm-docs/components/Block.md +211 -0
- package/dist/llm-docs/components/BlogPost.md +66 -0
- package/dist/llm-docs/components/BlogTOC.md +89 -0
- package/dist/llm-docs/components/BodyText.md +143 -0
- package/dist/llm-docs/components/Byline.md +242 -0
- package/dist/llm-docs/components/ClockWall.md +48 -0
- package/dist/llm-docs/components/DatawrapperChart.md +87 -0
- package/dist/llm-docs/components/DocumentCloud.md +47 -0
- package/dist/llm-docs/components/EmbedPreviewerLink.md +35 -0
- package/dist/llm-docs/components/EndNotes.md +79 -0
- package/dist/llm-docs/components/FeaturePhoto.md +102 -0
- package/dist/llm-docs/components/Framer.md +44 -0
- package/dist/llm-docs/components/Geocoder.md +49 -0
- package/dist/llm-docs/components/GraphicBlock.md +319 -0
- package/dist/llm-docs/components/Headline.md +248 -0
- package/dist/llm-docs/components/Headpile.md +55 -0
- package/dist/llm-docs/components/HeroHeadline.md +515 -0
- package/dist/llm-docs/components/HorizontalScroller.md +523 -0
- package/dist/llm-docs/components/InfoBox.md +196 -0
- package/dist/llm-docs/components/KinesisLogo.md +34 -0
- package/dist/llm-docs/components/LanguageButton.md +170 -0
- package/dist/llm-docs/components/Legend.md +251 -0
- package/dist/llm-docs/components/Lottie.md +464 -0
- package/dist/llm-docs/components/PaddingReset.md +78 -0
- package/dist/llm-docs/components/PhotoPack.md +238 -0
- package/dist/llm-docs/components/PymChild.md +49 -0
- package/dist/llm-docs/components/ReferralBlock.md +119 -0
- package/dist/llm-docs/components/ReutersGraphicsLogo.md +37 -0
- package/dist/llm-docs/components/ReutersLogo.md +35 -0
- package/dist/llm-docs/components/SEO.md +113 -0
- package/dist/llm-docs/components/Scroller.md +350 -0
- package/dist/llm-docs/components/ScrollerBase.md +104 -0
- package/dist/llm-docs/components/ScrollerVideo.md +576 -0
- package/dist/llm-docs/components/SearchInput.md +44 -0
- package/dist/llm-docs/components/ShareBar.md +78 -0
- package/dist/llm-docs/components/SimpleTimeline.md +141 -0
- package/dist/llm-docs/components/SiteFooter.md +77 -0
- package/dist/llm-docs/components/SiteHeader.md +55 -0
- package/dist/llm-docs/components/SiteHeadline.md +111 -0
- package/dist/llm-docs/components/Spinner.md +43 -0
- package/dist/llm-docs/components/Table.md +298 -0
- package/dist/llm-docs/components/Theme.md +266 -0
- package/dist/llm-docs/components/TileMap.md +477 -0
- package/dist/llm-docs/components/ToolsHeader.md +46 -0
- package/dist/llm-docs/components/Video.md +254 -0
- package/dist/llm-docs/components/Visible.md +54 -0
- package/dist/llm-docs/components/cssVariables.md +40 -0
- package/dist/llm-docs/components/index.md +59 -0
- package/dist/llm-docs/components/resizeObserver.md +21 -0
- package/dist/llm-docs/guides/archieml.md +406 -0
- package/dist/llm-docs/guides/colours.md +443 -0
- package/dist/llm-docs/guides/customising-with-scss.md +61 -0
- package/dist/llm-docs/guides/graphics-kit.md +25 -0
- package/dist/llm-docs/guides/index.md +16 -0
- package/dist/llm-docs/guides/intro.md +21 -0
- package/dist/llm-docs/guides/layout.md +13 -0
- package/dist/llm-docs/guides/llm-docs.md +71 -0
- package/dist/llm-docs/guides/styles.md +16 -0
- package/dist/llm-docs/guides/theming.md +100 -0
- package/dist/llm-docs/guides/tokens.md +150 -0
- package/dist/llm-docs/index.md +36 -0
- package/package.json +18 -24
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
# TileMap
|
|
2
|
+
|
|
3
|
+
**Category:** Components/Graphics/TileMap
|
|
4
|
+
|
|
5
|
+
**Import:** `import { TileMap } from '@reuters-graphics/graphics-components'`
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Required | Description |
|
|
10
|
+
|------|------|---------|:--------:|-------------|
|
|
11
|
+
| `title` | `string \| Snippet` | — | | Title of the map as a string or a custom snippet. |
|
|
12
|
+
| `description` | `string` | — | | Description of the map, passed in as a markdown string. |
|
|
13
|
+
| `notes` | `string \| Snippet` | — | | Notes to the map, passed in as a markdown string or a custom snippet. |
|
|
14
|
+
| `id` | `string` | ``map-${Math.random().toString(36).substring(2, 9)}`` | | Map container id |
|
|
15
|
+
| `center` | `[number, number]` | `[0, 0]` | | Map center coordinates [longitude, latitude] |
|
|
16
|
+
| `zoom` | `number` | `2` | | Initial zoom level |
|
|
17
|
+
| `minZoom` | `number` | `0` | | Minimum zoom level |
|
|
18
|
+
| `maxZoom` | `number` | `22` | | Maximum zoom level |
|
|
19
|
+
| `projection` | `ProjectionSpecification` | — | | Map projection. Use 'globe' for 3D globe view. See https://maplibre.org/maplibre-style-spec/types/#projectiondefinition |
|
|
20
|
+
| `interactive` | `boolean` | `true` | | Enable interactive controls (zoom, pan, etc.) |
|
|
21
|
+
| `styleUrl` | `string` | `'https://graphics.thomsonreuters.com/reuters-protomaps/style.json'` | | Map style URL |
|
|
22
|
+
| `emphasizeLabels` | `boolean` | `false` | | Darken the basemap's place labels and give them a strong white halo, so city/region names stay readable over colored data layers. Applied once on map load; a no-op on styles without `place` labels (e.g. non-default `styleUrl`s), so it degrades gracefully. |
|
|
23
|
+
| `height` | `string` | `'500px'` | | Map height (default: '500px') |
|
|
24
|
+
| `width` | `ContainerWidth` | `'normal'` | | Width of the map within the text well. Options: `normal`, `wide`, `wider`, `widest`, `fluid` |
|
|
25
|
+
| `textWidth` | `ContainerWidth` | `'normal'` | | Set a different width for the text within the text well, for example, "normal" to keep the title, description and notes inline with the rest of the text well. Can't ever be wider than `width`. |
|
|
26
|
+
| `onMapReady` | `(map: maplibregl.Map) => void` | — | | Callback function that receives the map instance when ready |
|
|
27
|
+
| `legend` | `Snippet` | — | | Optional content rendered inside the map's `GraphicBlock`, directly above the map. Use it to share a single block — with one title and the standard spacing — between the map and an accompanying element such as a `Legend`. |
|
|
28
|
+
| `children` | `Snippet` | — | | Child components (e.g., TileMapLayer) |
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
### Demo
|
|
33
|
+
|
|
34
|
+
```svelte
|
|
35
|
+
<TileMap id="demo-map" center={[-98, 39]} zoom={3} interactive={true} height="500px" />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Globe view
|
|
39
|
+
|
|
40
|
+
```svelte
|
|
41
|
+
<TileMap
|
|
42
|
+
id="globe-map"
|
|
43
|
+
center={[0, 0]}
|
|
44
|
+
zoom={2}
|
|
45
|
+
projection={{ type: 'globe' }}
|
|
46
|
+
interactive={true}
|
|
47
|
+
title="Globe View"
|
|
48
|
+
description="A 3D globe projection of the Earth."
|
|
49
|
+
height="600px"
|
|
50
|
+
/>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Non-interactive
|
|
54
|
+
|
|
55
|
+
```svelte
|
|
56
|
+
<TileMap
|
|
57
|
+
id="static-map"
|
|
58
|
+
center={[2.3522, 48.8566]}
|
|
59
|
+
zoom={12}
|
|
60
|
+
interactive={false}
|
|
61
|
+
title="Paris"
|
|
62
|
+
description="A static map of Paris, France."
|
|
63
|
+
height="400px"
|
|
64
|
+
/>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### With GeoJSON layers
|
|
68
|
+
|
|
69
|
+
```svelte
|
|
70
|
+
<TileMap
|
|
71
|
+
id="geojson-map"
|
|
72
|
+
center={[-73.9712, 40.7831]}
|
|
73
|
+
zoom={11}
|
|
74
|
+
interactive={true}
|
|
75
|
+
title="Map with GeoJSON Layers"
|
|
76
|
+
description="Example showing multiple GeoJSON layers including local data and data fetched from a URL."
|
|
77
|
+
notes="Demonstrates polygon fills, line overlays, point markers, and text labels."
|
|
78
|
+
height="600px"
|
|
79
|
+
>
|
|
80
|
+
<TileMapLayer
|
|
81
|
+
id="park-area"
|
|
82
|
+
data={centralParkData}
|
|
83
|
+
type="fill"
|
|
84
|
+
paint={{
|
|
85
|
+
'fill-color': '#179639',
|
|
86
|
+
'fill-opacity': 0.7,
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
<TileMapLayer
|
|
90
|
+
id="park-outline"
|
|
91
|
+
data={centralParkData}
|
|
92
|
+
type="line"
|
|
93
|
+
paint={{
|
|
94
|
+
'line-color': '#228b22',
|
|
95
|
+
'line-width': 2,
|
|
96
|
+
}}
|
|
97
|
+
/>
|
|
98
|
+
<TileMapLayer
|
|
99
|
+
id="route-line"
|
|
100
|
+
data="https://raw.githubusercontent.com/datanews/ny-marathon/refs/heads/master/route.geojson"
|
|
101
|
+
type="line"
|
|
102
|
+
paint={{
|
|
103
|
+
'line-color': '#4287f5',
|
|
104
|
+
'line-width': 2,
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
107
|
+
<TileMapLayer
|
|
108
|
+
id="reuters-office-point"
|
|
109
|
+
data={reutersOfficePoint}
|
|
110
|
+
type="circle"
|
|
111
|
+
paint={{
|
|
112
|
+
'circle-radius': 4,
|
|
113
|
+
'circle-color': '#ff0000',
|
|
114
|
+
'circle-stroke-width': 2,
|
|
115
|
+
'circle-stroke-color': '#ffffff',
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
<TileMapLayer
|
|
119
|
+
id="reuters-office-label"
|
|
120
|
+
data={reutersOfficePoint}
|
|
121
|
+
type="symbol"
|
|
122
|
+
layout={{
|
|
123
|
+
'text-field': 'Reuters Office',
|
|
124
|
+
'text-offset': [0.25, 0.5],
|
|
125
|
+
'text-anchor': 'top-left',
|
|
126
|
+
'text-size': 12,
|
|
127
|
+
}}
|
|
128
|
+
paint={{
|
|
129
|
+
'text-color': '#000000',
|
|
130
|
+
'text-halo-color': '#ffffff',
|
|
131
|
+
'text-halo-width': 2,
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
<TileMapLayer
|
|
135
|
+
id="points-layer"
|
|
136
|
+
data={points}
|
|
137
|
+
type="circle"
|
|
138
|
+
paint={{
|
|
139
|
+
'circle-radius': 4,
|
|
140
|
+
'circle-color': '#9c27b0',
|
|
141
|
+
'circle-stroke-width': 2,
|
|
142
|
+
'circle-stroke-color': '#ffffff',
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
</TileMap>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Labels above data
|
|
149
|
+
|
|
150
|
+
```svelte
|
|
151
|
+
<TileMap
|
|
152
|
+
id="labels-map"
|
|
153
|
+
center={[-93.5, 42]}
|
|
154
|
+
zoom={6}
|
|
155
|
+
interactive={true}
|
|
156
|
+
emphasizeLabels
|
|
157
|
+
title="Keeping labels readable over data"
|
|
158
|
+
description="`emphasizeLabels` (on the map) darkens the basemap's place labels and adds a white halo; `beneathLabels` (on the fill layer) inserts the data below the labels, so city names across Iowa stay on top of the colored overlay."
|
|
159
|
+
height="500px"
|
|
160
|
+
>
|
|
161
|
+
<TileMapLayer
|
|
162
|
+
id="iowa-fill"
|
|
163
|
+
data={iowaData}
|
|
164
|
+
type="fill"
|
|
165
|
+
beneathLabels
|
|
166
|
+
paint={{
|
|
167
|
+
'fill-color': '#d64000',
|
|
168
|
+
'fill-opacity': 0.75,
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
171
|
+
</TileMap>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### With Geocoder
|
|
175
|
+
|
|
176
|
+
```svelte
|
|
177
|
+
<TileMap
|
|
178
|
+
id="geocoder-map"
|
|
179
|
+
center={[-98, 39]}
|
|
180
|
+
zoom={3}
|
|
181
|
+
interactive={true}
|
|
182
|
+
title="Map with Geocoder"
|
|
183
|
+
description="Search for a location to fly the map there."
|
|
184
|
+
height="500px"
|
|
185
|
+
onMapReady={(map) => {
|
|
186
|
+
geocoderMapRef = map;
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
189
|
+
<div
|
|
190
|
+
style="position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000; width: min(500px, calc(100% - 20px));"
|
|
191
|
+
>
|
|
192
|
+
<Geocoder
|
|
193
|
+
accessToken={mapboxAccessToken}
|
|
194
|
+
onselect={(loc) => {
|
|
195
|
+
geocoderMapRef?.flyTo({ center: [loc.lng, loc.lat], zoom: 10 });
|
|
196
|
+
}}
|
|
197
|
+
/>
|
|
198
|
+
</div>
|
|
199
|
+
</TileMap>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Documentation
|
|
203
|
+
|
|
204
|
+
# TileMap
|
|
205
|
+
|
|
206
|
+
Easily add an interactive map to your page using MapLibre GL and PMTiles.
|
|
207
|
+
|
|
208
|
+
```svelte
|
|
209
|
+
<script>
|
|
210
|
+
import { TileMap } from '@reuters-graphics/graphics-components';
|
|
211
|
+
</script>
|
|
212
|
+
|
|
213
|
+
<TileMap
|
|
214
|
+
id="my-map"
|
|
215
|
+
center={[-74.006, 40.7128]}
|
|
216
|
+
zoom={10}
|
|
217
|
+
interactive={true}
|
|
218
|
+
height="500px"
|
|
219
|
+
/>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The TileMap component uses [MapLibre GL JS](https://maplibre.org/) and [PMTiles](https://protomaps.com/docs/pmtiles) for efficient, interactive mapping. It automatically configures the PMTiles protocol and uses the Reuters Protomaps style by default.
|
|
223
|
+
|
|
224
|
+
## Globe view
|
|
225
|
+
|
|
226
|
+
Use the `projection` prop to display a 3D globe. The projection accepts a [ProjectionSpecification](https://maplibre.org/maplibre-style-spec/types/#projectiondefinition) object:
|
|
227
|
+
|
|
228
|
+
```svelte
|
|
229
|
+
<TileMap
|
|
230
|
+
id="globe-map"
|
|
231
|
+
center={[0, 0]}
|
|
232
|
+
zoom={1}
|
|
233
|
+
projection={{ type: 'globe' }}
|
|
234
|
+
interactive={true}
|
|
235
|
+
height="600px"
|
|
236
|
+
/>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Non-interactive mode
|
|
240
|
+
|
|
241
|
+
Disable interaction for static maps:
|
|
242
|
+
|
|
243
|
+
## Adding GeoJSON layers
|
|
244
|
+
|
|
245
|
+
Use the `TileMapLayer` component to add GeoJSON data to your map. You can pass GeoJSON data directly or fetch it from a URL. Layer rendering order will directly correspond to the order in which you add the layers in the code.
|
|
246
|
+
|
|
247
|
+
> **Note for TypeScript users:** When passing GeoJSON data objects, you'll need to type cast them using `as GeoJSON` to ensure TypeScript recognizes the correct type. This provides better type safety and error messages. See examples below.
|
|
248
|
+
|
|
249
|
+
### Basic example with local data
|
|
250
|
+
|
|
251
|
+
```svelte
|
|
252
|
+
<script lang="ts">
|
|
253
|
+
import { TileMap, TileMapLayer } from '@reuters-graphics/graphics-components';
|
|
254
|
+
import type { GeoJSON } from 'geojson';
|
|
255
|
+
|
|
256
|
+
const parkData = {
|
|
257
|
+
type: 'FeatureCollection',
|
|
258
|
+
features: [
|
|
259
|
+
{
|
|
260
|
+
type: 'Feature',
|
|
261
|
+
geometry: {
|
|
262
|
+
type: 'Polygon',
|
|
263
|
+
coordinates: [
|
|
264
|
+
[
|
|
265
|
+
[-73.9577, 40.8005],
|
|
266
|
+
[-73.9816, 40.7684],
|
|
267
|
+
[-73.973, 40.7649],
|
|
268
|
+
[-73.9492, 40.7969],
|
|
269
|
+
[-73.9577, 40.8005],
|
|
270
|
+
],
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
properties: { name: 'Central Park' },
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
};
|
|
277
|
+
</script>
|
|
278
|
+
|
|
279
|
+
<TileMap center={[-73.9712, 40.7831]} zoom={13}>
|
|
280
|
+
<!-- Polygon fill -->
|
|
281
|
+
<TileMapLayer
|
|
282
|
+
id="park-fill"
|
|
283
|
+
data={parkData as GeoJSON}
|
|
284
|
+
type="fill"
|
|
285
|
+
paint={{
|
|
286
|
+
'fill-color': '#179639',
|
|
287
|
+
'fill-opacity': 0.7,
|
|
288
|
+
}}
|
|
289
|
+
/>
|
|
290
|
+
|
|
291
|
+
<!-- Polygon outline -->
|
|
292
|
+
<TileMapLayer
|
|
293
|
+
id="park-outline"
|
|
294
|
+
data={parkData as GeoJSON}
|
|
295
|
+
type="line"
|
|
296
|
+
paint={{
|
|
297
|
+
'line-color': '#228b22',
|
|
298
|
+
'line-width': 2,
|
|
299
|
+
}}
|
|
300
|
+
/>
|
|
301
|
+
</TileMap>
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Fetching GeoJSON from a URL
|
|
305
|
+
|
|
306
|
+
You can also pass a URL string to fetch GeoJSON data:
|
|
307
|
+
|
|
308
|
+
```svelte
|
|
309
|
+
<TileMap center={[-73.9712, 40.7831]} zoom={11}>
|
|
310
|
+
<TileMapLayer
|
|
311
|
+
id="marathon-route"
|
|
312
|
+
data="https://example.com/path/to/route.geojson"
|
|
313
|
+
type="line"
|
|
314
|
+
paint={{
|
|
315
|
+
'line-color': '#4287f5',
|
|
316
|
+
'line-width': 2,
|
|
317
|
+
}}
|
|
318
|
+
/>
|
|
319
|
+
</TileMap>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Adding point markers
|
|
323
|
+
|
|
324
|
+
```svelte
|
|
325
|
+
<script lang="ts">
|
|
326
|
+
import type { GeoJSON } from 'geojson';
|
|
327
|
+
|
|
328
|
+
const officeLocation = {
|
|
329
|
+
type: 'FeatureCollection',
|
|
330
|
+
features: [
|
|
331
|
+
{
|
|
332
|
+
type: 'Feature',
|
|
333
|
+
geometry: {
|
|
334
|
+
type: 'Point',
|
|
335
|
+
coordinates: [-73.9868, 40.7567],
|
|
336
|
+
},
|
|
337
|
+
properties: { name: 'Office' },
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
};
|
|
341
|
+
</script>
|
|
342
|
+
|
|
343
|
+
<TileMap center={[-73.9868, 40.7567]} zoom={14}>
|
|
344
|
+
<!-- Point marker -->
|
|
345
|
+
<TileMapLayer
|
|
346
|
+
id="office-point"
|
|
347
|
+
data={officeLocation as GeoJSON}
|
|
348
|
+
type="circle"
|
|
349
|
+
paint={{
|
|
350
|
+
'circle-radius': 6,
|
|
351
|
+
'circle-color': '#ff0000',
|
|
352
|
+
'circle-stroke-width': 2,
|
|
353
|
+
'circle-stroke-color': '#ffffff',
|
|
354
|
+
}}
|
|
355
|
+
/>
|
|
356
|
+
|
|
357
|
+
<!-- Text label -->
|
|
358
|
+
<TileMapLayer
|
|
359
|
+
id="office-label"
|
|
360
|
+
data={officeLocation as GeoJSON}
|
|
361
|
+
type="symbol"
|
|
362
|
+
layout={{
|
|
363
|
+
'text-field': 'Office',
|
|
364
|
+
'text-offset': [0, 1],
|
|
365
|
+
'text-anchor': 'top',
|
|
366
|
+
'text-size': 12,
|
|
367
|
+
}}
|
|
368
|
+
paint={{
|
|
369
|
+
'text-color': '#000000',
|
|
370
|
+
'text-halo-color': '#ffffff',
|
|
371
|
+
'text-halo-width': 2,
|
|
372
|
+
}}
|
|
373
|
+
/>
|
|
374
|
+
</TileMap>
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### TileMapLayer Props
|
|
378
|
+
|
|
379
|
+
- **id**: `string` (required) - Unique identifier for the layer
|
|
380
|
+
- **data**: `object | string` (required) - GeoJSON data or URL to fetch from
|
|
381
|
+
- **type**: `'fill' | 'line' | 'circle' | 'symbol' | 'fill-extrusion' | 'raster' | 'background' | 'heatmap' | 'hillshade'` - Layer type (default: `'fill'`)
|
|
382
|
+
- **paint**: `Record<string, unknown>` - Paint properties for the layer
|
|
383
|
+
- **layout**: `Record<string, unknown>` - Layout properties for the layer
|
|
384
|
+
- **beforeId**: `string` - Layer ID to insert before (for ordering)
|
|
385
|
+
- **beneathLabels**: `boolean` - Insert the layer beneath the basemap's labels so place names stay readable on top of it (default: `false`). Ignored when `beforeId` is set. A no-op on styles with no symbol layers.
|
|
386
|
+
- **minZoom**: `number` - Minimum zoom level to display layer
|
|
387
|
+
- **maxZoom**: `number` - Maximum zoom level to display layer
|
|
388
|
+
- **filter**: `unknown[]` - Filter expression for the layer
|
|
389
|
+
|
|
390
|
+
### Multiple layers example
|
|
391
|
+
|
|
392
|
+
You can combine multiple layers to create rich visualizations:
|
|
393
|
+
|
|
394
|
+
```svelte
|
|
395
|
+
<TileMap center={[-73.9712, 40.7831]} zoom={11}>
|
|
396
|
+
<!-- Background polygon -->
|
|
397
|
+
<TileMapLayer
|
|
398
|
+
id="area-fill"
|
|
399
|
+
data={areaData}
|
|
400
|
+
type="fill"
|
|
401
|
+
paint={{ 'fill-color': '#179639', 'fill-opacity': 0.7 }}
|
|
402
|
+
/>
|
|
403
|
+
|
|
404
|
+
<!-- Border line -->
|
|
405
|
+
<TileMapLayer
|
|
406
|
+
id="area-border"
|
|
407
|
+
data={areaData}
|
|
408
|
+
type="line"
|
|
409
|
+
paint={{ 'line-color': '#228b22', 'line-width': 2 }}
|
|
410
|
+
/>
|
|
411
|
+
|
|
412
|
+
<!-- Route from URL -->
|
|
413
|
+
<TileMapLayer
|
|
414
|
+
id="route"
|
|
415
|
+
data="https://example.com/route.geojson"
|
|
416
|
+
type="line"
|
|
417
|
+
paint={{ 'line-color': '#4287f5', 'line-width': 2 }}
|
|
418
|
+
/>
|
|
419
|
+
|
|
420
|
+
<!-- Point markers -->
|
|
421
|
+
<TileMapLayer
|
|
422
|
+
id="markers"
|
|
423
|
+
data={pointsData}
|
|
424
|
+
type="circle"
|
|
425
|
+
paint={{
|
|
426
|
+
'circle-radius': 4,
|
|
427
|
+
'circle-color': '#9c27b0',
|
|
428
|
+
'circle-stroke-width': 2,
|
|
429
|
+
'circle-stroke-color': '#ffffff',
|
|
430
|
+
}}
|
|
431
|
+
/>
|
|
432
|
+
</TileMap>
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## Advanced usage
|
|
436
|
+
|
|
437
|
+
For more control over the map, you can use the `onMapReady` callback to access the MapLibre GL instance:
|
|
438
|
+
|
|
439
|
+
```svelte
|
|
440
|
+
<script>
|
|
441
|
+
import { TileMap } from '@reuters-graphics/graphics-components';
|
|
442
|
+
import type { Map as MaplibreMap } from 'maplibre-gl';
|
|
443
|
+
|
|
444
|
+
function handleMapReady(map: MaplibreMap) {
|
|
445
|
+
// Add custom layers, sources, or event handlers
|
|
446
|
+
map.addSource('my-source', {
|
|
447
|
+
type: 'geojson',
|
|
448
|
+
data: myGeoJsonData,
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
map.addLayer({
|
|
452
|
+
id: 'my-layer',
|
|
453
|
+
type: 'circle',
|
|
454
|
+
source: 'my-source',
|
|
455
|
+
paint: {
|
|
456
|
+
'circle-radius': 8,
|
|
457
|
+
'circle-color': '#007cbf',
|
|
458
|
+
},
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
</script>
|
|
462
|
+
|
|
463
|
+
<Map id="custom-map" center={[0, 0]} zoom={2} onMapReady={handleMapReady} />
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
## Props
|
|
467
|
+
|
|
468
|
+
- **center**: `[longitude, latitude]` - Map center coordinates (default: `[0, 0]`)
|
|
469
|
+
- **zoom**: `number` - Initial zoom level (default: `2`)
|
|
470
|
+
- **minZoom**: `number` - Minimum zoom level (default: `0`)
|
|
471
|
+
- **maxZoom**: `number` - Maximum zoom level (default: `22`)
|
|
472
|
+
- **interactive**: `boolean` - Enable interactive controls (default: `true`)
|
|
473
|
+
- **styleUrl**: `string` - Map style URL (default: Reuters Protomaps style)
|
|
474
|
+
- **emphasizeLabels**: `boolean` - Darken the basemap's place labels and add a white halo so city/region names stay readable over colored data layers (default: `false`). Applied on map load; a no-op on styles without `place` labels.
|
|
475
|
+
- **height**: `string` - Map height in CSS units (default: `'500px'`)
|
|
476
|
+
- **width**: `ContainerWidth` - Width within the text well (default: `'normal'`)
|
|
477
|
+
- **onMapReady**: `(map: maplibregl.Map) => void` - Callback when map is ready
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# ToolsHeader
|
|
2
|
+
|
|
3
|
+
**Category:** Components/Page furniture/ToolsHeader
|
|
4
|
+
|
|
5
|
+
**Import:** `import { ToolsHeader } from '@reuters-graphics/graphics-components'`
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Required | Description |
|
|
10
|
+
|------|------|---------|:--------:|-------------|
|
|
11
|
+
| `children` | `Snippet` | — | | Snippet content |
|
|
12
|
+
| `id` | `string` | `''` | | ID of the header container |
|
|
13
|
+
| `class` | `string` | `''` | | Add a class to target with SCSS. |
|
|
14
|
+
| `sticky` | `boolean` | `false` | | Make the header stick when user scrolls. |
|
|
15
|
+
| `background` | `string` | `'transparent'` | | Background CSS |
|
|
16
|
+
| `borderBottom` | `string` | `'1px solid #dedede'` | | Border bottom CSS |
|
|
17
|
+
| `logoProps` | `{ logoColour?: string; textColor?: string; }` | `{ logoColour: '#404040' }` | | Colour props passed to `ReutersGraphicsLogo` component. |
|
|
18
|
+
| `homeLink` | `string` | `'/'` | | Link the logo points to. |
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### Demo
|
|
23
|
+
|
|
24
|
+
```svelte
|
|
25
|
+
<div>
|
|
26
|
+
<ToolsHeader />
|
|
27
|
+
</div>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
# ToolsHeader
|
|
33
|
+
|
|
34
|
+
The `ToolsHeader` component adds a header with the Reuters Graphics logo for internal tooling sites.
|
|
35
|
+
|
|
36
|
+
> **Note:** Don't use this component for public pages.
|
|
37
|
+
|
|
38
|
+
```svelte
|
|
39
|
+
<script>
|
|
40
|
+
import { ToolsHeader } from '@reuters-graphics/graphics-components';
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<ToolsHeader>
|
|
44
|
+
<!-- Anything else goes to the right of the logo -->
|
|
45
|
+
</ToolsHeader>
|
|
46
|
+
```
|