@emuanalytics/flow-rdf-core 4.0.15 → 4.0.16

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 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.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';
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.09a21889.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.09a21889.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.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';
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.09a21889.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.09a21889.js';
3
3
  export { IDisposer, IObservableStream, ISubscription } from 'mobx-utils';
4
4
  export { makeAutoObservable, makeObservable } from 'mobx';
5
5
  import 'eventemitter3';
@@ -0,0 +1,122 @@
1
+ import Debug from 'debug';
2
+ import { MapPluginBase } from '../map-plugin-base.mjs';
3
+ import { PopupPlugin } from '../popup.plugin.mjs';
4
+ import { SourceHover } from './source-hover.mjs';
5
+ import { FlowMapError } from '../../../errors/flow-map-error.mjs';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __publicField = (obj, key, value) => {
10
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
+ return value;
12
+ };
13
+ const debug = Debug("flow:HoverPlugin");
14
+ class HoverPlugin extends MapPluginBase {
15
+ /**
16
+ * Constructs a new HoverEffectPlugin instance. This is called automatically when the plugin is added to a {@link FlowCoreMap} instance
17
+ * using {@link FlowCoreMap.usePlugin} method.
18
+ *
19
+ * @param pluginManager The plugin manager instance associated with the map
20
+ */
21
+ constructor(pluginManager) {
22
+ super(pluginManager);
23
+ __publicField(this, "_sourceHovers", /* @__PURE__ */ new Map());
24
+ __publicField(this, "_enablePopups", true);
25
+ __publicField(this, "_compatibilityMode", true);
26
+ __publicField(this, "name", "HoverPlugin");
27
+ try {
28
+ pluginManager.getPlugin("HoverEffectPlugin");
29
+ console.warn(
30
+ "[HoverPlugin] Warning: HoverEffectPlugin is also loaded. It has been deprecated and should be removed to avoid conflicts."
31
+ );
32
+ } catch {
33
+ }
34
+ }
35
+ /**
36
+ * Enable hover popup support for the specified map data source.
37
+ *
38
+ * @param source Map data source ID
39
+ * @param options Selection options
40
+ */
41
+ enableHover(source, options = {}) {
42
+ this._compatibilityMode = false;
43
+ if (options.popup) {
44
+ try {
45
+ this.map.getPlugin(PopupPlugin);
46
+ } catch (e) {
47
+ throw new FlowMapError(`enableHover(): Popup plugin is required for automatic hover popups`);
48
+ }
49
+ }
50
+ this.disableHover(source);
51
+ this._sourceHovers.set(source, new SourceHover(this, source, options));
52
+ }
53
+ /**
54
+ * Disable hover for the specified map data source.
55
+ *
56
+ * @param source Map data source ID
57
+ */
58
+ disableHover(source) {
59
+ this._compatibilityMode = false;
60
+ if (this._sourceHovers.has(source)) {
61
+ this._sourceHovers.get(source).destroy();
62
+ this._sourceHovers.delete(source);
63
+ }
64
+ }
65
+ /**
66
+ * Enable display of popups when a feature is hovered and an associated popup has been registered with the map data source.
67
+ * See {@link PopupPlugin} for more details of how to define and register popups.
68
+ *
69
+ * Note that popups are enabled by default.
70
+ */
71
+ enablePopups() {
72
+ this._enablePopups = true;
73
+ }
74
+ /**
75
+ * Disable display of popups when a feature is hovered. This will also close any currently open popups.
76
+ */
77
+ disablePopups() {
78
+ if (this._enablePopups) {
79
+ this.map.getPlugin(PopupPlugin).closeAllPopups();
80
+ this._enablePopups = false;
81
+ }
82
+ }
83
+ /** @internal MapPluginBase handler */
84
+ handleMouseMove(event) {
85
+ if (this._compatibilityMode) {
86
+ const sourceId = event.features[0]?.source;
87
+ if (sourceId && !this._sourceHovers.has(sourceId)) {
88
+ debug(`Enabling implicit hover support for source '${sourceId}' in compatibility mode`);
89
+ this._sourceHovers.set(sourceId, new SourceHover(this, sourceId, {}));
90
+ }
91
+ }
92
+ const hoveredFeature = event.features[0];
93
+ this._sourceHovers.forEach((hover) => hover.handleMouseMove(event.lngLat, hoveredFeature, this._enablePopups));
94
+ const isFeatureHovered = Array.from(this._sourceHovers.values()).some((hover) => !!hover.hoveredFeature);
95
+ if (isFeatureHovered) {
96
+ this.map.maplibreMap._container.classList.add("feature-hovered");
97
+ } else {
98
+ this.map.maplibreMap._container.classList.remove("feature-hovered");
99
+ }
100
+ }
101
+ /** @internal MapPluginBase handler */
102
+ handleClick(event) {
103
+ const hoveredFeature = event.features[0];
104
+ this._sourceHovers.forEach((hover) => hover.handleClick(event, hoveredFeature));
105
+ }
106
+ /** @internal MapPluginBase handler */
107
+ handleMouseOut(_event) {
108
+ this.clearHover();
109
+ }
110
+ /** @internal MapPluginBase handler */
111
+ handleSetExclusivePlugin(exclusivePlugins) {
112
+ if (exclusivePlugins.length) {
113
+ this.clearHover();
114
+ }
115
+ }
116
+ clearHover() {
117
+ this._sourceHovers.forEach((hover) => hover.clearHover());
118
+ this.map.maplibreMap._container.classList.remove("feature-hovered");
119
+ }
120
+ }
121
+
122
+ export { HoverPlugin };
@@ -0,0 +1,119 @@
1
+ import Debug from 'debug';
2
+ import { assert } from '../../../utils/assert.mjs';
3
+ import { isObject } from '../../../utils/type-checks.mjs';
4
+ import { isFeatureWithId } from '../../types.mjs';
5
+ import { PopupPlugin } from '../popup.plugin.mjs';
6
+ import { SelectionPlugin } from '../selection/selection.plugin.mjs';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __publicField = (obj, key, value) => {
11
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
12
+ return value;
13
+ };
14
+ Debug("flow:SourceHover");
15
+ class SourceHover {
16
+ /** Constructs a SourceHover to handle hover for the specified map data source. */
17
+ constructor(plugin, source, options) {
18
+ __publicField(this, "_map");
19
+ __publicField(this, "_options");
20
+ __publicField(this, "_plugin");
21
+ __publicField(this, "_popup");
22
+ __publicField(this, "_hoveredFeature", null);
23
+ __publicField(this, "_sourceId");
24
+ __publicField(this, "_featuresSubscription", null);
25
+ this._plugin = plugin;
26
+ this._map = plugin.map;
27
+ this._options = options;
28
+ const sourceType = plugin.map.getSource(source).type;
29
+ this._sourceId = {
30
+ source,
31
+ sourceLayer: sourceType === "vector" ? options.sourceLayer ?? "geometry" : void 0
32
+ };
33
+ }
34
+ get options() {
35
+ return this._options;
36
+ }
37
+ get hoveredFeature() {
38
+ return this._hoveredFeature;
39
+ }
40
+ /** Plugin destroy handler */
41
+ destroy() {
42
+ this.clearHover();
43
+ this._featuresSubscription?.unsubscribe();
44
+ }
45
+ /** Plugin click handler */
46
+ handleMouseMove(lngLat, feature, enablePopups = true) {
47
+ const hoveredSource = !!(feature && feature.source === this._sourceId.source);
48
+ if (feature && hoveredSource) {
49
+ if (!this.compareFeatures(feature, this._hoveredFeature)) {
50
+ this.clearHover(false);
51
+ this.showHover(feature, lngLat, enablePopups);
52
+ }
53
+ if (this._popup && !this._popup.options.trackFeature) {
54
+ this._popup.moveTo(lngLat);
55
+ }
56
+ } else {
57
+ this.clearHover();
58
+ }
59
+ }
60
+ handleClick(event, feature) {
61
+ const hoveredSource = !!(feature && feature.source === this._sourceId.source);
62
+ if (hoveredSource && this._popup) {
63
+ this._popup.close();
64
+ this._popup = void 0;
65
+ }
66
+ }
67
+ handleMouseOut() {
68
+ this.clearHover();
69
+ }
70
+ showHover(feature, lngLat, enablePopups) {
71
+ assert(isFeatureWithId(feature));
72
+ this._map.setFeatureState(feature, { hover: true }, false);
73
+ let selected = false;
74
+ try {
75
+ const selectionPlugin = this._map.getPlugin(SelectionPlugin);
76
+ selected = selectionPlugin.featureHasPopup(feature.source, feature.id);
77
+ } catch {
78
+ }
79
+ if (this._popup && selected) {
80
+ this._popup.close();
81
+ this._popup = void 0;
82
+ } else if (this._popup && !this.compareFeatures(feature, this._hoveredFeature)) {
83
+ this._popup.moveTo(lngLat);
84
+ this._popup.feature = feature;
85
+ } else if (!selected && enablePopups) {
86
+ if (this.options.popup) {
87
+ const popup = this._map.getPlugin(PopupPlugin).openPopup(this._options.popup, lngLat, feature);
88
+ if (popup) {
89
+ popup.on("closed", () => {
90
+ this._popup = void 0;
91
+ });
92
+ this._popup = popup;
93
+ }
94
+ }
95
+ }
96
+ this._hoveredFeature = feature;
97
+ }
98
+ clearHover(closePopup = true) {
99
+ if (this._hoveredFeature) {
100
+ this._map.removeFeatureState(this._hoveredFeature, "hover", false);
101
+ this._hoveredFeature = null;
102
+ }
103
+ if (closePopup && this._popup) {
104
+ this._popup.close();
105
+ this._popup = void 0;
106
+ }
107
+ }
108
+ compareFeatures(f1, f2) {
109
+ if (f1 === f2) {
110
+ return true;
111
+ }
112
+ if (isObject(f1) && isObject(f2)) {
113
+ return f1.id == f2.id && f1.source === f2.source && f1.sourceLayer == f2.sourceLayer;
114
+ }
115
+ return false;
116
+ }
117
+ }
118
+
119
+ export { SourceHover };
@@ -18,7 +18,15 @@ class HoverEffectPlugin extends MapPluginBase {
18
18
  constructor(pluginManager) {
19
19
  super(pluginManager);
20
20
  __publicField(this, "hoveredFeature", null);
21
+ __publicField(this, "_popups", /* @__PURE__ */ new Map());
21
22
  __publicField(this, "name", "HoverEffectPlugin");
23
+ try {
24
+ pluginManager.getPlugin("HoverPlugin");
25
+ console.warn(
26
+ "[HoverEffectPlugin] Warning: HoverEffectPlugin has been deprecated and should be removed to avoid conflicts with HoverPlugin."
27
+ );
28
+ } catch {
29
+ }
22
30
  }
23
31
  /** @internal MapPluginBase handler */
24
32
  handleMouseMove(event) {
@@ -1,5 +1,5 @@
1
- import { a3 as MapEvent, a0 as FlowCoreMap, Y as MapSourceIdentifier, av as MapFeatureId, aw as MapPluginBase, ax as PluginManager, a5 as MapSourceEvent, a4 as MapMouseEvent, Z as MapFeatureStream, ay as PartialBy, T as MapAnimationOptions, a7 as MapStyleChangeEvent, M as MapStyleSpecification, S as StateStore, a9 as MapPopupOptions, aa as MapPopup, W as MapFeatureIdentifier } from '../../../shared/flow-rdf-core.3da5bd49.mjs';
2
- export { aC as EventHandlers, aB as PluginConstructor, aA as PluginEventsType, az as PluginOptionsType } from '../../../shared/flow-rdf-core.3da5bd49.mjs';
1
+ import { a3 as MapEvent, a0 as FlowCoreMap, Y as MapSourceIdentifier, av as MapFeatureId, aw as MapPluginBase, ax as PluginManager, a5 as MapSourceEvent, a4 as MapMouseEvent, Z as MapFeatureStream, ay as PartialBy, T as MapAnimationOptions, a7 as MapStyleChangeEvent, M as MapStyleSpecification, S as StateStore, a9 as MapPopupOptions, aa as MapPopup, W as MapFeatureIdentifier } from '../../../shared/flow-rdf-core.09a21889.mjs';
2
+ export { aC as EventHandlers, aB as PluginConstructor, aA as PluginEventsType, az as PluginOptionsType } from '../../../shared/flow-rdf-core.09a21889.mjs';
3
3
  import { F as Func } from '../../../shared/flow-rdf-core.63162669.mjs';
4
4
  import 'eventemitter3';
5
5
  import 'lit-html';
@@ -316,6 +316,7 @@ declare class SelectionPlugin extends MapPluginBase<undefined, SelectionEventTyp
316
316
  * Disable display of popups when a feature is clicked. This will also close any currently open popups.
317
317
  */
318
318
  disablePopups(): void;
319
+ featureHasPopup(source: string, featureId: MapFeatureId): boolean;
319
320
  }
320
321
 
321
322
  /**
@@ -894,6 +895,8 @@ declare class ExportPlugin extends MapPluginBase<ExportPluginOptions> {
894
895
  }
895
896
 
896
897
  /**
898
+ * @deprecated HoverEffectPlugin has been deprecated. Use {@link HoverPlugin} instead.
899
+ *
897
900
  * This plugin adds hover styling support to map features.
898
901
  *
899
902
  * When active, features that are hovered over will have their `hover`
@@ -922,6 +925,7 @@ declare class ExportPlugin extends MapPluginBase<ExportPluginOptions> {
922
925
  */
923
926
  declare class HoverEffectPlugin extends MapPluginBase {
924
927
  private hoveredFeature;
928
+ private _popups;
925
929
  readonly name = "HoverEffectPlugin";
926
930
  /**
927
931
  * Constructs a new HoverEffectPlugin instance. This is called automatically when the plugin is added to a {@link FlowCoreMap} instance
@@ -940,6 +944,128 @@ declare class HoverEffectPlugin extends MapPluginBase {
940
944
  private clearHover;
941
945
  }
942
946
 
947
+ interface HoverOptions {
948
+ /** ID of popup to display when hovering over a feature. */
949
+ popup?: string;
950
+ /** Map data source layer. Note that this is only required for custom vector data sources. */
951
+ sourceLayer?: string;
952
+ }
953
+ /**
954
+ * This plugin adds hover styling and hover popup support to map features.
955
+ *
956
+ * When active, features that are hovered over will have their `hover`
957
+ * feature state property set to `true`. This can be referenced in map layer
958
+ * style expressions to apply hover effects.
959
+ *
960
+ * To enable hover support for a specific map data source, use the {@link enableHover} method.
961
+ * This method accepts a {@link HoverOptions} object that can be used to configure hover behavior
962
+ * and add a hover popup.
963
+ *
964
+ * :::warning
965
+ * This plugin supersedes the deprecated {@link HoverEffectPlugin}. To preserve the
966
+ * behavior of the {@link HoverEffectPlugin}, the {@link HoverPlugin} initially operates
967
+ * in 'compatibility mode' and implicitly enables hover for **all** map data sources.
968
+ * The first call to {@link enableHover} will disable compatibility mode and hover effects
969
+ * for other data sources must be explicitly enabled.
970
+ * :::
971
+ *
972
+ * ## Hover Popups
973
+ *
974
+ * This plugin can automatically display a popup when a feature is hovered over.
975
+ * The popup specified (if any) should be previously registered with the map data source
976
+ * using the {@link PopupPlugin}.
977
+ *
978
+ * Hover popups should be designed to be non-intrusive, as they will appear
979
+ * and disappear frequently as the user moves the mouse over the map. They should be
980
+ * configured with `closeButton: false` and not support any other user interaction.
981
+ * If `trackFeature` is enabled when registering the popup, the popup will snap to the
982
+ * feature centroid. If `trackFeature` is not enabled, the popup will move with the mouse
983
+ * cursor. For point-type features, it is recommended to enable `trackFeature` for a
984
+ * cleaner user experience. For polygon and line features, it is recommended to set
985
+ * `trackFeature` to `false` so that the popup follows the mouse cursor.
986
+ *
987
+ * This plugin interacts with the {@link SelectionPlugin} (if used) to coordinate display
988
+ * of hover and selection popups. A selection popup will take precedence over
989
+ * a hover popup when both are applicable ensuring that hover popups do not obscure
990
+ * selection popups.
991
+ *
992
+ * @noInheritDoc
993
+ *
994
+ * @example
995
+ * This map layer definition applies a hover effect using the `circleStrokeWidth` property:
996
+ ```js{7}
997
+ const circleLayer = new MapLayer({
998
+ id: "circle-layer",
999
+ type: "circle",
1000
+ source: "airquality",
1001
+ style: layerStyle("circle")
1002
+ .circleColor(expr(`@no2 ? from-palette('YlOrRd', @no2, 0, 100) : gray`))
1003
+ .circleStrokeWidth(expr("@@hover ? 5 : 0"))
1004
+ .circleRadius(expr(`@no2 ? @no2 / 5 : 5`))
1005
+ .build()
1006
+ });
1007
+
1008
+ // Register a popup to use on hover for the data source
1009
+ map.getPlugin(PopupPlugin).registerPopup('hoverPopup', {
1010
+ trackFeature: true,
1011
+ closeButton: false,
1012
+ content: (feature) =>
1013
+ html` Hover popup: ${feature?.id}`
1014
+ });
1015
+
1016
+ map.getPlugin(HoverPlugin).enableHover('airquality', {
1017
+ popup: 'hoverPopup'
1018
+ });
1019
+ ```
1020
+ *
1021
+ */
1022
+ declare class HoverPlugin extends MapPluginBase {
1023
+ private _sourceHovers;
1024
+ private _enablePopups;
1025
+ private _compatibilityMode;
1026
+ readonly name = "HoverPlugin";
1027
+ /**
1028
+ * Constructs a new HoverEffectPlugin instance. This is called automatically when the plugin is added to a {@link FlowCoreMap} instance
1029
+ * using {@link FlowCoreMap.usePlugin} method.
1030
+ *
1031
+ * @param pluginManager The plugin manager instance associated with the map
1032
+ */
1033
+ constructor(pluginManager: PluginManager);
1034
+ /**
1035
+ * Enable hover popup support for the specified map data source.
1036
+ *
1037
+ * @param source Map data source ID
1038
+ * @param options Selection options
1039
+ */
1040
+ enableHover(source: string, options?: HoverOptions): void;
1041
+ /**
1042
+ * Disable hover for the specified map data source.
1043
+ *
1044
+ * @param source Map data source ID
1045
+ */
1046
+ disableHover(source: string): void;
1047
+ /**
1048
+ * Enable display of popups when a feature is hovered and an associated popup has been registered with the map data source.
1049
+ * See {@link PopupPlugin} for more details of how to define and register popups.
1050
+ *
1051
+ * Note that popups are enabled by default.
1052
+ */
1053
+ enablePopups(): void;
1054
+ /**
1055
+ * Disable display of popups when a feature is hovered. This will also close any currently open popups.
1056
+ */
1057
+ disablePopups(): void;
1058
+ /** @internal MapPluginBase handler */
1059
+ handleMouseMove(event: MapMouseEvent): void;
1060
+ /** @internal MapPluginBase handler */
1061
+ handleClick(event: MapMouseEvent): void;
1062
+ /** @internal MapPluginBase handler */
1063
+ handleMouseOut(_event: MapEvent): void;
1064
+ /** @internal MapPluginBase handler */
1065
+ handleSetExclusivePlugin(exclusivePlugins: MapPluginBase[]): void;
1066
+ private clearHover;
1067
+ }
1068
+
943
1069
  /**
944
1070
  * @noInheritDoc
945
1071
  *
@@ -1016,4 +1142,4 @@ declare class PopupPlugin extends MapPluginBase {
1016
1142
  closePopupsForSources(sources: string | string[]): void;
1017
1143
  }
1018
1144
 
1019
- export { AnnotationEvent, type AnnotationEventData, type AnnotationEventType, type AnnotationEventTypes, type AnnotationFeature, type AnnotationFeatureProps, type AnnotationFeatureType, type AnnotationMode, type AnnotationOperation, AnnotationPlugin, type AnnotationPluginOptions, type AnnotationStyle, DataJoin, type DataJoinOptions, DataJoinPlugin, type DrawOverlayCallback, type DrawOverlayFn, ExportPlugin, type ExportPluginOptions, type FlowMapExportOptions, HoverEffectPlugin, MapPluginBase, PluginManager, PopupPlugin, SelectionEvent, type SelectionEventType, type SelectionEventTypes, type SelectionMode, type SelectionOptions, SelectionPlugin };
1145
+ export { AnnotationEvent, type AnnotationEventData, type AnnotationEventType, type AnnotationEventTypes, type AnnotationFeature, type AnnotationFeatureProps, type AnnotationFeatureType, type AnnotationMode, type AnnotationOperation, AnnotationPlugin, type AnnotationPluginOptions, type AnnotationStyle, DataJoin, type DataJoinOptions, DataJoinPlugin, type DrawOverlayCallback, type DrawOverlayFn, ExportPlugin, type ExportPluginOptions, type FlowMapExportOptions, HoverEffectPlugin, type HoverOptions, HoverPlugin, MapPluginBase, PluginManager, PopupPlugin, SelectionEvent, type SelectionEventType, type SelectionEventTypes, type SelectionMode, type SelectionOptions, SelectionPlugin };
@@ -1,5 +1,5 @@
1
- import { a3 as MapEvent, a0 as FlowCoreMap, Y as MapSourceIdentifier, av as MapFeatureId, aw as MapPluginBase, ax as PluginManager, a5 as MapSourceEvent, a4 as MapMouseEvent, Z as MapFeatureStream, ay as PartialBy, T as MapAnimationOptions, a7 as MapStyleChangeEvent, M as MapStyleSpecification, S as StateStore, a9 as MapPopupOptions, aa as MapPopup, W as MapFeatureIdentifier } from '../../../shared/flow-rdf-core.3da5bd49.js';
2
- export { aC as EventHandlers, aB as PluginConstructor, aA as PluginEventsType, az as PluginOptionsType } from '../../../shared/flow-rdf-core.3da5bd49.js';
1
+ import { a3 as MapEvent, a0 as FlowCoreMap, Y as MapSourceIdentifier, av as MapFeatureId, aw as MapPluginBase, ax as PluginManager, a5 as MapSourceEvent, a4 as MapMouseEvent, Z as MapFeatureStream, ay as PartialBy, T as MapAnimationOptions, a7 as MapStyleChangeEvent, M as MapStyleSpecification, S as StateStore, a9 as MapPopupOptions, aa as MapPopup, W as MapFeatureIdentifier } from '../../../shared/flow-rdf-core.09a21889.js';
2
+ export { aC as EventHandlers, aB as PluginConstructor, aA as PluginEventsType, az as PluginOptionsType } from '../../../shared/flow-rdf-core.09a21889.js';
3
3
  import { F as Func } from '../../../shared/flow-rdf-core.63162669.js';
4
4
  import 'eventemitter3';
5
5
  import 'lit-html';
@@ -316,6 +316,7 @@ declare class SelectionPlugin extends MapPluginBase<undefined, SelectionEventTyp
316
316
  * Disable display of popups when a feature is clicked. This will also close any currently open popups.
317
317
  */
318
318
  disablePopups(): void;
319
+ featureHasPopup(source: string, featureId: MapFeatureId): boolean;
319
320
  }
