@fusion.dev/helix-map 0.0.0-dev
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/LICENSE +21 -0
- package/README.md +66 -0
- package/dist/connect-map/connect-map.d.ts +317 -0
- package/dist/connect-map/connect-map.d.ts.map +1 -0
- package/dist/connect-map/connect-map.js +847 -0
- package/dist/connect-map/connect-map.js.map +1 -0
- package/dist/connect-map/index.d.ts +3 -0
- package/dist/connect-map/index.d.ts.map +1 -0
- package/dist/connect-map/index.js +2 -0
- package/dist/connect-map/index.js.map +1 -0
- package/dist/contours/contours.d.ts +71 -0
- package/dist/contours/contours.d.ts.map +1 -0
- package/dist/contours/contours.js +314 -0
- package/dist/contours/contours.js.map +1 -0
- package/dist/credit/credit.d.ts +20 -0
- package/dist/credit/credit.d.ts.map +1 -0
- package/dist/credit/credit.js +65 -0
- package/dist/credit/credit.js.map +1 -0
- package/dist/credit/index.d.ts +3 -0
- package/dist/credit/index.d.ts.map +1 -0
- package/dist/credit/index.js +2 -0
- package/dist/credit/index.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/leaflet/index.d.ts +3 -0
- package/dist/leaflet/index.d.ts.map +1 -0
- package/dist/leaflet/index.js +2 -0
- package/dist/leaflet/index.js.map +1 -0
- package/dist/leaflet/leaflet-driver.d.ts +126 -0
- package/dist/leaflet/leaflet-driver.d.ts.map +1 -0
- package/dist/leaflet/leaflet-driver.js +241 -0
- package/dist/leaflet/leaflet-driver.js.map +1 -0
- package/dist/maplibre/index.d.ts +5 -0
- package/dist/maplibre/index.d.ts.map +1 -0
- package/dist/maplibre/index.js +3 -0
- package/dist/maplibre/index.js.map +1 -0
- package/dist/maplibre/map-images.d.ts +17 -0
- package/dist/maplibre/map-images.d.ts.map +1 -0
- package/dist/maplibre/map-images.js +138 -0
- package/dist/maplibre/map-images.js.map +1 -0
- package/dist/maplibre/maplibre-driver.d.ts +276 -0
- package/dist/maplibre/maplibre-driver.d.ts.map +1 -0
- package/dist/maplibre/maplibre-driver.js +1114 -0
- package/dist/maplibre/maplibre-driver.js.map +1 -0
- package/dist/motion/index.d.ts +3 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +2 -0
- package/dist/motion/index.js.map +1 -0
- package/dist/motion/motion.d.ts +41 -0
- package/dist/motion/motion.d.ts.map +1 -0
- package/dist/motion/motion.js +167 -0
- package/dist/motion/motion.js.map +1 -0
- package/dist/points/index.d.ts +3 -0
- package/dist/points/index.d.ts.map +1 -0
- package/dist/points/index.js +2 -0
- package/dist/points/index.js.map +1 -0
- package/dist/points/points.d.ts +20 -0
- package/dist/points/points.d.ts.map +1 -0
- package/dist/points/points.js +41 -0
- package/dist/points/points.js.map +1 -0
- package/dist/snapshot/camera.d.ts +44 -0
- package/dist/snapshot/camera.d.ts.map +1 -0
- package/dist/snapshot/camera.js +42 -0
- package/dist/snapshot/camera.js.map +1 -0
- package/dist/snapshot/index.d.ts +5 -0
- package/dist/snapshot/index.d.ts.map +1 -0
- package/dist/snapshot/index.js +3 -0
- package/dist/snapshot/index.js.map +1 -0
- package/dist/snapshot/snapshot.d.ts +75 -0
- package/dist/snapshot/snapshot.d.ts.map +1 -0
- package/dist/snapshot/snapshot.js +290 -0
- package/dist/snapshot/snapshot.js.map +1 -0
- package/dist/style/index.d.ts +5 -0
- package/dist/style/index.d.ts.map +1 -0
- package/dist/style/index.js +3 -0
- package/dist/style/index.js.map +1 -0
- package/dist/style/map-colors.d.ts +69 -0
- package/dist/style/map-colors.d.ts.map +1 -0
- package/dist/style/map-colors.js +82 -0
- package/dist/style/map-colors.js.map +1 -0
- package/dist/style/map-style.d.ts +99 -0
- package/dist/style/map-style.d.ts.map +1 -0
- package/dist/style/map-style.js +440 -0
- package/dist/style/map-style.js.map +1 -0
- package/dist/style/oklab.d.ts +36 -0
- package/dist/style/oklab.d.ts.map +1 -0
- package/dist/style/oklab.js +76 -0
- package/dist/style/oklab.js.map +1 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/watch-theme.d.ts +14 -0
- package/dist/theme/watch-theme.d.ts.map +1 -0
- package/dist/theme/watch-theme.js +30 -0
- package/dist/theme/watch-theme.js.map +1 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fusion Development Group
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @fusion.dev/helix-map
|
|
2
|
+
|
|
3
|
+
Connects the Helix `Map` frame to whatever draws the map: MapLibre, Leaflet, or
|
|
4
|
+
a driver of your own, with a style made from your tokens.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
bun add @fusion.dev/helix @fusion.dev/helix-map maplibre-gl
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
**The guide is [Maps](https://fusion.dev/helix/docs/maps)**: connecting a
|
|
11
|
+
renderer, the style, markers, clusters, routes, a live position, points, layers
|
|
12
|
+
such as 3D buildings, terrain, and weather radar, a snapshot drawn on the server
|
|
13
|
+
for the first paint, the keyboard, and writing a driver. The elements themselves are on the
|
|
14
|
+
[Map reference](https://fusion.dev/helix/components/map).
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { colorsReady, connectMap } from '@fusion.dev/helix-map'
|
|
18
|
+
import { followTheme, mapLibreDriver, mapLibreStyle } from '@fusion.dev/helix-map/maplibre'
|
|
19
|
+
|
|
20
|
+
const frame = document.querySelector('helix-map')
|
|
21
|
+
const style = (colors) => mapLibreStyle(colors)
|
|
22
|
+
const map = new maplibregl.Map({
|
|
23
|
+
attributionControl: false,
|
|
24
|
+
container: 'map',
|
|
25
|
+
style: style(await colorsReady(frame)),
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const connection = connectMap(frame, mapLibreDriver(map))
|
|
29
|
+
followTheme(map, frame, style)
|
|
30
|
+
|
|
31
|
+
// Later, when the map goes away:
|
|
32
|
+
connection.disconnect()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## What it exports
|
|
36
|
+
|
|
37
|
+
| Import | What |
|
|
38
|
+
|---|---|
|
|
39
|
+
| `@fusion.dev/helix-map` | `connectMap`, `colorsReady`, `mapColorsFrom`, `watchTheme`, `motionOf`, `distancesAlong`, `pointsFrom`, and the `MapDriver` type |
|
|
40
|
+
| `@fusion.dev/helix-map/maplibre` | `mapLibreDriver(map)`, `mapLibreStyle(colors, options)`, `followTheme(map, element, style)` |
|
|
41
|
+
| `@fusion.dev/helix-map/leaflet` | `leafletDriver(map, L)` |
|
|
42
|
+
|
|
43
|
+
**Neither renderer is a dependency.** A driver types the map it takes by the
|
|
44
|
+
calls it makes on it, so a page brings whichever version it has. A spec holds
|
|
45
|
+
those shapes to the real `Map` classes, so a renamed method fails a typecheck
|
|
46
|
+
here rather than a page.
|
|
47
|
+
|
|
48
|
+
| `connectMap` option | Default | What else it takes |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `credit` | `true` | `false` leaves the attribution slot to the page |
|
|
51
|
+
| `keyboard` | `'frame'` | `'renderer'` keeps the renderer's keys and tab stop, for a 3D view that wants its rotate and pitch |
|
|
52
|
+
| `clusterDistance` | `40` | How close, in pixels, two markers' points come before a frame with `cluster` gathers them |
|
|
53
|
+
| `clusterZoom` | `true` | `false` leaves a pressed cluster to the page's own `helix-map-cluster` listener |
|
|
54
|
+
|
|
55
|
+
## Working on it
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
bun run --filter @fusion.dev/helix-map build
|
|
59
|
+
bun run --filter @fusion.dev/helix-map test
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The specs drive stand-ins for each renderer. What they cannot show, that the
|
|
63
|
+
real libraries move the way the stand-ins are told, was checked against
|
|
64
|
+
MapLibre 5.24 and Leaflet 1.9.4 in Chromium on September 25, 2026.
|
|
65
|
+
|
|
66
|
+
MIT
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { type MapMotion } from '../motion/motion.js';
|
|
2
|
+
/** How the map draws the ground: the themed map, imagery under its roads and names, or imagery alone. */
|
|
3
|
+
export type MapType = 'hybrid' | 'satellite' | 'standard';
|
|
4
|
+
/**
|
|
5
|
+
* What a renderer has to answer for the frame to drive it, and nothing that is
|
|
6
|
+
* the same for every renderer: that is the connector's.
|
|
7
|
+
*
|
|
8
|
+
* **Physical pixels and a direction in, whatever the renderer calls them out.**
|
|
9
|
+
* The frame asks in reading order and in fractions of the viewport, and the
|
|
10
|
+
* connector turns that into pixels on screen before a driver sees it, so the
|
|
11
|
+
* one thing every driver would otherwise get wrong on its own, which way
|
|
12
|
+
* `start` is on a right-to-left page, is answered once.
|
|
13
|
+
*/
|
|
14
|
+
export interface MapDriver {
|
|
15
|
+
/**
|
|
16
|
+
* Which way the view is turned, in degrees clockwise from north, where the
|
|
17
|
+
* renderer can turn it. A position's heading is drawn against it, so an
|
|
18
|
+
* arrow pointing north still points north on a map turned east.
|
|
19
|
+
*/
|
|
20
|
+
bearing?(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether a place is on the far side of a globe, out of sight. A marker
|
|
23
|
+
* there is hidden, and stays in the frame's walk.
|
|
24
|
+
*/
|
|
25
|
+
behind?(place: MapPlace): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The renderer's credits as it writes them, which is markup, and a way to
|
|
28
|
+
* hear them change. `stop` ends the listening and puts back anything the
|
|
29
|
+
* driver hid to take the credit over, such as the renderer's own control.
|
|
30
|
+
*/
|
|
31
|
+
credits?(changed: () => void): {
|
|
32
|
+
read(): string[];
|
|
33
|
+
stop(): void;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Calls `done` once the renderer has drawn its view with its tiles, and
|
|
37
|
+
* returns what stops the waiting. What takes a snapshot drawn on the server
|
|
38
|
+
* away; without it, the snapshot stays under the renderer's drawing.
|
|
39
|
+
*/
|
|
40
|
+
ready?(done: () => void): () => void;
|
|
41
|
+
/**
|
|
42
|
+
* The element the renderer made focusable, which the connector takes out of
|
|
43
|
+
* the tab order while connected so the frame's region is the one stop.
|
|
44
|
+
*/
|
|
45
|
+
focusTarget?(): HTMLElement | null;
|
|
46
|
+
/**
|
|
47
|
+
* Frames a stretch of the world, its two corners in degrees, inset by
|
|
48
|
+
* `padding` pixels from the view's edges, over the page's motion or at once.
|
|
49
|
+
* What `connection.fit()` asks, to show every place the frame holds.
|
|
50
|
+
*/
|
|
51
|
+
fit?(bounds: MapBounds, padding: MapPadding, motion: MapMotion | null): void;
|
|
52
|
+
/**
|
|
53
|
+
* Shows or hides the renderer's own roads and names, which the Satellite
|
|
54
|
+
* map type hides so the imagery stands alone.
|
|
55
|
+
*/
|
|
56
|
+
labels?(shown: boolean): void;
|
|
57
|
+
/**
|
|
58
|
+
* Draws the frame's routes and areas as the renderer's own layers, under its
|
|
59
|
+
* place names where it has them. `read` is the whole set as it stands, its
|
|
60
|
+
* colors settled, and a driver asks it every time it draws, including after
|
|
61
|
+
* the renderer's style was replaced and took them with it. The connector
|
|
62
|
+
* calls `update` when one is added, taken away or changed; `stop` takes
|
|
63
|
+
* them off.
|
|
64
|
+
*/
|
|
65
|
+
layers?(read: () => MapLayerSpec[], events?: MapLayerEvents): {
|
|
66
|
+
/** Zooms in to where a points layer's count comes apart, at the page's pace. */
|
|
67
|
+
expand?(id: string, cluster: number): void;
|
|
68
|
+
/** A points layer's points and counts drawn in view, which the keyboard walks. */
|
|
69
|
+
inView?(id: string): MapInView[];
|
|
70
|
+
stop(): void;
|
|
71
|
+
update(): void;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Hears the view move, every frame it moves, and returns what stops it. What
|
|
75
|
+
* lets markers keep up with the map; without it they are placed once.
|
|
76
|
+
*/
|
|
77
|
+
onView?(moved: () => void): () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Moves the view by this many CSS pixels, right and down positive, over the
|
|
80
|
+
* page's own motion, or at once where it is `null`.
|
|
81
|
+
*/
|
|
82
|
+
panBy(x: number, y: number, motion: MapMotion | null): void;
|
|
83
|
+
/**
|
|
84
|
+
* Pictures of the view in each map type, as image URLs, for the cards in
|
|
85
|
+
* the frame's layers menu. `imagery` is the tile URL the Hybrid and
|
|
86
|
+
* Satellite types draw; without it, only Standard can be drawn.
|
|
87
|
+
*/
|
|
88
|
+
previews?(ask: {
|
|
89
|
+
imagery?: {
|
|
90
|
+
maxZoom?: number | undefined;
|
|
91
|
+
src: string;
|
|
92
|
+
} | undefined;
|
|
93
|
+
types: readonly MapType[];
|
|
94
|
+
}): Promise<Partial<Record<MapType, string>>>;
|
|
95
|
+
/**
|
|
96
|
+
* How far the view is tilted, in degrees from looking straight down, where
|
|
97
|
+
* the renderer can tilt it. The frame's 3D button is pressed while it is
|
|
98
|
+
* above `0`.
|
|
99
|
+
*/
|
|
100
|
+
pitch?(): number;
|
|
101
|
+
/**
|
|
102
|
+
* Where a place falls in the map's box, in CSS pixels from its top left.
|
|
103
|
+
* Without it markers cannot be placed, and the connector leaves them hidden.
|
|
104
|
+
*/
|
|
105
|
+
project?(place: MapPlace): {
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Takes off the renderer's own zoom buttons, which the frame's replace, and
|
|
111
|
+
* returns what puts them back. Asked only where the frame draws its own.
|
|
112
|
+
*/
|
|
113
|
+
replaceZoom?(): () => void;
|
|
114
|
+
/**
|
|
115
|
+
* Turns the view by `by` degrees clockwise, or to the bearing `to`, over the
|
|
116
|
+
* page's motion or at once. What the frame's rotate buttons and keys ask.
|
|
117
|
+
*/
|
|
118
|
+
rotate?(turn: {
|
|
119
|
+
by?: number | undefined;
|
|
120
|
+
to?: number | undefined;
|
|
121
|
+
}, motion: MapMotion | null): void;
|
|
122
|
+
/**
|
|
123
|
+
* Turns the renderer's own keyboard handling off, and returns what turns it
|
|
124
|
+
* back to how it was.
|
|
125
|
+
*/
|
|
126
|
+
silenceKeyboard?(): () => void;
|
|
127
|
+
/** Brings a place to the middle of the view, at its zoom where it has one. */
|
|
128
|
+
show?(place: MapPlace & {
|
|
129
|
+
zoom?: number | undefined;
|
|
130
|
+
}, motion: MapMotion | null): void;
|
|
131
|
+
/**
|
|
132
|
+
* Tilts the view `by` degrees toward the horizon, or back toward flat where
|
|
133
|
+
* negative, or `to` a tilt, `0` being flat, within what the renderer allows.
|
|
134
|
+
* What the frame's 3D button and tilt keys ask.
|
|
135
|
+
*/
|
|
136
|
+
tilt?(tilt: {
|
|
137
|
+
by?: number | undefined;
|
|
138
|
+
to?: number | undefined;
|
|
139
|
+
}, motion: MapMotion | null): void;
|
|
140
|
+
/** Zooms one step in, `1`, or out, `-1`, by whatever a step is to this renderer. */
|
|
141
|
+
zoomBy(direction: 1 | -1, motion: MapMotion | null): void;
|
|
142
|
+
}
|
|
143
|
+
/** What a driver drawing layers tells the connector, and asks of it. */
|
|
144
|
+
export interface MapLayerEvents {
|
|
145
|
+
/** The page's motion for a trip, for a cluster of points a press zooms in to. */
|
|
146
|
+
motion(): MapMotion | null;
|
|
147
|
+
/** A reader pressed a point: which points layer, by its spec's `id`, and which of its points. */
|
|
148
|
+
press(id: string, index: number): void;
|
|
149
|
+
/** The renderer has drawn what the view shows and gone still, which is when to ask what is in view. */
|
|
150
|
+
settled?(): void;
|
|
151
|
+
}
|
|
152
|
+
/** A point or a count a renderer drew in view. */
|
|
153
|
+
export interface MapInView {
|
|
154
|
+
/** Which of the layer's points, where it is one. */
|
|
155
|
+
at?: number | undefined;
|
|
156
|
+
/** The renderer's id for a count, where it is one. */
|
|
157
|
+
cluster?: number | undefined;
|
|
158
|
+
/** How many places a count holds. */
|
|
159
|
+
count?: number | undefined;
|
|
160
|
+
place: MapPlace;
|
|
161
|
+
}
|
|
162
|
+
/** A place, in degrees. */
|
|
163
|
+
export interface MapPlace {
|
|
164
|
+
lat: number;
|
|
165
|
+
lng: number;
|
|
166
|
+
}
|
|
167
|
+
/** A stretch of the world by its south-west and north-east corners. */
|
|
168
|
+
export interface MapBounds {
|
|
169
|
+
northEast: MapPlace;
|
|
170
|
+
southWest: MapPlace;
|
|
171
|
+
}
|
|
172
|
+
/** How far in from each edge of the view, in CSS pixels, or one inset for all four. */
|
|
173
|
+
export type MapPadding = number | {
|
|
174
|
+
bottom: number;
|
|
175
|
+
left: number;
|
|
176
|
+
right: number;
|
|
177
|
+
top: number;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* A layer as a driver draws it, whatever renderer it drives: its kind, the
|
|
181
|
+
* places it passes through or around, and its color settled to sRGB.
|
|
182
|
+
*/
|
|
183
|
+
export interface MapLayerSpec {
|
|
184
|
+
/** A raster layer's credit for its tiles, which the frame shows with the map's own. */
|
|
185
|
+
attribution?: string | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* A route's edge, drawn wider under it so it reads as laid over the roads
|
|
188
|
+
* rather than as one of them, where the roads are drawn in the same brand;
|
|
189
|
+
* the ring round each point of a points layer. Absent where there is none
|
|
190
|
+
* to draw.
|
|
191
|
+
*/
|
|
192
|
+
casing?: string | undefined;
|
|
193
|
+
/** How a terrain layer's elevation tiles store heights in their colors. */
|
|
194
|
+
encoding?: 'mapbox' | 'terrarium' | undefined;
|
|
195
|
+
/** How many times its real height a raised terrain layer's ground is raised. */
|
|
196
|
+
exaggeration?: number | undefined;
|
|
197
|
+
/** Whether a points layer's points are gathered into their counts where they would meet. */
|
|
198
|
+
cluster?: boolean | undefined;
|
|
199
|
+
/** `#hex`, `rgb()` or `rgba()`, which every renderer takes. */
|
|
200
|
+
color: string;
|
|
201
|
+
/**
|
|
202
|
+
* Drawn quieter: the part of a route already traveled, which the connector
|
|
203
|
+
* cuts from the rest at the route's `progress`.
|
|
204
|
+
*/
|
|
205
|
+
faded?: boolean | undefined;
|
|
206
|
+
/** Which of a raster layer's `frames` shows, counting from `0`. */
|
|
207
|
+
frame?: number | undefined;
|
|
208
|
+
/** A raster layer's tile URLs, one per frame, each with `{z}`, `{x}`, and `{y}` in it. */
|
|
209
|
+
frames?: readonly string[] | undefined;
|
|
210
|
+
/**
|
|
211
|
+
* A raster layer drawn as the ground, such as imagery: under the roads and
|
|
212
|
+
* place names, where other raster layers are over the roads.
|
|
213
|
+
*/
|
|
214
|
+
ground?: boolean | undefined;
|
|
215
|
+
/** The color of a terrain layer's slopes that face the light. Its `color` is the shadow's. */
|
|
216
|
+
highlight?: string | undefined;
|
|
217
|
+
/** Stable for as long as the element is in the frame, for a renderer that keys its layers. */
|
|
218
|
+
id: string;
|
|
219
|
+
/** What a points layer writes its counts in. */
|
|
220
|
+
ink?: string | undefined;
|
|
221
|
+
kind: 'area' | 'buildings' | 'contours' | 'landcover' | 'points' | 'raster' | 'route' | 'terrain';
|
|
222
|
+
/** What the frame's list calls it. */
|
|
223
|
+
label: string;
|
|
224
|
+
/** A raster layer's deepest zoom with tiles, past which a renderer enlarges them. */
|
|
225
|
+
maxZoom?: number | undefined;
|
|
226
|
+
/** How opaque a raster layer's tiles are, from `0` to `1`. */
|
|
227
|
+
opacity?: number | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* How a route's line is drawn where it is not solid: `dotted` for a leg
|
|
230
|
+
* off the network the rest is routed on, a place set back from its road.
|
|
231
|
+
*/
|
|
232
|
+
pattern?: 'dotted' | undefined;
|
|
233
|
+
/** Whether a terrain layer raises the ground to its height in 3D. */
|
|
234
|
+
raised?: boolean | undefined;
|
|
235
|
+
/** A terrain or contours layer's elevation tile URL, with `{z}`, `{x}`, and `{y}` in it. */
|
|
236
|
+
src?: string | undefined;
|
|
237
|
+
/** The unit a contours layer's heights are labeled in. */
|
|
238
|
+
unit?: 'feet' | 'meters' | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* In order: along a route, and around an area without repeating the first;
|
|
241
|
+
* a points layer's every point, the same array for as long as its data is
|
|
242
|
+
* the same, so a driver can tell a redraw that moved none of them.
|
|
243
|
+
*/
|
|
244
|
+
points: MapPlace[];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* How far along a line each of its points is, in meters from the first:
|
|
248
|
+
* degrees with longitude narrowed by the latitude, which is a flat map's idea
|
|
249
|
+
* of length and near enough over a city.
|
|
250
|
+
*
|
|
251
|
+
* **The one measure of a route's progress.** A route is cut at its `progress`
|
|
252
|
+
* by this, so a page moving something along the route measures with it too:
|
|
253
|
+
* measured in plain degrees, a walker's share of the walk and the connector's
|
|
254
|
+
* cut disagreed by up to a hundred meters, and the line under the walker was
|
|
255
|
+
* still bright behind it.
|
|
256
|
+
*/
|
|
257
|
+
export declare const distancesAlong: (points: readonly MapPlace[]) => number[];
|
|
258
|
+
/** How a connection is made, where the defaults are not wanted. */
|
|
259
|
+
export interface ConnectOptions {
|
|
260
|
+
/**
|
|
261
|
+
* Whether the renderer's credit fills the frame's `attribution` slot. On by
|
|
262
|
+
* default, and left alone either way where the page slotted its own.
|
|
263
|
+
*/
|
|
264
|
+
credit?: boolean | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* How close two markers' points may come on screen, in CSS pixels, before
|
|
267
|
+
* a frame that gathers its markers draws them as one. 40 by default, about
|
|
268
|
+
* where two points and their names begin to draw over each other.
|
|
269
|
+
*/
|
|
270
|
+
clusterDistance?: number | undefined;
|
|
271
|
+
/**
|
|
272
|
+
* Whether pressing a cluster zooms in to its places. On by default; off for
|
|
273
|
+
* a page that answers `helix-map-cluster` itself, listing them in a panel.
|
|
274
|
+
*/
|
|
275
|
+
clusterZoom?: boolean | undefined;
|
|
276
|
+
/**
|
|
277
|
+
* Who answers the arrow keys: the frame, whose region is the tab stop, or
|
|
278
|
+
* the renderer's own handler, which is the way back for a view that wants
|
|
279
|
+
* the renderer's rotate and pitch. `frame` by default.
|
|
280
|
+
*/
|
|
281
|
+
keyboard?: 'frame' | 'renderer' | undefined;
|
|
282
|
+
}
|
|
283
|
+
/** A connection, which is ended rather than left to leak. */
|
|
284
|
+
export interface MapConnection {
|
|
285
|
+
/** Stops answering the frame and puts back everything connecting changed. */
|
|
286
|
+
disconnect(): void;
|
|
287
|
+
/**
|
|
288
|
+
* Frames every place the frame holds, its markers and every point of its
|
|
289
|
+
* routes and areas, inset by `padding`, 48 pixels by default, at the page's
|
|
290
|
+
* pace for a trip, or at once with `animate: false`, which is what framing
|
|
291
|
+
* a map that is still settling its size wants. Nothing where the frame
|
|
292
|
+
* holds no place or the driver cannot frame.
|
|
293
|
+
*/
|
|
294
|
+
fit(options?: {
|
|
295
|
+
animate?: boolean | undefined;
|
|
296
|
+
padding?: MapPadding | undefined;
|
|
297
|
+
}): void;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Connects a Map frame to a renderer through its driver.
|
|
301
|
+
*
|
|
302
|
+
* **Everything that is the same for every renderer happens here**, once:
|
|
303
|
+
* `helix-map-pan` and `helix-map-zoom` answered in pixels and a direction, with
|
|
304
|
+
* no motion where the reader asked for none; the renderer's keyboard handler
|
|
305
|
+
* silenced and its canvas taken out of the tab order, so a reader meets one
|
|
306
|
+
* named stop and one set of keys rather than the frame and an unnamed canvas
|
|
307
|
+
* that answers differently; the renderer's own zoom buttons taken off where
|
|
308
|
+
* the frame draws its own; the frame's markers stood on their places as the
|
|
309
|
+
* view moves, and brought into view as the keyboard reaches them; and the
|
|
310
|
+
* renderer's credit written into the frame's
|
|
311
|
+
* `attribution` slot as text and links, kept current as its sources change.
|
|
312
|
+
*
|
|
313
|
+
* The frame is `helix-map` or `helix-headless-map`, and the driver is
|
|
314
|
+
* `mapLibreDriver`, `leafletDriver` or one of the page's own.
|
|
315
|
+
*/
|
|
316
|
+
export declare const connectMap: (frame: HTMLElement, driver: MapDriver, options?: ConnectOptions) => MapConnection;
|
|
317
|
+
//# sourceMappingURL=connect-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-map.d.ts","sourceRoot":"","sources":["../../src/connect-map/connect-map.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,qBAAqB,CAAA;AAK9D,yGAAyG;AACzG,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAA;AAEzD;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,OAAO,CAAC,IAAI,MAAM,CAAA;IAClB;;;OAGG;IACH,MAAM,CAAC,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAA;IACjC;;;;OAIG;IACH,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,IAAI,GA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