• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / deck.gl / 22867726651

09 Mar 2026 06:06PM UTC coverage: 91.028% (+0.02%) from 91.011%
22867726651

Pull #9963

github

web-flow
Merge e793c904d into aee311f24
Pull Request #9963: feat(mapbox): Add widget support to MapboxOverlay via IControl adapter

6972 of 7687 branches covered (90.7%)

Branch coverage included in aggregate %.

153 of 159 new or added lines in 2 files covered. (96.23%)

2 existing lines in 1 file now uncovered.

57456 of 63091 relevant lines covered (91.07%)

14224.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.51
/modules/mapbox/src/deck-widget-control.ts
1
// deck.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4

1✔
5
import type {Widget} from '@deck.gl/core';
1✔
6
import type {IControl, ControlPosition, Map} from './types';
1✔
7

1✔
8
/**
1✔
9
 * Wraps a deck.gl Widget as a Mapbox/MapLibre IControl.
1✔
10
 *
1✔
11
 * This enables deck widgets to be positioned alongside native map controls
1✔
12
 * in the same DOM container, preventing overlap issues.
1✔
13
 *
1✔
14
 * @internal Used by MapboxOverlay for widgets with `viewId: 'mapbox'`.
1✔
15
 */
1✔
16
export class DeckWidgetControl implements IControl {
1✔
17
  private _widget: Widget;
1✔
18
  private _container: HTMLDivElement | null = null;
1✔
19

1✔
20
  constructor(widget: Widget) {
1✔
21
    this._widget = widget;
8✔
22
  }
8✔
23

1✔
24
  /**
1✔
25
   * Called when the control is added to the map.
1✔
26
   * Creates a container element that will be positioned by Mapbox/MapLibre,
1✔
27
   * and sets the widget's _container prop so WidgetManager appends the widget here.
1✔
28
   */
1✔
29
  onAdd(map: Map): HTMLElement {
1✔
30
    this._container = document.createElement('div');
8✔
31
    this._container.className = 'maplibregl-ctrl mapboxgl-ctrl deck-widget-ctrl';
8✔
32

8✔
33
    // Set _container so WidgetManager appends the widget's rootElement here
8✔
34
    // instead of in its own overlay container
8✔
35
    this._widget.props._container = this._container;
8✔
36

8✔
37
    return this._container;
8✔
38
  }
8✔
39

1✔
40
  /**
1✔
41
   * Called when the control is removed from the map.
1✔
42
   */
1✔
43
  onRemove(): void {
1✔
44
    // Clear the _container reference so widget doesn't try to append there
8✔
45
    if (this._widget.props._container === this._container) {
8✔
46
      this._widget.props._container = null;
8✔
47
    }
8✔
48
    this._container?.remove();
8✔
49
    this._container = null;
8✔
50
  }
8✔
51

1✔
52
  /**
1✔
53
   * Returns the default position for this control.
1✔
54
   * Uses the widget's placement, which conveniently matches Mapbox control positions.
1✔
55
   * Note: 'fill' placement is not supported by Mapbox controls, defaults to 'top-left'.
1✔
56
   */
1✔
57
  getDefaultPosition(): ControlPosition {
1✔
58
    const placement = this._widget.placement;
8✔
59
    // 'fill' is not a valid Mapbox control position
8✔
60
    if (!placement || placement === 'fill') {
8!
NEW
61
      return 'top-left';
×
NEW
62
    }
×
63
    return placement;
8✔
64
  }
8✔
65

1✔
66
  /** Returns the wrapped widget */
1✔
67
  get widget(): Widget {
1✔
68
    return this._widget;
8✔
69
  }
8✔
70

1✔
71
  /**
1✔
72
   * Updates the wrapped widget reference.
1✔
73
   * Used when reusing this control for a new widget instance with the same id.
1✔
74
   */
1✔
75
  setWidget(widget: Widget): void {
1✔
76
    this._widget = widget;
2✔
77
  }
2✔
78
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc