@emuanalytics/flow-rdf-core 4.0.11 → 4.0.13
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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/lib/map/flow-core-map.mjs +36 -12
- package/dist/lib/map/plugins/annotations/annotation.events.mjs +9 -0
- package/dist/lib/map/plugins/annotations/annotation.plugin.mjs +134 -2
- package/dist/lib/map/plugins/data-join.plugin.mjs +42 -1
- package/dist/lib/map/plugins/export/export.plugin.mjs +14 -0
- package/dist/lib/map/plugins/export/map-exporter.mjs +37 -34
- package/dist/lib/map/plugins/hover-effect.plugin.mjs +9 -0
- package/dist/lib/map/plugins/index.d.mts +742 -33
- package/dist/lib/map/plugins/index.d.ts +742 -33
- package/dist/lib/map/plugins/index.mjs +0 -1
- package/dist/lib/map/plugins/keyboard-shortcut-manager.mjs +6 -0
- package/dist/lib/map/plugins/map-plugin-base.mjs +5 -0
- package/dist/lib/map/plugins/plugin-manager.mjs +97 -0
- package/dist/lib/map/plugins/popup.plugin.mjs +12 -0
- package/dist/lib/map/plugins/selection/selection.events.mjs +3 -0
- package/dist/lib/map/plugins/selection/selection.plugin.mjs +75 -4
- package/dist/lib/map/plugins/selection/source-selection.mjs +50 -2
- package/dist/lib/map/support/map-events.mjs +19 -0
- package/dist/lib/map/support/map-popup.mjs +30 -5
- package/dist/lib/utils/index.d.mts +1 -0
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/package.json.mjs +1 -1
- package/dist/shared/{flow-rdf-core.08156446.d.mts → flow-rdf-core.3da5bd49.d.mts} +448 -17
- package/dist/shared/{flow-rdf-core.08156446.d.ts → flow-rdf-core.3da5bd49.d.ts} +448 -17
- package/package.json +4 -3
- package/styles/flow-rdf-core.css +1 -1
- package/dist/lib/map/plugins/url-sync.plugin.mjs +0 -55
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Annotation, M as MapStyleSpecification, S as StateStore, a as MapDataSource, b as MapLayer, F as FlowContextOptions, c as FlowContext } from './shared/flow-rdf-core.
|
|
2
|
-
export { B as BackgroundLayerStyleBuilder, C as CircleLayerStyleBuilder, D as DEFAULT_CONTEXT_ID, _ as FeatureStreamOptions, s as FillExtrusionLayerStyleBuilder, q as FillLayerStyleBuilder, d as FlowCoreError, h as FlowCoreExpressionCustomFunction, i as FlowCoreExpressionCustomFunctionSignature, j as FlowCoreExpressionCustomFunctions, e as FlowCoreExpressionError, a0 as FlowCoreMap, o as FlowEngineEndpoint, f as FlowMapError, H as HeatmapLayerStyleBuilder, u as HillshadeLayerStyleBuilder, L as LineLayerStyleBuilder, T as MapAnimationOptions, U as MapCenterOptions, K as MapDataSourceOptions, N as MapDataSourceSpecification, J as MapDataSourceType, a3 as MapEvent, a2 as MapEventType, a1 as MapEventTypes, V as MapFeature, W as MapFeatureIdentifier, Z as MapFeatureStream, O as MapGeojsonData, E as MapLayerExpression, z as MapLayerOptions, I as MapLayerPropertyMetadataIndex, G as MapLayerSpecification, w as MapLayerStyleBuilder, p as MapLayerType, a6 as MapLoadingEvent, a4 as MapMouseEvent, $ as MapOptions, X as MapPaddingOptions, aa as MapPopup, a9 as MapPopupOptions, a8 as MapPopupTemplateFn, g as MapRegistry, a5 as MapSourceEvent, Y as MapSourceIdentifier, a7 as MapStyleChangeEvent, P as ParserExpression, k as ParserExpressionWithIndex, l as ParserFunctionExpression, m as ParserIndex, n as ParserProgram, aq as Path, ar as PathValue, ab as Query, ag as QueryAttribute, al as QueryDefinition, an as QueryDefinitionFn, ai as QueryExtraParams, am as QueryOptions, aj as QueryOrderClause, Q as QueryRegistry, af as QueryResultFormat, ao as QueryResultTransformFn, ak as QuerySampleOptions, ah as QueryWhereClauses, t as RasterLayerStyleBuilder, R as ReactiveExpression, au as SerializationFormat, at as StoreAnnotations, as as StoreConstructor, x as StyleExpression, r as SymbolLayerStyleBuilder, y as expr, v as layerStyle, ac as query, ad as queryMany, ae as queryOne, ap as traceReaction } from './shared/flow-rdf-core.
|
|
1
|
+
import { A as Annotation, M as MapStyleSpecification, S as StateStore, a as MapDataSource, b as MapLayer, F as FlowContextOptions, c as FlowContext } from './shared/flow-rdf-core.3da5bd49.mjs';
|
|
2
|
+
export { B as BackgroundLayerStyleBuilder, C as CircleLayerStyleBuilder, D as DEFAULT_CONTEXT_ID, _ as FeatureStreamOptions, s as FillExtrusionLayerStyleBuilder, q as FillLayerStyleBuilder, d as FlowCoreError, h as FlowCoreExpressionCustomFunction, i as FlowCoreExpressionCustomFunctionSignature, j as FlowCoreExpressionCustomFunctions, e as FlowCoreExpressionError, a0 as FlowCoreMap, o as FlowEngineEndpoint, f as FlowMapError, H as HeatmapLayerStyleBuilder, u as HillshadeLayerStyleBuilder, L as LineLayerStyleBuilder, T as MapAnimationOptions, U as MapCenterOptions, K as MapDataSourceOptions, N as MapDataSourceSpecification, J as MapDataSourceType, a3 as MapEvent, a2 as MapEventType, a1 as MapEventTypes, V as MapFeature, W as MapFeatureIdentifier, Z as MapFeatureStream, O as MapGeojsonData, E as MapLayerExpression, z as MapLayerOptions, I as MapLayerPropertyMetadataIndex, G as MapLayerSpecification, w as MapLayerStyleBuilder, p as MapLayerType, a6 as MapLoadingEvent, a4 as MapMouseEvent, $ as MapOptions, X as MapPaddingOptions, aa as MapPopup, a9 as MapPopupOptions, a8 as MapPopupTemplateFn, g as MapRegistry, a5 as MapSourceEvent, Y as MapSourceIdentifier, a7 as MapStyleChangeEvent, P as ParserExpression, k as ParserExpressionWithIndex, l as ParserFunctionExpression, m as ParserIndex, n as ParserProgram, aq as Path, ar as PathValue, ab as Query, ag as QueryAttribute, al as QueryDefinition, an as QueryDefinitionFn, ai as QueryExtraParams, am as QueryOptions, aj as QueryOrderClause, Q as QueryRegistry, af as QueryResultFormat, ao as QueryResultTransformFn, ak as QuerySampleOptions, ah as QueryWhereClauses, t as RasterLayerStyleBuilder, R as ReactiveExpression, au as SerializationFormat, at as StoreAnnotations, as as StoreConstructor, x as StyleExpression, r as SymbolLayerStyleBuilder, y as expr, v as layerStyle, ac as query, ad as queryMany, ae as queryOne, ap as traceReaction } from './shared/flow-rdf-core.3da5bd49.mjs';
|
|
3
3
|
export { IDisposer, IObservableStream, ISubscription } from 'mobx-utils';
|
|
4
4
|
export { makeAutoObservable, makeObservable } from 'mobx';
|
|
5
5
|
import 'eventemitter3';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Annotation, M as MapStyleSpecification, S as StateStore, a as MapDataSource, b as MapLayer, F as FlowContextOptions, c as FlowContext } from './shared/flow-rdf-core.
|
|
2
|
-
export { B as BackgroundLayerStyleBuilder, C as CircleLayerStyleBuilder, D as DEFAULT_CONTEXT_ID, _ as FeatureStreamOptions, s as FillExtrusionLayerStyleBuilder, q as FillLayerStyleBuilder, d as FlowCoreError, h as FlowCoreExpressionCustomFunction, i as FlowCoreExpressionCustomFunctionSignature, j as FlowCoreExpressionCustomFunctions, e as FlowCoreExpressionError, a0 as FlowCoreMap, o as FlowEngineEndpoint, f as FlowMapError, H as HeatmapLayerStyleBuilder, u as HillshadeLayerStyleBuilder, L as LineLayerStyleBuilder, T as MapAnimationOptions, U as MapCenterOptions, K as MapDataSourceOptions, N as MapDataSourceSpecification, J as MapDataSourceType, a3 as MapEvent, a2 as MapEventType, a1 as MapEventTypes, V as MapFeature, W as MapFeatureIdentifier, Z as MapFeatureStream, O as MapGeojsonData, E as MapLayerExpression, z as MapLayerOptions, I as MapLayerPropertyMetadataIndex, G as MapLayerSpecification, w as MapLayerStyleBuilder, p as MapLayerType, a6 as MapLoadingEvent, a4 as MapMouseEvent, $ as MapOptions, X as MapPaddingOptions, aa as MapPopup, a9 as MapPopupOptions, a8 as MapPopupTemplateFn, g as MapRegistry, a5 as MapSourceEvent, Y as MapSourceIdentifier, a7 as MapStyleChangeEvent, P as ParserExpression, k as ParserExpressionWithIndex, l as ParserFunctionExpression, m as ParserIndex, n as ParserProgram, aq as Path, ar as PathValue, ab as Query, ag as QueryAttribute, al as QueryDefinition, an as QueryDefinitionFn, ai as QueryExtraParams, am as QueryOptions, aj as QueryOrderClause, Q as QueryRegistry, af as QueryResultFormat, ao as QueryResultTransformFn, ak as QuerySampleOptions, ah as QueryWhereClauses, t as RasterLayerStyleBuilder, R as ReactiveExpression, au as SerializationFormat, at as StoreAnnotations, as as StoreConstructor, x as StyleExpression, r as SymbolLayerStyleBuilder, y as expr, v as layerStyle, ac as query, ad as queryMany, ae as queryOne, ap as traceReaction } from './shared/flow-rdf-core.
|
|
1
|
+
import { A as Annotation, M as MapStyleSpecification, S as StateStore, a as MapDataSource, b as MapLayer, F as FlowContextOptions, c as FlowContext } from './shared/flow-rdf-core.3da5bd49.js';
|
|
2
|
+
export { B as BackgroundLayerStyleBuilder, C as CircleLayerStyleBuilder, D as DEFAULT_CONTEXT_ID, _ as FeatureStreamOptions, s as FillExtrusionLayerStyleBuilder, q as FillLayerStyleBuilder, d as FlowCoreError, h as FlowCoreExpressionCustomFunction, i as FlowCoreExpressionCustomFunctionSignature, j as FlowCoreExpressionCustomFunctions, e as FlowCoreExpressionError, a0 as FlowCoreMap, o as FlowEngineEndpoint, f as FlowMapError, H as HeatmapLayerStyleBuilder, u as HillshadeLayerStyleBuilder, L as LineLayerStyleBuilder, T as MapAnimationOptions, U as MapCenterOptions, K as MapDataSourceOptions, N as MapDataSourceSpecification, J as MapDataSourceType, a3 as MapEvent, a2 as MapEventType, a1 as MapEventTypes, V as MapFeature, W as MapFeatureIdentifier, Z as MapFeatureStream, O as MapGeojsonData, E as MapLayerExpression, z as MapLayerOptions, I as MapLayerPropertyMetadataIndex, G as MapLayerSpecification, w as MapLayerStyleBuilder, p as MapLayerType, a6 as MapLoadingEvent, a4 as MapMouseEvent, $ as MapOptions, X as MapPaddingOptions, aa as MapPopup, a9 as MapPopupOptions, a8 as MapPopupTemplateFn, g as MapRegistry, a5 as MapSourceEvent, Y as MapSourceIdentifier, a7 as MapStyleChangeEvent, P as ParserExpression, k as ParserExpressionWithIndex, l as ParserFunctionExpression, m as ParserIndex, n as ParserProgram, aq as Path, ar as PathValue, ab as Query, ag as QueryAttribute, al as QueryDefinition, an as QueryDefinitionFn, ai as QueryExtraParams, am as QueryOptions, aj as QueryOrderClause, Q as QueryRegistry, af as QueryResultFormat, ao as QueryResultTransformFn, ak as QuerySampleOptions, ah as QueryWhereClauses, t as RasterLayerStyleBuilder, R as ReactiveExpression, au as SerializationFormat, at as StoreAnnotations, as as StoreConstructor, x as StyleExpression, r as SymbolLayerStyleBuilder, y as expr, v as layerStyle, ac as query, ad as queryMany, ae as queryOne, ap as traceReaction } from './shared/flow-rdf-core.3da5bd49.js';
|
|
3
3
|
export { IDisposer, IObservableStream, ISubscription } from 'mobx-utils';
|
|
4
4
|
export { makeAutoObservable, makeObservable } from 'mobx';
|
|
5
5
|
import 'eventemitter3';
|
|
@@ -313,18 +313,42 @@ const _FlowCoreMap = class _FlowCoreMap extends EventEmitter {
|
|
|
313
313
|
return this._style.getSources(filter);
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
316
|
+
* Register a map icon image.
|
|
317
|
+
*
|
|
318
|
+
* The image can be used on [symbol-type map layers](/flow-rdf-core/layer-reference/symbol) by specifying the image ID
|
|
319
|
+
* as the [`iconImage`](/flow-rdf-core/layer-reference/symbol#icon-image) property.
|
|
320
|
+
*
|
|
321
|
+
* :::warning
|
|
322
|
+
* To fully support recoloring and halo effects, the source image should be a SDF (signed distance field) image.
|
|
323
|
+
*
|
|
324
|
+
* See [MapLibre Sprite](https://maplibre.org/maplibre-style-spec/sprite/#sprite-source-format) documentation.
|
|
325
|
+
* :::
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* Register and use a map icon image:
|
|
329
|
+
```ts
|
|
330
|
+
// Register the image
|
|
331
|
+
map.registerImage('aircraft','https://flow-cdn.emu-analytics.net/centralised-airports/vehicles/aircraft.png', 50, 50, 2, true);
|
|
332
|
+
|
|
333
|
+
// Use the image in a map layer
|
|
334
|
+
const aircraftIcons = new MapLayer({
|
|
335
|
+
id: 'aircraft_icons',
|
|
336
|
+
type: 'symbol',
|
|
337
|
+
source: 'aircraft_source',
|
|
338
|
+
style: layerStyle('symbol')
|
|
339
|
+
.iconImage('aircraft')
|
|
340
|
+
.iconColor('red')
|
|
341
|
+
});
|
|
342
|
+
```
|
|
343
|
+
*
|
|
344
|
+
*
|
|
345
|
+
* @param id Image ID.
|
|
346
|
+
* @param src Image source URL.
|
|
347
|
+
* @param width Image display width.
|
|
348
|
+
* @param height Image display height.
|
|
349
|
+
* @param pixelDensity Image pixel density. Defaults to `2` - the source image should be @2x resolution to enable better quality rendering on high-resolution displays.
|
|
350
|
+
* @param recolor Set to `true` to allow recoloring of map icon image using map layer style properties.
|
|
351
|
+
*/
|
|
328
352
|
registerImage(id, src, width, height, pixelDensity = 2, recolor = false) {
|
|
329
353
|
debug(`${this.formattedName}: Registering image '${id}'`);
|
|
330
354
|
this._imageRegistry.registerImage(id, src, width, height, pixelDensity, recolor);
|
|
@@ -7,13 +7,22 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
return value;
|
|
8
8
|
};
|
|
9
9
|
class AnnotationEvent extends MapEvent {
|
|
10
|
+
/**
|
|
11
|
+
* Constructs a new AnnotationEvent instance.
|
|
12
|
+
*/
|
|
10
13
|
constructor(type, map, data) {
|
|
11
14
|
super(type, map);
|
|
15
|
+
/** Current annotation mode (`creating`, `editing`, `idle`). */
|
|
12
16
|
__publicField(this, "mode");
|
|
17
|
+
/** Whether the last operation can be undo. Use this flag to enable/disable undo UI. */
|
|
13
18
|
__publicField(this, "canUndo");
|
|
19
|
+
/** Whether an operation can be redone. Use this flag to enable/disable redo UI. */
|
|
14
20
|
__publicField(this, "canRedo");
|
|
21
|
+
/** Currently active annotation feature ID. */
|
|
15
22
|
__publicField(this, "activeFeatureId");
|
|
23
|
+
/** Currently active annotation feature type. */
|
|
16
24
|
__publicField(this, "activeFeatureType");
|
|
25
|
+
/** Current set of annotation features. */
|
|
17
26
|
__publicField(this, "features");
|
|
18
27
|
this.mode = data.mode;
|
|
19
28
|
this.canUndo = data.canUndo;
|
|
@@ -6,8 +6,8 @@ import turfBuffer from '@turf/buffer';
|
|
|
6
6
|
import turfLength from '@turf/length';
|
|
7
7
|
import Debug from 'debug';
|
|
8
8
|
import { isPolygon, isLineString, isPoint } from '../../../utils/feature-type-checks.mjs';
|
|
9
|
-
import { isNumber, isStringFull } from '../../../utils/type-checks.mjs';
|
|
10
9
|
import { randomId } from '../../../utils/random-id.mjs';
|
|
10
|
+
import { isNumber, isStringFull } from '../../../utils/type-checks.mjs';
|
|
11
11
|
import { MapPluginBase } from '../map-plugin-base.mjs';
|
|
12
12
|
import { SelectionPlugin } from '../selection/selection.plugin.mjs';
|
|
13
13
|
import { addAnnotationLayers } from './annotation-layers.mjs';
|
|
@@ -24,6 +24,13 @@ var __publicField = (obj, key, value) => {
|
|
|
24
24
|
};
|
|
25
25
|
Debug("flow:annotation-plugin");
|
|
26
26
|
const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new AnnotationPlugin instance. This is called automatically when the plugin is added to a {@link FlowCoreMap} instance
|
|
29
|
+
* using {@link FlowCoreMap.usePlugin} method. {@link AnnotationPluginOptions} should be specified when calling `usePlugin`.
|
|
30
|
+
*
|
|
31
|
+
* @param pluginManager The plugin manager instance associated with the map
|
|
32
|
+
* @param options Plugin-specific options
|
|
33
|
+
*/
|
|
27
34
|
constructor(pluginManager, options) {
|
|
28
35
|
super(pluginManager, options);
|
|
29
36
|
__publicField(this, "name", "AnnotationPlugin");
|
|
@@ -44,6 +51,11 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
44
51
|
this.options = { ..._AnnotationPlugin._defaultOptions, ...options };
|
|
45
52
|
this.options.defaultStyle = { ..._AnnotationPlugin._defaultOptions.defaultStyle, ...options?.defaultStyle };
|
|
46
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*
|
|
57
|
+
* Called by {@link PluginManager} when the plugin is added to the map.
|
|
58
|
+
*/
|
|
47
59
|
initialize() {
|
|
48
60
|
this._annotationDataSource = addAnnotationLayers(this.map);
|
|
49
61
|
if (this.options.selectionOptions) {
|
|
@@ -68,10 +80,20 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
68
80
|
});
|
|
69
81
|
}
|
|
70
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* @internal
|
|
85
|
+
*
|
|
86
|
+
* Called by {@link PluginManager} when the plugin is destroyed.
|
|
87
|
+
*/
|
|
71
88
|
destroy() {
|
|
72
89
|
if (this._removeKeyboardShortcuts)
|
|
73
90
|
this._removeKeyboardShortcuts();
|
|
74
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Clears all map annotations and reset the plugin state.
|
|
94
|
+
*
|
|
95
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
96
|
+
*/
|
|
75
97
|
clear() {
|
|
76
98
|
this.commit();
|
|
77
99
|
this._featureIds = [];
|
|
@@ -84,6 +106,11 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
84
106
|
this.render();
|
|
85
107
|
return this;
|
|
86
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Undoes the last operation on the operation stack and pushes it to the redo stack.
|
|
111
|
+
*
|
|
112
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
113
|
+
*/
|
|
87
114
|
undo() {
|
|
88
115
|
const operation = this._undoStack.pop();
|
|
89
116
|
if (operation) {
|
|
@@ -94,7 +121,9 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
94
121
|
return this;
|
|
95
122
|
}
|
|
96
123
|
/**
|
|
97
|
-
*
|
|
124
|
+
* Redoes the last operation on the redo stack.
|
|
125
|
+
*
|
|
126
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
98
127
|
*/
|
|
99
128
|
redo() {
|
|
100
129
|
const operation = this._redoStack.pop();
|
|
@@ -105,6 +134,11 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
105
134
|
}
|
|
106
135
|
return this;
|
|
107
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Returns the specified annotation feature by id.
|
|
139
|
+
*
|
|
140
|
+
* @param featureId
|
|
141
|
+
*/
|
|
108
142
|
getFeature(featureId) {
|
|
109
143
|
const feature = this._features.get(featureId);
|
|
110
144
|
if (!feature) {
|
|
@@ -112,9 +146,20 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
112
146
|
}
|
|
113
147
|
return feature;
|
|
114
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Returns all annotation features.
|
|
151
|
+
*/
|
|
115
152
|
getFeatures() {
|
|
116
153
|
return this._featureIds.map((id) => this._features.get(id));
|
|
117
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Sets all annotation features in bulk.
|
|
157
|
+
*
|
|
158
|
+
* This operation can be undone.
|
|
159
|
+
*
|
|
160
|
+
* @param features Array of annotation features to set
|
|
161
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
162
|
+
*/
|
|
118
163
|
setFeatures(features) {
|
|
119
164
|
this.commit();
|
|
120
165
|
const normalizedFeatures = features.map((f) => this.applyDefaults(f));
|
|
@@ -133,6 +178,14 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
133
178
|
this.performOperation(operation);
|
|
134
179
|
return this;
|
|
135
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Adds an annotation feature. Note that `id` is set automatically and is available from the returned feature.
|
|
183
|
+
*
|
|
184
|
+
* This operation can be undone.
|
|
185
|
+
*
|
|
186
|
+
* @param feature The annotation feature to add
|
|
187
|
+
* @returns The added annotation feature with `id` set
|
|
188
|
+
*/
|
|
136
189
|
addFeature(feature) {
|
|
137
190
|
this.commit();
|
|
138
191
|
const fullFeature = this.applyDefaults(feature);
|
|
@@ -152,6 +205,15 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
152
205
|
this.performOperation(operation);
|
|
153
206
|
return fullFeature;
|
|
154
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Deletes the specified annotation feature.
|
|
210
|
+
*
|
|
211
|
+
* This operation can be undone.
|
|
212
|
+
*
|
|
213
|
+
* @param featureId The id of the annotation feature to delete
|
|
214
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
215
|
+
*
|
|
216
|
+
*/
|
|
155
217
|
deleteFeature(featureId) {
|
|
156
218
|
this.commit();
|
|
157
219
|
if (!featureId) {
|
|
@@ -175,6 +237,14 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
175
237
|
this.performOperation(operation);
|
|
176
238
|
return this;
|
|
177
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* Starts drawing a new annotation feature. The plugin handles subsequent mouse events to allow the user to complete the feature.
|
|
242
|
+
*
|
|
243
|
+
* Creation mode is exited when the user has completed drawing the feature or {@link AnnotationPlugin.commit} is called. Call {@link AnnotationPlugin.cancel}
|
|
244
|
+
* to programmatically exit edit mode.
|
|
245
|
+
*
|
|
246
|
+
* @param featureType The type of the feature to create
|
|
247
|
+
*/
|
|
178
248
|
createFeature(featureType) {
|
|
179
249
|
this.commit();
|
|
180
250
|
this.startDrawing();
|
|
@@ -193,6 +263,15 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
193
263
|
this.map.maplibreMap.off("draw.modechange", commitChanges);
|
|
194
264
|
});
|
|
195
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Starts editing the specified annotation feature. The plugin handles subsequent mouse events to allow the user to move the feature
|
|
268
|
+
* and modify the feature geometry.
|
|
269
|
+
*
|
|
270
|
+
* Editing mode is exited when the user deselect the feature or {@link AnnotationPlugin.commit} is called. Call {@link AnnotationPlugin.cancel}
|
|
271
|
+
* to programmatically exit edit mode.
|
|
272
|
+
*
|
|
273
|
+
* @param featureId The id of the annotation feature to edit
|
|
274
|
+
*/
|
|
196
275
|
editFeature(featureId) {
|
|
197
276
|
const feature = this.getFeature(featureId);
|
|
198
277
|
this._mode = "editing";
|
|
@@ -222,6 +301,13 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
222
301
|
break;
|
|
223
302
|
}
|
|
224
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Zoom the map to the specified annotation feature.
|
|
306
|
+
*
|
|
307
|
+
* @param featureId
|
|
308
|
+
* @param animationOptions
|
|
309
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
310
|
+
*/
|
|
225
311
|
zoomToFeature(featureId, animationOptions) {
|
|
226
312
|
const feature = this.getFeature(featureId);
|
|
227
313
|
if (!feature)
|
|
@@ -230,6 +316,14 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
230
316
|
this.map.setBounds(bbox, animationOptions);
|
|
231
317
|
return this;
|
|
232
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Sets a property of the specified annotation feature.
|
|
321
|
+
*
|
|
322
|
+
* @param featureId ID of annotation feature
|
|
323
|
+
* @param property Property name to set
|
|
324
|
+
* @param value Property value to set
|
|
325
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
326
|
+
*/
|
|
233
327
|
setFeatureProperty(featureId, property, value) {
|
|
234
328
|
const feature = this.getFeature(featureId);
|
|
235
329
|
const featureCopy = {
|
|
@@ -239,6 +333,13 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
239
333
|
this._features.set(featureId, featureCopy);
|
|
240
334
|
return this;
|
|
241
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Sets multiple properties of the specified annotation feature.
|
|
338
|
+
*
|
|
339
|
+
* @param featureId ID of annotation feature
|
|
340
|
+
* @param properties Map of name/value pairs
|
|
341
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
342
|
+
*/
|
|
242
343
|
setFeatureProperties(featureId, properties) {
|
|
243
344
|
const feature = this.getFeature(featureId);
|
|
244
345
|
const featureCopy = {
|
|
@@ -248,6 +349,13 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
248
349
|
this._features.set(featureId, featureCopy);
|
|
249
350
|
return this;
|
|
250
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Commits the current creation or editing operation.
|
|
354
|
+
*
|
|
355
|
+
* This operation can be undone.
|
|
356
|
+
*
|
|
357
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
358
|
+
*/
|
|
251
359
|
commit() {
|
|
252
360
|
this._onCommitCleanup.forEach((f) => f());
|
|
253
361
|
this._onCommitCleanup = [];
|
|
@@ -310,6 +418,13 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
310
418
|
this.render();
|
|
311
419
|
return this;
|
|
312
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* Cancel the current creation or editing operation.
|
|
423
|
+
*
|
|
424
|
+
* This operation **cannot** be undone.
|
|
425
|
+
*
|
|
426
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
427
|
+
*/
|
|
313
428
|
cancel() {
|
|
314
429
|
this._onCommitCleanup.forEach((f) => f());
|
|
315
430
|
this._onCommitCleanup = [];
|
|
@@ -325,6 +440,13 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
325
440
|
this.render();
|
|
326
441
|
return this;
|
|
327
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* Render the current state of the annotation features to the map.
|
|
445
|
+
*
|
|
446
|
+
* Note that rendering is performed automatically after creation or editing operations.
|
|
447
|
+
*
|
|
448
|
+
* @returns The annotation plugin instance to allow method chaining
|
|
449
|
+
*/
|
|
328
450
|
render() {
|
|
329
451
|
const renderedFeatures = {
|
|
330
452
|
type: "FeatureCollection",
|
|
@@ -334,6 +456,11 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
334
456
|
this.emitStateChange();
|
|
335
457
|
return this;
|
|
336
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* @internal
|
|
461
|
+
*
|
|
462
|
+
* MapPluginBase event handler
|
|
463
|
+
*/
|
|
337
464
|
handleDblClick(event) {
|
|
338
465
|
if (!this.options.interactive) {
|
|
339
466
|
return;
|
|
@@ -343,6 +470,11 @@ const _AnnotationPlugin = class _AnnotationPlugin extends MapPluginBase {
|
|
|
343
470
|
this.editFeature(clickedFeature.id.toString());
|
|
344
471
|
}
|
|
345
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* @internal
|
|
475
|
+
*
|
|
476
|
+
* MapPluginBase event handler
|
|
477
|
+
*/
|
|
346
478
|
handleBeforeStyleChanged(event) {
|
|
347
479
|
const { oldStyle, newStyle } = event;
|
|
348
480
|
if (this._drawControl) {
|
|
@@ -16,9 +16,11 @@ const _DataJoin = class _DataJoin {
|
|
|
16
16
|
constructor(id, map, options) {
|
|
17
17
|
this.id = id;
|
|
18
18
|
this.map = map;
|
|
19
|
+
__publicField(this, "options");
|
|
19
20
|
__publicField(this, "autorunDisposer", null);
|
|
21
|
+
/** Reactive expression that returns array of data objects to be joined. */
|
|
20
22
|
__publicField(this, "dataExpression", null);
|
|
21
|
-
|
|
23
|
+
/** Parameter key/value pairs where value is a reactive expression */
|
|
22
24
|
__publicField(this, "parameterExpressions", {});
|
|
23
25
|
this.options = {
|
|
24
26
|
..._DataJoin.defaultOptions,
|
|
@@ -28,6 +30,10 @@ const _DataJoin = class _DataJoin {
|
|
|
28
30
|
get source() {
|
|
29
31
|
return this.options.source;
|
|
30
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Starts the reactive data join. Changes to the reactive data expression or reactive parameters will trigger new data to be obtained
|
|
35
|
+
* and joined with the map data source features.
|
|
36
|
+
*/
|
|
31
37
|
start() {
|
|
32
38
|
this.stop();
|
|
33
39
|
if (isString(this.options.data)) {
|
|
@@ -76,12 +82,16 @@ const _DataJoin = class _DataJoin {
|
|
|
76
82
|
{ name: `FlowDataJoin.${this.map.id}.${this.id})` }
|
|
77
83
|
);
|
|
78
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Stops the reactive data join.
|
|
87
|
+
*/
|
|
79
88
|
stop() {
|
|
80
89
|
if (this.autorunDisposer) {
|
|
81
90
|
this.autorunDisposer();
|
|
82
91
|
this.autorunDisposer = null;
|
|
83
92
|
}
|
|
84
93
|
}
|
|
94
|
+
/** Performs the data join given an array of data objects. */
|
|
85
95
|
doDataJoin(data) {
|
|
86
96
|
const source = this.map.getSource(this.options.source);
|
|
87
97
|
const sourceLayer = source.type === "vector" ? this.options.sourceLayer || "geometry" : void 0;
|
|
@@ -94,6 +104,11 @@ const _DataJoin = class _DataJoin {
|
|
|
94
104
|
}, {});
|
|
95
105
|
this.map.setFeatureStateBulk({ source: source.id, sourceLayer }, featureData);
|
|
96
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Load data to join using the specified datasetId or a custom URL.
|
|
109
|
+
*
|
|
110
|
+
* Reactive parameters are added to the query as name/value querystring parameters.
|
|
111
|
+
*/
|
|
97
112
|
loadData(datasetOrUrl) {
|
|
98
113
|
if (isURL(datasetOrUrl)) {
|
|
99
114
|
const url = new URL(datasetOrUrl);
|
|
@@ -134,23 +149,44 @@ __publicField(_DataJoin, "defaultOptions", {
|
|
|
134
149
|
});
|
|
135
150
|
let DataJoin = _DataJoin;
|
|
136
151
|
class DataJoinPlugin extends MapPluginBase {
|
|
152
|
+
/**
|
|
153
|
+
* Constructs a new DataJoinPlugin instance. This is called automatically when the plugin is added to a {@link FlowCoreMap} instance
|
|
154
|
+
* using {@link FlowCoreMap.usePlugin} method.
|
|
155
|
+
*
|
|
156
|
+
* @param pluginManager The plugin manager instance associated with the map
|
|
157
|
+
*/
|
|
137
158
|
constructor(pluginManager) {
|
|
138
159
|
super(pluginManager);
|
|
139
160
|
__publicField(this, "_joins", /* @__PURE__ */ new Map());
|
|
140
161
|
__publicField(this, "name", "DataJoinPlugin");
|
|
141
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Add a new data join to the map using the specified options.
|
|
165
|
+
*
|
|
166
|
+
* The joined data can be accessed in map layer style expressions using the specified data join ID.
|
|
167
|
+
*
|
|
168
|
+
* @param id Data join ID
|
|
169
|
+
* @param options Data join options
|
|
170
|
+
*/
|
|
142
171
|
addDataJoin(id, options) {
|
|
143
172
|
const dataJoin = new DataJoin(id, this.map, options);
|
|
144
173
|
this._joins.set(id, dataJoin);
|
|
145
174
|
dataJoin.start();
|
|
146
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* @internal
|
|
178
|
+
*
|
|
179
|
+
* Used internally to set the {@link StateStore} to use for retrieving reactive properties.
|
|
180
|
+
*/
|
|
147
181
|
bindState(state) {
|
|
148
182
|
this._joins.forEach((join) => join.start());
|
|
149
183
|
}
|
|
184
|
+
/** @internal */
|
|
150
185
|
destroy() {
|
|
151
186
|
this._joins.forEach((join) => join.stop());
|
|
152
187
|
this._joins.clear();
|
|
153
188
|
}
|
|
189
|
+
/** @internal */
|
|
154
190
|
handleSourceRemoved(event) {
|
|
155
191
|
this._joins.forEach((join) => {
|
|
156
192
|
if (join.source === event.source) {
|
|
@@ -159,6 +195,11 @@ class DataJoinPlugin extends MapPluginBase {
|
|
|
159
195
|
}
|
|
160
196
|
});
|
|
161
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Removes the specified data join from the map.
|
|
200
|
+
*
|
|
201
|
+
* @param id Data join ID
|
|
202
|
+
*/
|
|
162
203
|
removeDataJoin(id) {
|
|
163
204
|
const dataJoin = this._joins.get(id);
|
|
164
205
|
if (dataJoin) {
|
|
@@ -8,10 +8,24 @@ var __publicField = (obj, key, value) => {
|
|
|
8
8
|
return value;
|
|
9
9
|
};
|
|
10
10
|
class ExportPlugin extends MapPluginBase {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs an instance of the ExportPlugin. Note that this is called automatically
|
|
13
|
+
* when the plugin is registered with a map.
|
|
14
|
+
*
|
|
15
|
+
* @param pluginManager
|
|
16
|
+
*/
|
|
11
17
|
constructor(pluginManager) {
|
|
12
18
|
super(pluginManager);
|
|
13
19
|
__publicField(this, "name", "ExportPlugin");
|
|
14
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Export the map an image file. The map will be exported in the format specified in the options.
|
|
23
|
+
*
|
|
24
|
+
* Note that only PNG format is supported currently.
|
|
25
|
+
*
|
|
26
|
+
* @param options Export options
|
|
27
|
+
* @returns Promise that resolves to the filename of the exported map image when the export has finished
|
|
28
|
+
*/
|
|
15
29
|
exportMap(options) {
|
|
16
30
|
const mapExporter = new MapExporter(this.map);
|
|
17
31
|
return mapExporter.export(options);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import maplibre from '@emuanalytics/maplibre-gl';
|
|
2
2
|
import saveAs from 'file-saver';
|
|
3
3
|
import { randomId } from '../../../utils/random-id.mjs';
|
|
4
|
-
import { isFunction } from '../../../utils/type-checks.mjs';
|
|
4
|
+
import { isFunction, isArray } from '../../../utils/type-checks.mjs';
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -16,20 +16,20 @@ const _MapExporter = class _MapExporter {
|
|
|
16
16
|
}
|
|
17
17
|
async export(options) {
|
|
18
18
|
options = { ..._MapExporter.defaultOptions, ...options };
|
|
19
|
-
const [container, mapCopy] = await this.createMapCopy(options);
|
|
19
|
+
const [container, hidden, mapCopy] = await this.createMapCopy(options);
|
|
20
20
|
return new Promise((resolve, reject) => {
|
|
21
21
|
const fileName = `${options.name}.${options.format}`;
|
|
22
22
|
const mapCanvas = mapCopy.getCanvas();
|
|
23
23
|
const exportCanvas = this.createExportCanvas(container, mapCanvas);
|
|
24
24
|
const exportContext = exportCanvas.getContext("2d");
|
|
25
25
|
if (!exportContext) {
|
|
26
|
-
this.destroyMapCopy(
|
|
26
|
+
this.destroyMapCopy(hidden, mapCopy);
|
|
27
27
|
reject(new Error("Failed to create export canvas context"));
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
const drawOverlayCallback = (err) => {
|
|
31
31
|
if (err) {
|
|
32
|
-
this.destroyMapCopy(
|
|
32
|
+
this.destroyMapCopy(hidden, mapCopy);
|
|
33
33
|
reject(err);
|
|
34
34
|
} else {
|
|
35
35
|
switch (options.format) {
|
|
@@ -41,12 +41,16 @@ const _MapExporter = class _MapExporter {
|
|
|
41
41
|
case "pdf":
|
|
42
42
|
throw new Error("Export to PDF is not currently supported");
|
|
43
43
|
}
|
|
44
|
-
this.destroyMapCopy(
|
|
44
|
+
this.destroyMapCopy(hidden, mapCopy);
|
|
45
45
|
resolve(fileName);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
const mapImage = new Image();
|
|
49
49
|
mapImage.onload = () => {
|
|
50
|
+
exportContext.save();
|
|
51
|
+
exportContext.fillStyle = options.background || "white";
|
|
52
|
+
exportContext.fillRect(0, 0, exportCanvas.width, exportCanvas.height);
|
|
53
|
+
exportContext.restore();
|
|
50
54
|
exportContext.drawImage(mapImage, 0, 0);
|
|
51
55
|
if (isFunction(options.drawOverlayFn)) {
|
|
52
56
|
options.drawOverlayFn(
|
|
@@ -64,45 +68,44 @@ const _MapExporter = class _MapExporter {
|
|
|
64
68
|
});
|
|
65
69
|
}
|
|
66
70
|
createMapCopy(options) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
let bounds = this.map.maplibreMap.getBounds();
|
|
72
|
+
let center = this.map.maplibreMap.getCenter();
|
|
73
|
+
let zoom = this.map.maplibreMap.getZoom();
|
|
74
|
+
const projection = this.map.maplibreMap.getProjection();
|
|
75
|
+
if (isArray(options.bounds) && options.bounds.length === 4 && (projection.type !== "globe" || zoom >= 4)) {
|
|
76
|
+
bounds = new maplibre.LngLatBounds(
|
|
77
|
+
[options.bounds[0], options.bounds[1]],
|
|
78
|
+
[options.bounds[2], options.bounds[3]]
|
|
79
|
+
);
|
|
80
|
+
const calculatedCamera = this.map.maplibreMap.cameraForBounds(bounds);
|
|
81
|
+
if (calculatedCamera) {
|
|
82
|
+
center = maplibre.LngLat.convert(calculatedCamera.center);
|
|
83
|
+
zoom = calculatedCamera.zoom;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
78
86
|
const exportWidth = options.width * options.dpmm;
|
|
79
87
|
const exportHeight = options.height * options.dpmm;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const coverRatio = Math.max(aspectRatios.width, aspectRatios.height);
|
|
85
|
-
const copyWidth = exportWidth * coverRatio;
|
|
86
|
-
const copyHeight = exportHeight * coverRatio;
|
|
87
|
-
const pixelRatio = exportWidth / copyWidth;
|
|
88
|
-
this.setDevicePixelRatio(pixelRatio);
|
|
88
|
+
this.setDevicePixelRatio(options.dpmm / 3.7795);
|
|
89
|
+
const hidden = document.createElement("div");
|
|
90
|
+
hidden.className = "maplibregl-export";
|
|
91
|
+
document.body.appendChild(hidden);
|
|
89
92
|
const container = document.createElement("div");
|
|
90
|
-
container.
|
|
91
|
-
container.
|
|
92
|
-
container
|
|
93
|
-
container.style.height = `${copyHeight}px`;
|
|
94
|
-
this.map.container.insertBefore(container, this.map.container.firstChild);
|
|
93
|
+
container.style.width = `${exportWidth}px`;
|
|
94
|
+
container.style.height = `${exportHeight}px`;
|
|
95
|
+
hidden.appendChild(container);
|
|
95
96
|
const mapCopy = new maplibre.Map({
|
|
96
97
|
container,
|
|
97
|
-
center
|
|
98
|
-
zoom
|
|
98
|
+
center,
|
|
99
|
+
zoom,
|
|
99
100
|
style: { ...this.map.maplibreMap.getStyle(), transition: { delay: 0, duration: 0 } },
|
|
100
101
|
bearing: this.map.maplibreMap.getBearing(),
|
|
101
102
|
pitch: this.map.maplibreMap.getPitch(),
|
|
102
103
|
interactive: false,
|
|
103
104
|
attributionControl: false,
|
|
104
105
|
fadeDuration: 0,
|
|
105
|
-
|
|
106
|
+
canvasContextAttributes: {
|
|
107
|
+
preserveDrawingBuffer: true
|
|
108
|
+
},
|
|
106
109
|
transformRequest: this.transformMapRequest.bind(this)
|
|
107
110
|
});
|
|
108
111
|
mapCopy.on("styleimagemissing", (e) => this.handleMissingImage(e, mapCopy));
|
|
@@ -112,7 +115,7 @@ const _MapExporter = class _MapExporter {
|
|
|
112
115
|
mapCopy.style.sourceCaches[sourceId]._state.stateChanges = this.map.maplibreMap.style.sourceCaches[sourceId]._state.state;
|
|
113
116
|
});
|
|
114
117
|
mapCopy._update();
|
|
115
|
-
setTimeout(() => resolve([container, mapCopy]), 500);
|
|
118
|
+
setTimeout(() => resolve([container, hidden, mapCopy]), 500);
|
|
116
119
|
});
|
|
117
120
|
});
|
|
118
121
|
}
|