320
321
 
321
322
  /**
@@ -894,6 +895,8 @@ declare class ExportPlugin extends MapPluginBase<ExportPluginOptions> {
894
895
  }
895
896
 
896
897
  /**
898
+ * @deprecated HoverEffectPlugin has been deprecated. Use {@link HoverPlugin} instead.
899
+ *
897
900
  * This plugin adds hover styling support to map features.
898
901
  *
899
902
  * When active, features that are hovered over will have their `hover`
@@ -922,6 +925,7 @@ declare class ExportPlugin extends MapPluginBase<ExportPluginOptions> {
922
925
  */
923
926
  declare class HoverEffectPlugin extends MapPluginBase {
924
927
  private hoveredFeature;
928
+ private _popups;
925
929
  readonly name = "HoverEffectPlugin";
926
930
  /**
927
931
  * Constructs a new HoverEffectPlugin instance. This is called automatically when the plugin is added to a {@link FlowCoreMap} instance
@@ -940,6 +944,128 @@ declare class HoverEffectPlugin extends MapPluginBase {
940
944
  private clearHover;
941
945
  }
942
946
 
947
+ interface HoverOptions {
948
+ /** ID of popup to display when hovering over a feature. */
949
+ popup?: string;
950
+ /** Map data source layer. Note that this is only required for custom vector data sources. */
951
+ sourceLayer?: string;
952
+ }
953
+ /**
954
+ * This plugin adds hover styling and hover popup support to map features.
955
+ *
956
+ * When active, features that are hovered over will have their `hover`
957
+ * feature state property set to `true`. This can be referenced in map layer
958
+ * style expressions to apply hover effects.
959
+ *
960
+ * To enable hover support for a specific map data source, use the {@link enableHover} method.
961
+ * This method accepts a {@link HoverOptions} object that can be used to configure hover behavior
962
+ * and add a hover popup.
963
+ *
964
+ * :::warning
965
+ * This plugin supersedes the deprecated {@link HoverEffectPlugin}. To preserve the
966
+ * behavior of the {@link HoverEffectPlugin}, the {@link HoverPlugin} initially operates
967
+ * in 'compatibility mode' and implicitly enables hover for **all** map data sources.
968
+ * The first call to {@link enableHover} will disable compatibility mode and hover effects
969
+ * for other data sources must be explicitly enabled.
970
+ * :::
971
+ *
972
+ * ## Hover Popups
973
+ *
974
+ * This plugin can automatically display a popup when a feature is hovered over.
975
+ * The popup specified (if any) should be previously registered with the map data source
976
+ * using the {@link PopupPlugin}.
977
+ *
978
+ * Hover popups should be designed to be non-intrusive, as they will appear
979
+ * and disappear frequently as the user moves the mouse over the map. They should be
980
+ * configured with `closeButton: false` and not support any other user interaction.
981
+ * If `trackFeature` is enabled when registering the popup, the popup will snap to the
982
+ * feature centroid. If `trackFeature` is not enabled, the popup will move with the mouse
983
+ * cursor. For point-type features, it is recommended to enable `trackFeature` for a
984
+ * cleaner user experience. For polygon and line features, it is recommended to set
985
+ * `trackFeature` to `false` so that the popup follows the mouse cursor.
986
+ *
987
+ * This plugin interacts with the {@link SelectionPlugin} (if used) to coordinate display
988
+ * of hover and selection popups. A selection popup will take precedence over
989
+ * a hover popup when both are applicable ensuring that hover popups do not obscure
990
+ * selection popups.
991
+ *
992
+ * @noInheritDoc
993
+ *
994
+ * @example
995
+ * This map layer definition applies a hover effect using the `circleStrokeWidth` property:
996
+ ```js{7}
997
+ const circleLayer = new MapLayer({
998
+ id: "circle-layer",
999
+ type: "circle",
1000
+ source: "airquality",
1001
+ style: layerStyle("circle")
1002
+ .circleColor(expr(`@no2 ? from-palette('YlOrRd', @no2, 0, 100) : gray`))
1003
+ .circleStrokeWidth(expr("@@hover ? 5 : 0"))
1004
+ .circleRadius(expr(`@no2 ? @no2 / 5 : 5`))
1005
+ .build()
1006
+ });
1007
+
1008
+ // Register a popup to use on hover for the data source
1009
+ map.getPlugin(PopupPlugin).registerPopup('hoverPopup', {
1010
+ trackFeature: true,
1011
+ closeButton: false,
1012
+ content: (feature) =>
1013
+ html` Hover popup: ${feature?.id}`
1014
+ });
1015
+
1016
+ map.getPlugin(HoverPlugin).enableHover('airquality', {
1017
+ popup: 'hoverPopup'
1018
+ });
1019
+ ```
1020
+ *
1021
+ */
1022
+ declare class HoverPlugin extends MapPluginBase {
1023
+ private _sourceHovers;
1024
+ private _enablePopups;
1025
+ private _compatibilityMode;
1026
+ readonly name = "HoverPlugin";
1027
+ /**
1028
+ * Constructs a new HoverEffectPlugin instance. This is called automatically when the plugin is added to a {@link FlowCoreMap} instance
1029
+ * using {@link FlowCoreMap.usePlugin} method.
1030
+ *
1031
+ * @param pluginManager The plugin manager instance associated with the map
1032
+ */
1033
+ constructor(pluginManager: PluginManager);
1034
+ /**
1035
+ * Enable hover popup support for the specified map data source.
1036
+ *
1037
+ * @param source Map data source ID
1038
+ * @param options Selection options
1039
+ */
1040
+ enableHover(source: string, options?: HoverOptions): void;
1041
+ /**
1042
+ * Disable hover for the specified map data source.
1043
+ *
1044
+ * @param source Map data source ID
1045
+ */
1046
+ disableHover(source: string): void;
1047
+ /**
1048
+ * Enable display of popups when a feature is hovered and an associated popup has been registered with the map data source.
1049
+ * See {@link PopupPlugin} for more details of how to define and register popups.
1050
+ *
1051
+ * Note that popups are enabled by default.
1052
+ */
1053
+ enablePopups(): void;
1054
+ /**
1055
+ * Disable display of popups when a feature is hovered. This will also close any currently open popups.
1056
+ */
1057
+ disablePopups(): void;
1058
+ /** @internal MapPluginBase handler */
1059
+ handleMouseMove(event: MapMouseEvent): void;
1060
+ /** @internal MapPluginBase handler */
1061
+ handleClick(event: MapMouseEvent): void;
1062
+ /** @internal MapPluginBase handler */
1063
+ handleMouseOut(_event: MapEvent): void;
1064
+ /** @internal MapPluginBase handler */
1065
+ handleSetExclusivePlugin(exclusivePlugins: MapPluginBase[]): void;
1066
+ private clearHover;
1067
+ }
1068
+
943
1069
  /**
944
1070
  * @noInheritDoc
945
1071
  *
@@ -1016,4 +1142,4 @@ declare class PopupPlugin extends MapPluginBase {
1016
1142
  closePopupsForSources(sources: string | string[]): void;
1017
1143
  }
1018
1144
 
1019
- export { AnnotationEvent, type AnnotationEventData, type AnnotationEventType, type AnnotationEventTypes, type AnnotationFeature, type AnnotationFeatureProps, type AnnotationFeatureType, type AnnotationMode, type AnnotationOperation, AnnotationPlugin, type AnnotationPluginOptions, type AnnotationStyle, DataJoin, type DataJoinOptions, DataJoinPlugin, type DrawOverlayCallback, type DrawOverlayFn, ExportPlugin, type ExportPluginOptions, type FlowMapExportOptions, HoverEffectPlugin, MapPluginBase, PluginManager, PopupPlugin, SelectionEvent, type SelectionEventType, type SelectionEventTypes, type SelectionMode, type SelectionOptions, SelectionPlugin };
1145
+ export { AnnotationEvent, type AnnotationEventData, type AnnotationEventType, type AnnotationEventTypes, type AnnotationFeature, type AnnotationFeatureProps, type AnnotationFeatureType, type AnnotationMode, type AnnotationOperation, AnnotationPlugin, type AnnotationPluginOptions, type AnnotationStyle, DataJoin, type DataJoinOptions, DataJoinPlugin, type DrawOverlayCallback, type DrawOverlayFn, ExportPlugin, type ExportPluginOptions, type FlowMapExportOptions, HoverEffectPlugin, type HoverOptions, HoverPlugin, MapPluginBase, PluginManager, PopupPlugin, SelectionEvent, type SelectionEventType, type SelectionEventTypes, type SelectionMode, type SelectionOptions, SelectionPlugin };
@@ -3,6 +3,7 @@ export { AnnotationPlugin } from './annotations/annotation.plugin.mjs';
3
3
  export { DataJoin, DataJoinPlugin } from './data-join.plugin.mjs';
4
4
  export { ExportPlugin } from './export/export.plugin.mjs';
5
5
  export { HoverEffectPlugin } from './hover-effect.plugin.mjs';
6
+ export { HoverPlugin } from './hover/hover.plugin.mjs';
6
7
  export { MapPluginBase } from './map-plugin-base.mjs';
7
8
  export { PluginManager } from './plugin-manager.mjs';
8
9
  export { PopupPlugin } from './popup.plugin.mjs';
@@ -202,6 +202,13 @@ class SelectionPlugin extends MapPluginBase {
202
202
  this._enablePopups = false;
203
203
  }
204
204
  }
205
+ featureHasPopup(source, featureId) {
206
+ const sourceSelection = this._sourceSelections.get(source);
207
+ if (!sourceSelection) {
208
+ return false;
209
+ }
210
+ return sourceSelection.featureHasPopup(featureId);
211
+ }
205
212
  }
206
213
 
207
214
  export { SelectionPlugin };
@@ -153,6 +153,9 @@ class SourceSelection {
153
153
  }
154
154
  this.showPendingPopups();
155
155
  }
156
+ featureHasPopup(featureId) {
157
+ return this._popups.has(featureId);
158
+ }
156
159
  areSetsEqual(a, b) {
157
160
  return a.size === b.size && [...a].every((value) => b.has(value));
158
161
  }
@@ -50,6 +50,12 @@ class MapPopup extends EventEmitter {
50
50
  get feature() {
51
51
  return this._feature;
52
52
  }
53
+ set feature(feature) {
54
+ this._feature = feature;
55
+ if (this._featureStream) {
56
+ this._featureStream.featureIds = feature ? [feature.id] : [];
57
+ }
58
+ }
53
59
  /**
54
60
  * Close the popup.
55
61
  */
