@artsdatabanken/nbic-map-component 0.3.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 +170 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/geometry-analysis-ERCBMJB7.js +37 -0
- package/dist/index.cjs +3796 -0
- package/dist/index.d.cts +805 -0
- package/dist/index.d.ts +805 -0
- package/dist/index.js +3711 -0
- package/package.json +70 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,805 @@
|
|
|
1
|
+
import { Tile, Feature as Feature$1 } from 'ol';
|
|
2
|
+
import { Extent } from 'ol/extent';
|
|
3
|
+
import Feature, { FeatureLike } from 'ol/Feature';
|
|
4
|
+
import BaseLayer from 'ol/layer/Base';
|
|
5
|
+
import { Geometry } from 'ol/geom';
|
|
6
|
+
import VectorSource from 'ol/source/Vector';
|
|
7
|
+
import Control from 'ol/control/Control';
|
|
8
|
+
import { Type } from 'ol/geom/Geometry';
|
|
9
|
+
import { Coordinate } from 'ol/coordinate';
|
|
10
|
+
import { GeoJsonProperties, Position, Feature as Feature$2, Geometry as Geometry$1, FeatureCollection } from 'geojson';
|
|
11
|
+
import OlMap from 'ol/Map';
|
|
12
|
+
|
|
13
|
+
type MapCoord = [number, number];
|
|
14
|
+
type DrawKind = 'Point' | 'LineString' | 'Polygon' | 'Circle' | 'Text' | 'Box';
|
|
15
|
+
interface ControlInit {
|
|
16
|
+
fullscreen?: boolean;
|
|
17
|
+
scaleLine?: boolean;
|
|
18
|
+
geolocation?: boolean;
|
|
19
|
+
geolocationFollow?: boolean;
|
|
20
|
+
zoom?: boolean;
|
|
21
|
+
attribution?: boolean;
|
|
22
|
+
}
|
|
23
|
+
type BufferUnits = 'meters' | 'kilometers' | 'miles' | 'feet';
|
|
24
|
+
type InteractiveBuffer = boolean | ({
|
|
25
|
+
interactive?: boolean;
|
|
26
|
+
distance?: number;
|
|
27
|
+
units?: BufferUnits;
|
|
28
|
+
steps?: number;
|
|
29
|
+
style?: DrawStyleOptions;
|
|
30
|
+
replaceOriginal?: boolean;
|
|
31
|
+
/** Line cap style for line buffers (turf): 'round' | 'flat' | 'square' */
|
|
32
|
+
cap?: 'round' | 'flat' | 'square';
|
|
33
|
+
/** Line join style for polygons (turf): 'round' | 'mitre' | 'bevel' */
|
|
34
|
+
join?: 'round' | 'mitre' | 'bevel';
|
|
35
|
+
});
|
|
36
|
+
interface DrawStyleOptions {
|
|
37
|
+
strokeColor?: string;
|
|
38
|
+
strokeWidth?: number;
|
|
39
|
+
fillColor?: string;
|
|
40
|
+
pointRadius?: number;
|
|
41
|
+
text?: {
|
|
42
|
+
label?: string;
|
|
43
|
+
font?: string;
|
|
44
|
+
fillColor?: string;
|
|
45
|
+
strokeColor?: string;
|
|
46
|
+
strokeWidth?: number;
|
|
47
|
+
offsetX?: number;
|
|
48
|
+
offsetY?: number;
|
|
49
|
+
};
|
|
50
|
+
icon?: {
|
|
51
|
+
src: string;
|
|
52
|
+
scale?: number;
|
|
53
|
+
size?: [number, number];
|
|
54
|
+
anchor?: [number, number];
|
|
55
|
+
anchorXUnits?: 'fraction' | 'pixels';
|
|
56
|
+
anchorYUnits?: 'fraction' | 'pixels';
|
|
57
|
+
rotation?: number;
|
|
58
|
+
opacity?: number;
|
|
59
|
+
color?: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface DrawOptions {
|
|
63
|
+
kind: DrawKind;
|
|
64
|
+
style?: DrawStyleOptions;
|
|
65
|
+
snap?: boolean;
|
|
66
|
+
buffer?: InteractiveBuffer;
|
|
67
|
+
}
|
|
68
|
+
interface DrawExportOptions {
|
|
69
|
+
pretty?: boolean;
|
|
70
|
+
}
|
|
71
|
+
interface DrawImportOptions {
|
|
72
|
+
clearExisting?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface MapInit {
|
|
75
|
+
target: string | HTMLElement;
|
|
76
|
+
center?: MapCoord;
|
|
77
|
+
zoom?: number;
|
|
78
|
+
projection?: string;
|
|
79
|
+
enableDefaults?: boolean;
|
|
80
|
+
minZoom?: number;
|
|
81
|
+
maxZoom?: number;
|
|
82
|
+
controls?: ControlInit;
|
|
83
|
+
}
|
|
84
|
+
interface WMTSDefOptions {
|
|
85
|
+
url: string;
|
|
86
|
+
layer: string;
|
|
87
|
+
format?: string;
|
|
88
|
+
style?: string;
|
|
89
|
+
matrixSet?: string;
|
|
90
|
+
/** When WMTS server uses non-EPSG matrix set ids (e.g. 'default028mm') */
|
|
91
|
+
matrixSetId?: string;
|
|
92
|
+
projection?: string;
|
|
93
|
+
tileSize?: number;
|
|
94
|
+
levels?: number;
|
|
95
|
+
wrapX?: boolean;
|
|
96
|
+
opacity?: number;
|
|
97
|
+
attribution?: string;
|
|
98
|
+
extent?: Extent;
|
|
99
|
+
/** Provide a full custom WMTS tile grid (overrides auto-build) */
|
|
100
|
+
/** KVP URL param override hook (rarely needed) */
|
|
101
|
+
urlParamOverrides?: Record<string, string>;
|
|
102
|
+
tileLoadFunction?: (tile: Tile, src: string) => void;
|
|
103
|
+
}
|
|
104
|
+
interface WFSDefOptions {
|
|
105
|
+
url: string;
|
|
106
|
+
typeName: string;
|
|
107
|
+
version?: '2.0.0' | '1.1.0';
|
|
108
|
+
srsName?: string;
|
|
109
|
+
outputFormat?: string;
|
|
110
|
+
geometryName?: string;
|
|
111
|
+
maxFeatures?: number;
|
|
112
|
+
headers?: Record<string, string>;
|
|
113
|
+
params?: Record<string, string | number>;
|
|
114
|
+
strategy?: 'bbox' | 'all';
|
|
115
|
+
featureNS?: string;
|
|
116
|
+
featureType?: string;
|
|
117
|
+
minZoomToLoad?: number;
|
|
118
|
+
}
|
|
119
|
+
interface ThumbnailMarkerOptions {
|
|
120
|
+
/** property name on the feature holding image url */
|
|
121
|
+
property?: string;
|
|
122
|
+
/** used when no thumbnail is present */
|
|
123
|
+
fallbackMaterialIcon?: string;
|
|
124
|
+
/** image size (source pixel size) */
|
|
125
|
+
imageSize?: [number, number];
|
|
126
|
+
/** icon scale for the image */
|
|
127
|
+
imageScale?: number;
|
|
128
|
+
/** square "frame" radius */
|
|
129
|
+
frameRadius?: number;
|
|
130
|
+
/** frame border width */
|
|
131
|
+
frameBorderWidth?: number;
|
|
132
|
+
/** frame border color */
|
|
133
|
+
frameBorderColor?: string;
|
|
134
|
+
/** frame fill color */
|
|
135
|
+
frameFillColor?: string;
|
|
136
|
+
/** frame displacement */
|
|
137
|
+
frameDisplacement?: [number, number];
|
|
138
|
+
/** triangle radius */
|
|
139
|
+
pinRadius?: number;
|
|
140
|
+
/** pin fill color */
|
|
141
|
+
pinFillColor?: string;
|
|
142
|
+
/** triangle rotation */
|
|
143
|
+
pinRotation?: number;
|
|
144
|
+
/** crossOrigin for thumbnails */
|
|
145
|
+
crossOrigin?: '' | 'anonymous' | 'use-credentials';
|
|
146
|
+
}
|
|
147
|
+
interface SimpleStyleOptions {
|
|
148
|
+
thumbnailMarker?: ThumbnailMarkerOptions;
|
|
149
|
+
fillColor?: string;
|
|
150
|
+
strokeColor?: string;
|
|
151
|
+
strokeWidth?: number;
|
|
152
|
+
circle?: {
|
|
153
|
+
radius?: number;
|
|
154
|
+
fillColor?: string;
|
|
155
|
+
strokeColor?: string;
|
|
156
|
+
strokeWidth?: number;
|
|
157
|
+
units?: 'px' | 'map';
|
|
158
|
+
radiusProperty?: string;
|
|
159
|
+
segments?: number;
|
|
160
|
+
gradient?: {
|
|
161
|
+
color: string;
|
|
162
|
+
outerScale?: number;
|
|
163
|
+
stops?: Array<[number, number]>;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
text?: {
|
|
167
|
+
label?: string;
|
|
168
|
+
font?: string;
|
|
169
|
+
fillColor?: string;
|
|
170
|
+
strokeColor?: string;
|
|
171
|
+
strokeWidth?: number;
|
|
172
|
+
offsetX?: number;
|
|
173
|
+
offsetY?: number;
|
|
174
|
+
};
|
|
175
|
+
icon?: {
|
|
176
|
+
/** e.g. '/assets/icons/marker.svg' */
|
|
177
|
+
src: string;
|
|
178
|
+
/** 1 = 100% */
|
|
179
|
+
scale?: number;
|
|
180
|
+
/** 0..1 if using fraction; or pixels if using 'pixels' units */
|
|
181
|
+
anchor?: [number, number];
|
|
182
|
+
anchorXUnits?: 'fraction' | 'pixels';
|
|
183
|
+
anchorYUnits?: 'fraction' | 'pixels';
|
|
184
|
+
/** [w, h] of the source image (optional, but helps layout) */
|
|
185
|
+
size?: [number, number];
|
|
186
|
+
rotation?: number;
|
|
187
|
+
opacity?: number;
|
|
188
|
+
/** Optional tint for SVGs (works for inline-colorable SVGs) */
|
|
189
|
+
color?: string;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
interface RawStyleOptions {
|
|
193
|
+
instance: unknown;
|
|
194
|
+
}
|
|
195
|
+
type StyleRef = {
|
|
196
|
+
ref: string;
|
|
197
|
+
};
|
|
198
|
+
type StyleDef = {
|
|
199
|
+
type: 'simple';
|
|
200
|
+
options?: SimpleStyleOptions;
|
|
201
|
+
} | {
|
|
202
|
+
type: 'raw';
|
|
203
|
+
options: RawStyleOptions;
|
|
204
|
+
} | StyleRef;
|
|
205
|
+
interface HitResult {
|
|
206
|
+
layerId: string;
|
|
207
|
+
featureId?: string | number;
|
|
208
|
+
properties?: Record<string, unknown>;
|
|
209
|
+
coordinate: MapCoord;
|
|
210
|
+
}
|
|
211
|
+
interface CameraState {
|
|
212
|
+
center: MapCoord;
|
|
213
|
+
zoom: number;
|
|
214
|
+
}
|
|
215
|
+
interface XYZDefOptions {
|
|
216
|
+
url: string;
|
|
217
|
+
minZoom?: number;
|
|
218
|
+
maxZoom?: number;
|
|
219
|
+
attributions?: string | string[];
|
|
220
|
+
tileSize?: number;
|
|
221
|
+
}
|
|
222
|
+
interface XYZDefOptions {
|
|
223
|
+
url: string;
|
|
224
|
+
minZoom?: number;
|
|
225
|
+
maxZoom?: number;
|
|
226
|
+
attributions?: string | string[];
|
|
227
|
+
tileSize?: number;
|
|
228
|
+
}
|
|
229
|
+
interface GeoJSONDefOptions {
|
|
230
|
+
url?: string;
|
|
231
|
+
/** Inline GeoJSON string (Feature or FeatureCollection) */
|
|
232
|
+
text?: string;
|
|
233
|
+
/** CRS of the GeoJSON data if different from the map (no reprojection if omitted) */
|
|
234
|
+
dataProjection?: string;
|
|
235
|
+
featureProjection?: string;
|
|
236
|
+
}
|
|
237
|
+
type SourceDef = {
|
|
238
|
+
type: 'osm';
|
|
239
|
+
} | {
|
|
240
|
+
type: 'xyz';
|
|
241
|
+
options: XYZDefOptions;
|
|
242
|
+
} | {
|
|
243
|
+
type: 'wmts';
|
|
244
|
+
options: WMTSDefOptions;
|
|
245
|
+
} | {
|
|
246
|
+
type: 'wfs';
|
|
247
|
+
options: WFSDefOptions;
|
|
248
|
+
} | {
|
|
249
|
+
type: 'geojson';
|
|
250
|
+
options: GeoJSONDefOptions;
|
|
251
|
+
} | {
|
|
252
|
+
type: 'memory';
|
|
253
|
+
};
|
|
254
|
+
type SourceInput = SourceDef;
|
|
255
|
+
interface AdoptLayerOptions {
|
|
256
|
+
base?: 'regional' | 'super';
|
|
257
|
+
zIndex?: number;
|
|
258
|
+
pickable?: boolean;
|
|
259
|
+
role?: 'overlay' | 'hover' | 'draw';
|
|
260
|
+
}
|
|
261
|
+
interface EnableEditingOptions {
|
|
262
|
+
showVertices?: boolean;
|
|
263
|
+
showVerticesPersistent?: boolean;
|
|
264
|
+
vertexStyle?: DrawStyleOptions;
|
|
265
|
+
}
|
|
266
|
+
interface LayerDef {
|
|
267
|
+
id: string;
|
|
268
|
+
name?: string;
|
|
269
|
+
kind: 'tile' | 'raster' | 'vector';
|
|
270
|
+
source: SourceInput;
|
|
271
|
+
style?: StyleDef;
|
|
272
|
+
visible?: boolean;
|
|
273
|
+
zIndex?: number;
|
|
274
|
+
zIndexPinned?: boolean;
|
|
275
|
+
base?: boolean | 'super' | 'regional';
|
|
276
|
+
background?: string;
|
|
277
|
+
minZoom?: number;
|
|
278
|
+
maxZoom?: number;
|
|
279
|
+
opacity?: number;
|
|
280
|
+
pickable?: boolean;
|
|
281
|
+
hover?: {
|
|
282
|
+
cursor?: string;
|
|
283
|
+
hitTolerance?: number;
|
|
284
|
+
clusterBehavior?: 'bubble' | 'unwrapSingle';
|
|
285
|
+
style?: DrawStyleOptions;
|
|
286
|
+
clusterStyle?: DrawStyleOptions;
|
|
287
|
+
singleClusterStyle?: DrawStyleOptions;
|
|
288
|
+
};
|
|
289
|
+
cluster?: {
|
|
290
|
+
enabled: boolean;
|
|
291
|
+
distance?: number;
|
|
292
|
+
minDistance?: number;
|
|
293
|
+
style?: StyleDef;
|
|
294
|
+
keepSingleAsCluster?: boolean;
|
|
295
|
+
countField?: string;
|
|
296
|
+
maxClusterPoints?: number;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
interface UpdateGeoJSONLayerOptions {
|
|
300
|
+
mode?: 'replace' | 'merge';
|
|
301
|
+
dataProjection?: string;
|
|
302
|
+
keepStyles?: boolean;
|
|
303
|
+
idProperty?: string;
|
|
304
|
+
}
|
|
305
|
+
interface HoverInfoOptions {
|
|
306
|
+
/** Pixel tolerance for hit-testing. Default: 5 */
|
|
307
|
+
hitTolerance?: number;
|
|
308
|
+
/** Outline color. Default: '#ffcc00' */
|
|
309
|
+
outlineColor?: string;
|
|
310
|
+
/** Outline width in px. Default: 3 */
|
|
311
|
+
outlineWidth?: number;
|
|
312
|
+
}
|
|
313
|
+
interface InsertGeomOptions {
|
|
314
|
+
/** CRS of the incoming coordinates. If omitted, assume map/view projection. */
|
|
315
|
+
dataProjection?: string;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
type MapEventMap = {
|
|
319
|
+
ready: void;
|
|
320
|
+
destroy: void;
|
|
321
|
+
'camera:changed': CameraState;
|
|
322
|
+
'layer:added': {
|
|
323
|
+
layerId: string;
|
|
324
|
+
};
|
|
325
|
+
'layer:removed': {
|
|
326
|
+
layerId: string;
|
|
327
|
+
};
|
|
328
|
+
'pointer:move': {
|
|
329
|
+
coordinate: MapCoord;
|
|
330
|
+
};
|
|
331
|
+
'pointer:click': {
|
|
332
|
+
features: {
|
|
333
|
+
feature: Feature;
|
|
334
|
+
layer: BaseLayer;
|
|
335
|
+
}[];
|
|
336
|
+
clickCoordinate: Coordinate;
|
|
337
|
+
} | {
|
|
338
|
+
clickCoordinate: Coordinate;
|
|
339
|
+
features: null;
|
|
340
|
+
};
|
|
341
|
+
'extent:changed': {
|
|
342
|
+
extent: Extent;
|
|
343
|
+
};
|
|
344
|
+
'baselayer:changed': {
|
|
345
|
+
layerId: string | null;
|
|
346
|
+
};
|
|
347
|
+
'hover:info': {
|
|
348
|
+
coordinate: MapCoord;
|
|
349
|
+
items: {
|
|
350
|
+
feature: Feature;
|
|
351
|
+
layer: BaseLayer;
|
|
352
|
+
}[];
|
|
353
|
+
} | null;
|
|
354
|
+
'draw:start': {
|
|
355
|
+
kind: string;
|
|
356
|
+
};
|
|
357
|
+
'draw:end': {
|
|
358
|
+
feature: Feature<Geometry>;
|
|
359
|
+
};
|
|
360
|
+
'draw:imported': {
|
|
361
|
+
count: number;
|
|
362
|
+
};
|
|
363
|
+
'draw:cleared': {
|
|
364
|
+
count: number;
|
|
365
|
+
};
|
|
366
|
+
'draw:vertex': {
|
|
367
|
+
kind: string;
|
|
368
|
+
index: number;
|
|
369
|
+
coordinate: MapCoord;
|
|
370
|
+
};
|
|
371
|
+
'draw:vertexRemoved': {
|
|
372
|
+
kind: string;
|
|
373
|
+
index: number;
|
|
374
|
+
};
|
|
375
|
+
'edit:modified': {
|
|
376
|
+
count: number;
|
|
377
|
+
feature: Feature<Geometry>;
|
|
378
|
+
};
|
|
379
|
+
'edit:undo': {
|
|
380
|
+
feature: Feature<Geometry>;
|
|
381
|
+
};
|
|
382
|
+
'geo:position': {
|
|
383
|
+
coordinate: MapCoord;
|
|
384
|
+
accuracy?: number;
|
|
385
|
+
} | null;
|
|
386
|
+
'geo:error': {
|
|
387
|
+
message: string;
|
|
388
|
+
};
|
|
389
|
+
'fullscreen:change': {
|
|
390
|
+
active: boolean;
|
|
391
|
+
};
|
|
392
|
+
'controls:scaleline': {
|
|
393
|
+
visible: boolean;
|
|
394
|
+
};
|
|
395
|
+
'controls:zoom': {
|
|
396
|
+
visible: boolean;
|
|
397
|
+
};
|
|
398
|
+
'controls:attribution': {
|
|
399
|
+
visible: boolean;
|
|
400
|
+
};
|
|
401
|
+
'base:changed': {
|
|
402
|
+
regional: string | null;
|
|
403
|
+
super: string | null;
|
|
404
|
+
};
|
|
405
|
+
'buffer:created': {
|
|
406
|
+
baseFeature: Feature<Geometry>;
|
|
407
|
+
bufferFeature: Feature<Geometry>;
|
|
408
|
+
distance: number;
|
|
409
|
+
units: string;
|
|
410
|
+
};
|
|
411
|
+
'buffer:interactive:start': {
|
|
412
|
+
mode: Type;
|
|
413
|
+
};
|
|
414
|
+
'select:changed': {
|
|
415
|
+
layerId: string;
|
|
416
|
+
featureId: string | number;
|
|
417
|
+
} | null;
|
|
418
|
+
error: {
|
|
419
|
+
scope: string;
|
|
420
|
+
message: string;
|
|
421
|
+
detail?: unknown;
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
declare const MapEvents: {
|
|
425
|
+
readonly Ready: "ready";
|
|
426
|
+
readonly Destroy: "destroy";
|
|
427
|
+
readonly CameraChanged: "camera:changed";
|
|
428
|
+
readonly ExtentChanged: "extent:changed";
|
|
429
|
+
readonly LayerAdded: "layer:added";
|
|
430
|
+
readonly LayerRemoved: "layer:removed";
|
|
431
|
+
readonly PointerMove: "pointer:move";
|
|
432
|
+
readonly PointerClick: "pointer:click";
|
|
433
|
+
readonly BaselayerChanged: "baselayer:changed";
|
|
434
|
+
readonly BaseChanged: "base:changed";
|
|
435
|
+
readonly HoverInfo: "hover:info";
|
|
436
|
+
readonly Error: "error";
|
|
437
|
+
readonly DrawStart: "draw:start";
|
|
438
|
+
readonly DrawEnd: "draw:end";
|
|
439
|
+
readonly DrawImported: "draw:imported";
|
|
440
|
+
readonly DrawCleared: "draw:cleared";
|
|
441
|
+
readonly DrawVertex: "draw:vertex";
|
|
442
|
+
readonly DrawVertexRemoved: "draw:vertexRemoved";
|
|
443
|
+
readonly GeoPosition: "geo:position";
|
|
444
|
+
readonly GeoError: "geo:error";
|
|
445
|
+
readonly FullscreenChange: "fullscreen:change";
|
|
446
|
+
readonly ScaleLineControl: "controls:scaleline";
|
|
447
|
+
readonly ZoomControl: "controls:zoom";
|
|
448
|
+
readonly AttributionControl: "controls:attribution";
|
|
449
|
+
readonly BufferCreated: "buffer:created";
|
|
450
|
+
readonly BufferInteractiveStart: "buffer:interactive:start";
|
|
451
|
+
readonly EditModified: "edit:modified";
|
|
452
|
+
};
|
|
453
|
+
type MapEventName = keyof MapEventMap;
|
|
454
|
+
type MapEventPayload<K extends MapEventName> = MapEventMap[K];
|
|
455
|
+
|
|
456
|
+
interface MapEngine {
|
|
457
|
+
init(init: MapInit): Promise<void>;
|
|
458
|
+
destroy(): void;
|
|
459
|
+
getCamera(): CameraState;
|
|
460
|
+
getExtent(): Extent;
|
|
461
|
+
setCenter(center: MapCoord): void;
|
|
462
|
+
setZoom(zoom: number): void;
|
|
463
|
+
fitExtent(extent: Extent, padding: number): void;
|
|
464
|
+
addLayer(def: LayerDef): void;
|
|
465
|
+
removeLayer(layerId: string): void;
|
|
466
|
+
updateGeoJSONLayer(layerId: string, geojson: string, opts?: UpdateGeoJSONLayerOptions): void;
|
|
467
|
+
setLayerVisibility(layerId: string, visible: boolean): void;
|
|
468
|
+
reorderLayers(order: string[]): void;
|
|
469
|
+
setActiveBase(layerId: string): void;
|
|
470
|
+
adoptLayer(id: string, layer: BaseLayer, opts?: AdoptLayerOptions): void;
|
|
471
|
+
adoptControl(control: Control, id?: string): string;
|
|
472
|
+
removeControl(id: string): boolean;
|
|
473
|
+
listCustomControlIds(): string[];
|
|
474
|
+
getCustomControl(id: string): Control | undefined;
|
|
475
|
+
listLayerIds(): string[];
|
|
476
|
+
listBaseLayerIds(): string[];
|
|
477
|
+
listOverlayLayerIds(): string[];
|
|
478
|
+
getLayerById(id: string): BaseLayer | null;
|
|
479
|
+
ejectLayer(id: string): void;
|
|
480
|
+
getFeatureCount(layerId: string): number;
|
|
481
|
+
getFeatures(layerId: string): Feature$1<Geometry>[] | null;
|
|
482
|
+
analyzeSelfIntersections(feature: FeatureLike): Promise<{
|
|
483
|
+
valid: boolean;
|
|
484
|
+
intersections?: unknown;
|
|
485
|
+
}>;
|
|
486
|
+
pickAt(pixel: [number, number]): HitResult | null;
|
|
487
|
+
activateHoverInfo(options?: HoverInfoOptions): void;
|
|
488
|
+
deactivateHoverInfo(): void;
|
|
489
|
+
startDrawing(opts: DrawOptions): void;
|
|
490
|
+
stopDrawing(): void;
|
|
491
|
+
enableDrawEditing(opts?: EnableEditingOptions): void;
|
|
492
|
+
disableDrawEditing(): void;
|
|
493
|
+
undoLastPoint(): void;
|
|
494
|
+
undoEdit(): void;
|
|
495
|
+
finishCurrent(): void;
|
|
496
|
+
abortCurrent(): void;
|
|
497
|
+
clearDrawn(): void;
|
|
498
|
+
setDrawnFeatureStyle(feature: Feature$1<Geometry>, style: DrawStyleOptions): void;
|
|
499
|
+
clearDrawnFeatureStyle(feature: Feature$1<Geometry>): void;
|
|
500
|
+
setFeatureStyle(layerId: string, featureId: string | number, style: DrawStyleOptions): boolean;
|
|
501
|
+
clearFeatureStyle(layerId: string, featureId: string | number): boolean;
|
|
502
|
+
exportDrawnGeoJSON(opts?: DrawExportOptions): string;
|
|
503
|
+
importDrawnGeoJSON(geojson: string, opts?: DrawImportOptions): void;
|
|
504
|
+
enterFullScreen(): void;
|
|
505
|
+
leaveFullScreen(): void;
|
|
506
|
+
showScaleLine(): void;
|
|
507
|
+
hideScaleLine(): void;
|
|
508
|
+
showZoomControl(): void;
|
|
509
|
+
hideZoomControl(): void;
|
|
510
|
+
showAttribution(): void;
|
|
511
|
+
hideAttribution(): void;
|
|
512
|
+
activateGeolocation(follow?: boolean): void;
|
|
513
|
+
deactivateGeolocation(): void;
|
|
514
|
+
zoomToGeolocation(maxZoom?: number): Promise<boolean>;
|
|
515
|
+
getVectorLayerSource(layerId: string): VectorSource<FeatureLike> | null;
|
|
516
|
+
addPoint(layerId: string, coord: MapCoord, properties?: Record<string, unknown>, style?: DrawStyleOptions, opts?: InsertGeomOptions): boolean;
|
|
517
|
+
removeAllFromLayer(layerId: string): boolean;
|
|
518
|
+
transformCoordsFrom(coord: [number, number], from: string, to: string): [number, number];
|
|
519
|
+
transformCoordsArrayFrom(coords: number[][], from: string, to: string): number[][];
|
|
520
|
+
transformExtentFrom(extent: Extent, from: string, to: string): number[] | null;
|
|
521
|
+
zoomToFeature(layerId: string, featureId: string, opts?: {
|
|
522
|
+
maxZoom?: number;
|
|
523
|
+
padding?: number;
|
|
524
|
+
}): boolean;
|
|
525
|
+
zoomToLayer(layerId: string, opts?: {
|
|
526
|
+
maxZoom?: number;
|
|
527
|
+
padding?: number;
|
|
528
|
+
}): boolean;
|
|
529
|
+
zoomToExtent(extent: Extent, opts?: {
|
|
530
|
+
maxZoom?: number;
|
|
531
|
+
padding?: number;
|
|
532
|
+
}): boolean;
|
|
533
|
+
fitGeometry(geom: Geometry, opts?: {
|
|
534
|
+
maxZoom?: number;
|
|
535
|
+
padding?: number;
|
|
536
|
+
}): boolean;
|
|
537
|
+
selectFeature(layerId: string, featureId: string | number, style?: DrawStyleOptions, coordinates?: [number, number]): boolean;
|
|
538
|
+
clearSelection(): void;
|
|
539
|
+
getSelection(): {
|
|
540
|
+
layerId: string;
|
|
541
|
+
featureId: string | number;
|
|
542
|
+
} | null;
|
|
543
|
+
getTargetElement(): HTMLElement | null;
|
|
544
|
+
getCenterFromExtent(extent: Extent): MapCoord;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
declare class MapAPI {
|
|
548
|
+
private engine;
|
|
549
|
+
private events;
|
|
550
|
+
private layerDefs;
|
|
551
|
+
constructor(init: MapInit, engine?: MapEngine);
|
|
552
|
+
on<K extends keyof MapEventMap>(type: K, cb: (payload: MapEventMap[K]) => void): () => void;
|
|
553
|
+
off<K extends keyof MapEventMap>(type: K, cb: (payload: MapEventMap[K]) => void): void;
|
|
554
|
+
once<K extends keyof MapEventMap>(type: K, cb: (payload: MapEventMap[K]) => void): void;
|
|
555
|
+
destroy(): void;
|
|
556
|
+
getCamera(): CameraState;
|
|
557
|
+
getExtent(): Extent;
|
|
558
|
+
/** Return all layers marked as base (in insertion order). */
|
|
559
|
+
getBaseLayerIds(): string[];
|
|
560
|
+
getOverlayLayerIds(): string[];
|
|
561
|
+
/** If you still want full LayerDef[] for config-only layers, keep these: */
|
|
562
|
+
getBaseLayers(): LayerDef[];
|
|
563
|
+
getOverlayLayers(): LayerDef[];
|
|
564
|
+
/** Or add engine-backed variants that return live OL layers: */
|
|
565
|
+
getLayerById(id: string): BaseLayer | null;
|
|
566
|
+
adoptControl(control: Control, id?: string): string;
|
|
567
|
+
removeControl(id: string): boolean;
|
|
568
|
+
listCustomControlIds(): string[];
|
|
569
|
+
getCustomControl(id: string): Control | undefined;
|
|
570
|
+
setCenter(center: MapCoord): void;
|
|
571
|
+
setZoom(zoom: number): void;
|
|
572
|
+
fitExtent(extent: Extent, padding?: number): void;
|
|
573
|
+
addLayer(layer: LayerDef): void;
|
|
574
|
+
removeLayer(layerId: string): void;
|
|
575
|
+
updateGeoJSONLayer(layerId: string, geojson: string, opts?: UpdateGeoJSONLayerOptions): void;
|
|
576
|
+
setLayerVisibility(layerId: string, visible: boolean): void;
|
|
577
|
+
reorderLayers(order: string[]): void;
|
|
578
|
+
addPoint(layerId: string, coord: MapCoord, properties?: Record<string, unknown>, style?: DrawStyleOptions, opts?: InsertGeomOptions): boolean;
|
|
579
|
+
removeAllFromLayer(layerId: string): boolean;
|
|
580
|
+
adoptLayer(id: string, layer: BaseLayer, opts?: AdoptLayerOptions): void;
|
|
581
|
+
ejectLayer(id: string): void;
|
|
582
|
+
getFeatureCount(layerId: string): number;
|
|
583
|
+
getFeatures(layerId: string): Feature$1<Geometry>[] | null;
|
|
584
|
+
activateHoverInfo(options?: HoverInfoOptions): void;
|
|
585
|
+
deactivateHoverInfo(): void;
|
|
586
|
+
pickAt(pixel: [number, number]): HitResult | null;
|
|
587
|
+
startDrawing(opts: DrawOptions): void;
|
|
588
|
+
stopDrawing(): void;
|
|
589
|
+
enableDrawEditing(opts?: EnableEditingOptions): void;
|
|
590
|
+
disableDrawEditing(): void;
|
|
591
|
+
setDrawnFeatureStyle(feature: Feature$1<Geometry>, style: DrawStyleOptions): void;
|
|
592
|
+
clearDrawnFeatureStyle(feature: Feature$1<Geometry>): void;
|
|
593
|
+
setFeatureStyle(layerId: string, featureId: string | number, style: DrawStyleOptions): boolean;
|
|
594
|
+
clearFeatureStyle(layerId: string, featureId: string | number): boolean;
|
|
595
|
+
undoLastPoint(): void;
|
|
596
|
+
undoEdit(): void;
|
|
597
|
+
finishCurrent(): void;
|
|
598
|
+
abortCurrent(): void;
|
|
599
|
+
clearDrawn(): void;
|
|
600
|
+
exportDrawnGeoJSON(opts?: DrawExportOptions): string;
|
|
601
|
+
importDrawnGeoJSON(text: string, opts?: DrawImportOptions): void;
|
|
602
|
+
analyzeSelfIntersections(feature: FeatureLike): Promise<{
|
|
603
|
+
valid: boolean;
|
|
604
|
+
intersections?: unknown;
|
|
605
|
+
}>;
|
|
606
|
+
enterFullScreen(): void;
|
|
607
|
+
leaveFullScreen(): void;
|
|
608
|
+
showScaleLine(): void;
|
|
609
|
+
hideScaleLine(): void;
|
|
610
|
+
showZoomControl(): void;
|
|
611
|
+
hideZoomControl(): void;
|
|
612
|
+
showAttribution(): void;
|
|
613
|
+
hideAttribution(): void;
|
|
614
|
+
activateGeolocation(follow?: boolean): void;
|
|
615
|
+
deactivateGeolocation(): void;
|
|
616
|
+
zoomToGeolocation(maxZoom?: number): Promise<boolean>;
|
|
617
|
+
transformCoordsFrom(coord: [number, number], from: string, to: string): [number, number];
|
|
618
|
+
transformCoordsArrayFrom(coords: number[][], from: string, to: string): number[][];
|
|
619
|
+
transformExtentFrom(extent: Extent, from: string, to: string): number[] | null;
|
|
620
|
+
zoomToFeature(layerId: string, featureId: string, opts?: {
|
|
621
|
+
maxZoom?: number;
|
|
622
|
+
padding?: number;
|
|
623
|
+
}): boolean;
|
|
624
|
+
zoomToLayer(layerId: string, opts?: {
|
|
625
|
+
maxZoom?: number;
|
|
626
|
+
padding?: number;
|
|
627
|
+
}): boolean;
|
|
628
|
+
zoomToExtent(extent: Extent, opts?: {
|
|
629
|
+
maxZoom?: number;
|
|
630
|
+
padding?: number;
|
|
631
|
+
}): boolean;
|
|
632
|
+
fitGeometry(geom: Geometry, opts?: {
|
|
633
|
+
maxZoom?: number;
|
|
634
|
+
padding?: number;
|
|
635
|
+
}): boolean;
|
|
636
|
+
selectFeature(layerId: string, featureId: string | number, style?: DrawStyleOptions, coordinates?: [number, number]): boolean;
|
|
637
|
+
clearSelection(): void;
|
|
638
|
+
getSelection(): {
|
|
639
|
+
layerId: string;
|
|
640
|
+
featureId: string | number;
|
|
641
|
+
} | null;
|
|
642
|
+
getTargetElement(): HTMLElement | null;
|
|
643
|
+
getCenterFromExtent(extent: Extent): MapCoord;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
declare function createMap(target: string | HTMLElement, rawConfig: unknown): MapAPI;
|
|
647
|
+
|
|
648
|
+
type IdGetter<T> = (item: T, index: number) => string | number | undefined;
|
|
649
|
+
type PropsGetter<T> = (item: T, index: number) => GeoJsonProperties | undefined;
|
|
650
|
+
type PointGetter<T> = (item: T, index: number) => {
|
|
651
|
+
lon: number;
|
|
652
|
+
lat: number;
|
|
653
|
+
} | null;
|
|
654
|
+
type LineGetter<T> = (item: T, index: number) => Position[] | null;
|
|
655
|
+
type PolyGetter<T> = (item: T, index: number) => Position[][] | null;
|
|
656
|
+
type GeometryKind = 'Point' | 'LineString' | 'Polygon';
|
|
657
|
+
interface CommonOptions<T> {
|
|
658
|
+
id?: IdGetter<T>;
|
|
659
|
+
props?: PropsGetter<T>;
|
|
660
|
+
skipInvalid?: boolean;
|
|
661
|
+
filterNull?: boolean;
|
|
662
|
+
}
|
|
663
|
+
interface PointBuildOptions<T> extends CommonOptions<T> {
|
|
664
|
+
kind: 'Point';
|
|
665
|
+
getPoint: PointGetter<T>;
|
|
666
|
+
}
|
|
667
|
+
interface LineBuildOptions<T> extends CommonOptions<T> {
|
|
668
|
+
kind: 'LineString';
|
|
669
|
+
getLine: LineGetter<T>;
|
|
670
|
+
}
|
|
671
|
+
interface PolyBuildOptions<T> extends CommonOptions<T> {
|
|
672
|
+
kind: 'Polygon';
|
|
673
|
+
getPolygon: PolyGetter<T>;
|
|
674
|
+
}
|
|
675
|
+
type BuildOptions<T> = PointBuildOptions<T> | LineBuildOptions<T> | PolyBuildOptions<T>;
|
|
676
|
+
declare function toFeature<T>(item: T, index: number, opts: BuildOptions<T>): Feature$2<Geometry$1, GeoJsonProperties> | null;
|
|
677
|
+
declare function toFeatureCollection<T>(items: T[], opts: BuildOptions<T>): FeatureCollection;
|
|
678
|
+
/** Handy for cluster label totals (supports your `countField` behavior) */
|
|
679
|
+
declare function sumProperty(features: Feature$2[], field?: string): number;
|
|
680
|
+
|
|
681
|
+
type index$2_BuildOptions<T> = BuildOptions<T>;
|
|
682
|
+
type index$2_CommonOptions<T> = CommonOptions<T>;
|
|
683
|
+
type index$2_GeometryKind = GeometryKind;
|
|
684
|
+
type index$2_IdGetter<T> = IdGetter<T>;
|
|
685
|
+
type index$2_LineBuildOptions<T> = LineBuildOptions<T>;
|
|
686
|
+
type index$2_LineGetter<T> = LineGetter<T>;
|
|
687
|
+
type index$2_PointBuildOptions<T> = PointBuildOptions<T>;
|
|
688
|
+
type index$2_PointGetter<T> = PointGetter<T>;
|
|
689
|
+
type index$2_PolyBuildOptions<T> = PolyBuildOptions<T>;
|
|
690
|
+
type index$2_PolyGetter<T> = PolyGetter<T>;
|
|
691
|
+
type index$2_PropsGetter<T> = PropsGetter<T>;
|
|
692
|
+
declare const index$2_sumProperty: typeof sumProperty;
|
|
693
|
+
declare const index$2_toFeature: typeof toFeature;
|
|
694
|
+
declare const index$2_toFeatureCollection: typeof toFeatureCollection;
|
|
695
|
+
declare namespace index$2 {
|
|
696
|
+
export { type index$2_BuildOptions as BuildOptions, type index$2_CommonOptions as CommonOptions, type index$2_GeometryKind as GeometryKind, type index$2_IdGetter as IdGetter, type index$2_LineBuildOptions as LineBuildOptions, type index$2_LineGetter as LineGetter, type index$2_PointBuildOptions as PointBuildOptions, type index$2_PointGetter as PointGetter, type index$2_PolyBuildOptions as PolyBuildOptions, type index$2_PolyGetter as PolyGetter, type index$2_PropsGetter as PropsGetter, index$2_sumProperty as sumProperty, index$2_toFeature as toFeature, index$2_toFeatureCollection as toFeatureCollection };
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
declare function ensureClosedRing(ring: number[][]): number[][];
|
|
700
|
+
/**
|
|
701
|
+
* Compute area (m²) from a lon/lat ring (EPSG:4326).
|
|
702
|
+
* `ring` is an array of [lon, lat] coordinates.
|
|
703
|
+
*/
|
|
704
|
+
declare function areaFromLonLatRing(ring: number[][]): number;
|
|
705
|
+
declare function areaToString(m2: number): string;
|
|
706
|
+
declare function getCenterFromPolygon(polygonCoordinates: number[][]): MapCoord | null;
|
|
707
|
+
/** Compute centroid from an array of coordinates.
|
|
708
|
+
* @param coordinates Array of [x, y] coordinates.
|
|
709
|
+
* @returns Centroid as [x, y] or null if input is invalid.
|
|
710
|
+
*/
|
|
711
|
+
declare function getCentroid(coordinates: number[][]): MapCoord | null;
|
|
712
|
+
declare function getExtentFromPolygon(polygonCoordinates: number[][]): number[] | null;
|
|
713
|
+
declare function isExtentInside(inner: number[], outer: number[]): boolean;
|
|
714
|
+
declare function isPointInsideExtent(coord: MapCoord, extent: number[]): boolean;
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Transforms a coordinate from a given projection into the map's view projection.
|
|
718
|
+
* If `from` is not specified or already matches the view projection, it returns the same coord.
|
|
719
|
+
*/
|
|
720
|
+
declare function toViewCoord(map: OlMap, coord: [number, number], from?: string): [number, number];
|
|
721
|
+
/**
|
|
722
|
+
* Transforms a coordinate from map view projection to another projection (default: WGS84).
|
|
723
|
+
*/
|
|
724
|
+
declare function toDataCoord(map: OlMap, coord: [number, number], to?: string): [number, number];
|
|
725
|
+
declare function transformCoordsArrayFrom(coords: number[][], from: string, to: string): number[][];
|
|
726
|
+
declare function transformCoordsFrom(coords: [number, number], from: string, to: string): [number, number];
|
|
727
|
+
declare function transformExtentFrom(extent: Extent, from: string, to: string): number[] | null;
|
|
728
|
+
declare function getCenterFromExtent(extent: number[]): MapCoord;
|
|
729
|
+
|
|
730
|
+
declare const index$1_areaFromLonLatRing: typeof areaFromLonLatRing;
|
|
731
|
+
declare const index$1_areaToString: typeof areaToString;
|
|
732
|
+
declare const index$1_ensureClosedRing: typeof ensureClosedRing;
|
|
733
|
+
declare const index$1_getCenterFromExtent: typeof getCenterFromExtent;
|
|
734
|
+
declare const index$1_getCenterFromPolygon: typeof getCenterFromPolygon;
|
|
735
|
+
declare const index$1_getCentroid: typeof getCentroid;
|
|
736
|
+
declare const index$1_getExtentFromPolygon: typeof getExtentFromPolygon;
|
|
737
|
+
declare const index$1_isExtentInside: typeof isExtentInside;
|
|
738
|
+
declare const index$1_isPointInsideExtent: typeof isPointInsideExtent;
|
|
739
|
+
declare const index$1_toDataCoord: typeof toDataCoord;
|
|
740
|
+
declare const index$1_toViewCoord: typeof toViewCoord;
|
|
741
|
+
declare const index$1_transformCoordsArrayFrom: typeof transformCoordsArrayFrom;
|
|
742
|
+
declare const index$1_transformCoordsFrom: typeof transformCoordsFrom;
|
|
743
|
+
declare const index$1_transformExtentFrom: typeof transformExtentFrom;
|
|
744
|
+
declare namespace index$1 {
|
|
745
|
+
export { index$1_areaFromLonLatRing as areaFromLonLatRing, index$1_areaToString as areaToString, index$1_ensureClosedRing as ensureClosedRing, index$1_getCenterFromExtent as getCenterFromExtent, index$1_getCenterFromPolygon as getCenterFromPolygon, index$1_getCentroid as getCentroid, index$1_getExtentFromPolygon as getExtentFromPolygon, index$1_isExtentInside as isExtentInside, index$1_isPointInsideExtent as isPointInsideExtent, index$1_toDataCoord as toDataCoord, index$1_toViewCoord as toViewCoord, index$1_transformCoordsArrayFrom as transformCoordsArrayFrom, index$1_transformCoordsFrom as transformCoordsFrom, index$1_transformExtentFrom as transformExtentFrom };
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
declare const svalbardBaseLayer: LayerDef;
|
|
749
|
+
declare const janmayenBaseLayer: LayerDef;
|
|
750
|
+
declare const topografiskBaseLayer: LayerDef;
|
|
751
|
+
declare const topo4graatoneBaseLayer: LayerDef;
|
|
752
|
+
declare const nib: LayerDef;
|
|
753
|
+
declare const osm: LayerDef;
|
|
754
|
+
|
|
755
|
+
declare const norwayCoordinate: number[];
|
|
756
|
+
declare const administrativeEnheterKommune: LayerDef;
|
|
757
|
+
declare const administrativeEnheterFylke: LayerDef;
|
|
758
|
+
|
|
759
|
+
declare const index_administrativeEnheterFylke: typeof administrativeEnheterFylke;
|
|
760
|
+
declare const index_administrativeEnheterKommune: typeof administrativeEnheterKommune;
|
|
761
|
+
declare const index_janmayenBaseLayer: typeof janmayenBaseLayer;
|
|
762
|
+
declare const index_nib: typeof nib;
|
|
763
|
+
declare const index_norwayCoordinate: typeof norwayCoordinate;
|
|
764
|
+
declare const index_osm: typeof osm;
|
|
765
|
+
declare const index_svalbardBaseLayer: typeof svalbardBaseLayer;
|
|
766
|
+
declare const index_topo4graatoneBaseLayer: typeof topo4graatoneBaseLayer;
|
|
767
|
+
declare const index_topografiskBaseLayer: typeof topografiskBaseLayer;
|
|
768
|
+
declare namespace index {
|
|
769
|
+
export { index_administrativeEnheterFylke as administrativeEnheterFylke, index_administrativeEnheterKommune as administrativeEnheterKommune, index_janmayenBaseLayer as janmayenBaseLayer, index_nib as nib, index_norwayCoordinate as norwayCoordinate, index_osm as osm, index_svalbardBaseLayer as svalbardBaseLayer, index_topo4graatoneBaseLayer as topo4graatoneBaseLayer, index_topografiskBaseLayer as topografiskBaseLayer };
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Handles fetching, storing, and renewing tokens for Norge i Bilder aerial photo services.
|
|
774
|
+
*/
|
|
775
|
+
interface NibTokenConfig {
|
|
776
|
+
tokenUrl?: string;
|
|
777
|
+
storageKey?: string;
|
|
778
|
+
expiryMarginMinutes?: number;
|
|
779
|
+
retryIntervalMs?: number;
|
|
780
|
+
onTokenFetched?: (token: string) => void;
|
|
781
|
+
onError?: (error: Error) => void;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Token object stored in localStorage
|
|
785
|
+
*/
|
|
786
|
+
interface NibToken {
|
|
787
|
+
value: string;
|
|
788
|
+
expires: number;
|
|
789
|
+
when: number;
|
|
790
|
+
}
|
|
791
|
+
interface NibTokenManager {
|
|
792
|
+
init(): Promise<void>;
|
|
793
|
+
getToken(): string;
|
|
794
|
+
getTokenInfo(): NibToken | null;
|
|
795
|
+
refreshToken(force?: boolean): Promise<string>;
|
|
796
|
+
onTokenChange(callback: (token: string) => void): () => void;
|
|
797
|
+
dispose(): void;
|
|
798
|
+
isInitialized(): boolean;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Create a NiB token manager instance
|
|
802
|
+
*/
|
|
803
|
+
declare function createNibToken(config?: NibTokenConfig): NibTokenManager;
|
|
804
|
+
|
|
805
|
+
export { type LayerDef, type MapEventName, type MapEventPayload, MapEvents, type MapInit, MapAPI as NbicMapComponent, type NibToken, type NibTokenConfig, type NibTokenManager, createMap, createNibToken, index$2 as nbicMapGeojson, index as nbicMapPresets, index$1 as nbicMapUtils };
|