@ruckc/truss-ol 1.57.0 → 1.58.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/README.md +69 -4
- package/dist/Map.svelte +96 -45
- package/dist/Map.svelte.d.ts +28 -1
- package/dist/basemaps.d.ts +106 -0
- package/dist/basemaps.js +50 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/layers-ol.d.ts +47 -0
- package/dist/layers-ol.js +185 -0
- package/dist/ol-style.d.ts +71 -0
- package/dist/ol-style.js +107 -0
- package/dist/style.d.ts +27 -4
- package/dist/style.js +36 -7
- package/dist/types.d.ts +65 -10
- package/dist/util.d.ts +1 -0
- package/dist/util.js +1 -0
- package/package.json +7 -2
package/dist/types.d.ts
CHANGED
|
@@ -18,18 +18,67 @@ export type MapMarker = {
|
|
|
18
18
|
width: number;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
+
export type { Basemap, BasemapTiles, BasemapOsm, BasemapLayer, BasemapStack, BasemapOption } from './basemaps.js';
|
|
22
|
+
/** What a layer's `loader` is asked for: the view's lon/lat box, padded by a quarter on each side and clamped to the world. */
|
|
23
|
+
export type MapLayerRequest = {
|
|
24
|
+
/** `[west, south, east, north]` */
|
|
25
|
+
bbox: [number, number, number, number];
|
|
26
|
+
zoom: number;
|
|
27
|
+
/** Aborted when the view moves on before the request finished, or the layer goes away. */
|
|
28
|
+
signal: AbortSignal;
|
|
29
|
+
};
|
|
30
|
+
/** What a `loader` resolves to: GeoJSON (a FeatureCollection, a Feature, or an array of Features), or that with `truncated: true` when the box held more than you sent (the next move loads again even inside the same box). */
|
|
31
|
+
export type MapLayerData = object | {
|
|
32
|
+
geojson: object;
|
|
33
|
+
truncated?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/** A layer's loading state, reported to its `onload`. */
|
|
36
|
+
export type MapLayerLoadState = {
|
|
37
|
+
loading: boolean;
|
|
38
|
+
count: number;
|
|
39
|
+
truncated: boolean;
|
|
40
|
+
error?: string;
|
|
41
|
+
};
|
|
21
42
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
43
|
+
* One data layer of the `layers` prop: an OpenLayers vector layer the Map creates, styles and keeps in step with this object (matched by `id`;
|
|
44
|
+
* only what changed is applied, so an unchanged layer is never rebuilt). Features come from `geojson`, your own `source`, or a bbox `loader`.
|
|
24
45
|
*/
|
|
25
|
-
export type
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
export type MapLayer = {
|
|
47
|
+
/** Unique and stable: selection reports it as `layer`, `select(id, featureId)` and `layer(id)` take it. */
|
|
48
|
+
id: string;
|
|
49
|
+
/** GeoJSON in lon/lat (FeatureCollection or Feature). Replaced when a new object is passed. Feature ids: the GeoJSON `id`, else `properties.id`, else the index. */
|
|
50
|
+
geojson?: object;
|
|
51
|
+
/** Your own OpenLayers vector source (EPSG:3857 features) instead of `geojson`; the Map draws, hit-tests and fits it but never clears it (unless the layer also has a `loader`, whose answers replace its features). */
|
|
52
|
+
source?: import('ol/source/Vector.js').default;
|
|
53
|
+
/**
|
|
54
|
+
* Load features for the view: called (debounced 250ms) after the map moves while the layer is visible, unless the last answer covered the
|
|
55
|
+
* view and was not `truncated`. Each answer replaces the layer's features; a request the view outran is aborted and its answer ignored.
|
|
56
|
+
*/
|
|
57
|
+
loader?: (request: MapLayerRequest) => Promise<MapLayerData | null | undefined>;
|
|
58
|
+
/** Loading state for a `loader` layer: `loading` while a request runs, then the feature `count`, `truncated`, or the `error` message. */
|
|
59
|
+
onload?: (state: MapLayerLoadState) => void;
|
|
60
|
+
/**
|
|
61
|
+
* The layer's look: a {@link import('./style.js').FeatureStyle} for every feature, or a function of a feature's properties returning one.
|
|
62
|
+
* A feature's own `style` object and simplestyle properties win over it (unless `simplestyle: false`); what neither sets takes the theme.
|
|
63
|
+
*/
|
|
64
|
+
style?: import('./style.js').FeatureStyle | ((properties: Record<string, unknown>, feature: {
|
|
65
|
+
id: string | number | undefined;
|
|
66
|
+
type: string;
|
|
67
|
+
}) => import('./style.js').FeatureStyle | undefined);
|
|
68
|
+
/** Read each feature's own `style` and simplestyle properties. Default true. */
|
|
69
|
+
simplestyle?: boolean;
|
|
70
|
+
/** Default true. */
|
|
71
|
+
visible?: boolean;
|
|
72
|
+
/** Stacking order among all layers. Default `30 + index` (above the built-in GeoJSON, points and markers, later entries on top). */
|
|
73
|
+
zIndex?: number;
|
|
74
|
+
/** Take part in click, hover, keyboard selection and the default fit. Default true. */
|
|
75
|
+
interactive?: boolean;
|
|
76
|
+
/** A human-readable name, kept as the OpenLayers layer's `label` property (for a layer list you build). */
|
|
77
|
+
label?: string;
|
|
78
|
+
/** 0 to 1. Default 1. */
|
|
79
|
+
opacity?: number;
|
|
80
|
+
/** Hide overlapping labels and symbols (OpenLayers' `declutter`). Read when the layer is created. Default false. */
|
|
81
|
+
declutter?: boolean;
|
|
33
82
|
};
|
|
34
83
|
/** What `onviewchange` receives, and what `bind:extent` holds: the view after the map moved. */
|
|
35
84
|
export type MapViewChange = {
|
|
@@ -109,6 +158,10 @@ export type MapApi = {
|
|
|
109
158
|
abortDrawing(): void;
|
|
110
159
|
/** Remove the last vertex of the sketch being drawn, as Backspace does. */
|
|
111
160
|
undoLastPoint(): void;
|
|
161
|
+
/** The OpenLayers vector layer the `layers` entry `id` made (its source holds the features), or `undefined`. */
|
|
162
|
+
layer(id: string): import('ol/layer/Vector.js').default | undefined;
|
|
163
|
+
/** Load a `loader` layer again now, even when the last answer covered the view (after your data changed). */
|
|
164
|
+
reloadLayer(id: string): void;
|
|
112
165
|
};
|
|
113
166
|
/** Where the Map starts (`initialView`): a centre and zoom, or a lon/lat extent fitted once the container has a size. */
|
|
114
167
|
export type MapInitialView = {
|
|
@@ -130,6 +183,8 @@ export type MapControls = {
|
|
|
130
183
|
fit?: boolean;
|
|
131
184
|
/** "Show my location" (off by default): `true`, or options. See `onlocate` / `onlocateerror`. */
|
|
132
185
|
locate?: boolean | MapLocateOptions;
|
|
186
|
+
/** The basemap switcher, shown when `basemaps` lists two or more. */
|
|
187
|
+
basemap?: boolean;
|
|
133
188
|
};
|
|
134
189
|
/** OpenLayers' attribution control of the Map (`attribution`). */
|
|
135
190
|
export type MapAttribution = {
|
package/dist/util.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type OLMap from 'ol/Map.js';
|
|
2
2
|
export * from './style.js';
|
|
3
3
|
export * from './points.js';
|
|
4
|
+
export * from './basemaps.js';
|
|
4
5
|
/** Where a standalone control sits inside its (positioned) parent. `none` leaves placement to you. */
|
|
5
6
|
export type ControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none';
|
|
6
7
|
export type ScaleUnit = 'metric' | 'imperial';
|
package/dist/util.js
CHANGED
|
@@ -2,6 +2,7 @@ import { labelFor } from './labels.js';
|
|
|
2
2
|
import { prefersReducedMotion } from '@ruckc/truss-ui';
|
|
3
3
|
export * from './style.js';
|
|
4
4
|
export * from './points.js';
|
|
5
|
+
export * from './basemaps.js';
|
|
5
6
|
const LADDER = {
|
|
6
7
|
metric: [['km', 1000], ['m', 1], ['cm', 0.01]],
|
|
7
8
|
imperial: [['mi', 1609.344], ['ft', 0.3048], ['in', 0.0254]]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruckc/truss-ol",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.0",
|
|
4
4
|
"description": "OpenLayers map styled with Truss UI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,11 +20,16 @@
|
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"svelte": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./ol-style": {
|
|
25
|
+
"types": "./dist/ol-style.d.ts",
|
|
26
|
+
"svelte": "./dist/ol-style.js",
|
|
27
|
+
"default": "./dist/ol-style.js"
|
|
23
28
|
}
|
|
24
29
|
},
|
|
25
30
|
"peerDependencies": {
|
|
26
31
|
"svelte": "^5.20.0",
|
|
27
|
-
"@ruckc/truss-ui": "^1.
|
|
32
|
+
"@ruckc/truss-ui": "^1.58.0",
|
|
28
33
|
"ol": "^10.0.0"
|
|
29
34
|
},
|
|
30
35
|
"devDependencies": {
|