@@ -102,7 +108,7 @@ class MapPopup extends EventEmitter {
102
108
  this._featureStreamDisposer = this.map.context.state.autorun(() => {
103
109
  const data = this._featureStream?.featureData;
104
110
  if (data) {
105
- this.handleFeatureUpdate(data[feature.id]);
111
+ this.handleFeatureUpdate(data[this._feature.id]);
106
112
  }
107
113
  });
108
114
  } else {
@@ -1,3 +1,3 @@
1
- const version = "4.0.15";
1
+ const version = "4.0.16";
2
2
 
3
3
  export { version };
@@ -3242,6 +3242,7 @@ declare class MapPopup extends EventEmitter$1<MapPopupEvents> {
3242
3242
  * Get the map feature associated with the popup.
3243
3243
  */
3244
3244
  get feature(): MapFeatureIdentifier | undefined;
3245
+ set feature(feature: MapFeatureIdentifier | undefined);
3245
3246
  /**
3246
3247
  * Close the popup.
3247
3248
  */
@@ -3242,6 +3242,7 @@ declare class MapPopup extends EventEmitter$1<MapPopupEvents> {
3242
3242
  * Get the map feature associated with the popup.
3243
3243
  */
3244
3244
  get feature(): MapFeatureIdentifier | undefined;
3245
+ set feature(feature: MapFeatureIdentifier | undefined);
3245
3246
  /**
3246
3247
  * Close the popup.
3247
3248
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emuanalytics/flow-rdf-core",
3
- "version": "4.0.15",
3
+ "version": "4.0.16",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "type": "module",