@sjvair/monitor-map 3.5.1 → 3.6.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.
@@ -2,6 +2,14 @@ import type { MapLayerEventType, Popup } from "@maptiler/sdk";
2
2
  export type TooltipBuilder = (evt: MapLayerEventType["mousemove"] & object) => Popup | void;
3
3
  export declare class TooltipManager {
4
4
  static activeHandle: TooltipHandle | null;
5
+ /**
6
+ * Host-controlled master switch. When false, enable() is a no-op
7
+ * regardless of how many times or when internal code (e.g. a map
8
+ * integration's apply()) calls it -- unlike isEnabled below, this is
9
+ * checked fresh on every enable() call, so it can't be raced by an
10
+ * apply() invocation that fires before a host sets this to false.
11
+ */
12
+ enabled: boolean;
5
13
  private isEnabled;
6
14
  private _tooltips;
7
15
  get tooltips(): MapIterator<TooltipHandle>;
@@ -11,13 +11,21 @@ function setCursorDefault() {
11
11
  }
12
12
  export class TooltipManager {
13
13
  static activeHandle = null;
14
+ /**
15
+ * Host-controlled master switch. When false, enable() is a no-op
16
+ * regardless of how many times or when internal code (e.g. a map
17
+ * integration's apply()) calls it -- unlike isEnabled below, this is
18
+ * checked fresh on every enable() call, so it can't be raced by an
19
+ * apply() invocation that fires before a host sets this to false.
20
+ */
21
+ enabled = true;
14
22
  isEnabled = false;
15
23
  _tooltips = new XMap();
16
24
  get tooltips() {
17
25
  return this._tooltips.values();
18
26
  }
19
27
  enable(layerId) {
20
- if (!mapManager.map || this.isEnabled)
28
+ if (!this.enabled || !mapManager.map || this.isEnabled)
21
29
  return;
22
30
  mapManager.map.on("zoom", handleZoom);
23
31
  this.forEachHandle(layerId, (h) => h.enable());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sjvair/monitor-map",
3
3
  "description": "SJVAir's interactive monitor map",
4
- "version": "3.5.1",
4
+ "version": "3.6.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SJVAir/monitor-map"
@@ -19,6 +19,15 @@ function setCursorDefault() {
19
19
  export class TooltipManager {
20
20
  static activeHandle: TooltipHandle | null = null;
21
21
 
22
+ /**
23
+ * Host-controlled master switch. When false, enable() is a no-op
24
+ * regardless of how many times or when internal code (e.g. a map
25
+ * integration's apply()) calls it -- unlike isEnabled below, this is
26
+ * checked fresh on every enable() call, so it can't be raced by an
27
+ * apply() invocation that fires before a host sets this to false.
28
+ */
29
+ enabled: boolean = true;
30
+
22
31
  private isEnabled: boolean = false;
23
32
  private _tooltips: XMap<string, TooltipHandle> = new XMap();
24
33
 
@@ -27,7 +36,7 @@ export class TooltipManager {
27
36
  }
28
37
 
29
38
  enable(layerId?: string) {
30
- if (!mapManager.map || this.isEnabled) return;
39
+ if (!this.enabled || !mapManager.map || this.isEnabled) return;
31
40
  mapManager.map.on("zoom", handleZoom);
32
41
  this.forEachHandle(layerId, (h) => h.enable());
33
42
  this.isEnabled = true;