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

visgl / deck.gl / 21338288234

25 Jan 2026 07:30PM UTC coverage: 91.062% (-0.05%) from 91.114%
21338288234

Pull #9963

github

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

6878 of 7559 branches covered (90.99%)

Branch coverage included in aggregate %.

88 of 132 new or added lines in 2 files covered. (66.67%)

41 existing lines in 1 file now uncovered.

56949 of 62533 relevant lines covered (91.07%)

14349.81 hits per line

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

65.82
/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
 * Used internally by MapboxOverlay for widgets with `viewId: 'mapbox'`.
1✔
15
 * Can also be used directly for more control over widget positioning.
1✔
16
 *
1✔
17
 * @example
1✔
18
 * ```typescript
1✔
19
 * const zoomWidget = new ZoomWidget({placement: 'top-right'});
1✔
20
 * const control = new DeckWidgetControl(zoomWidget);
1✔
21
 * map.addControl(control, 'top-right');
1✔
22
 * ```
1✔
23
 */
1✔
24
export class DeckWidgetControl implements IControl {
1✔
25
  private _widget: Widget;
1✔
26
  private _container: HTMLDivElement | null = null;
1✔
27

1✔
28
  constructor(widget: Widget) {
1✔
NEW
29
    this._widget = widget;
×
NEW
30
  }
×
31

1✔
32
  /**
1✔
33
   * Called when the control is added to the map.
1✔
34
   * Creates a container element that will be positioned by Mapbox/MapLibre,
1✔
35
   * and sets the widget's _container prop so WidgetManager appends the widget here.
1✔
36
   */
1✔
37
  onAdd(map: Map): HTMLElement {
1✔
NEW
38
    this._container = document.createElement('div');
×
NEW
39
    this._container.className = 'maplibregl-ctrl mapboxgl-ctrl deck-widget-ctrl';
×
NEW
40

×
NEW
41
    // Set _container so WidgetManager appends the widget's rootElement here
×
NEW
42
    // instead of in its own overlay container
×
NEW
43
    this._widget.props._container = this._container;
×
NEW
44

×
NEW
45
    return this._container;
×
NEW
46
  }
×
47

1✔
48
  /**
1✔
49
   * Called when the control is removed from the map.
1✔
50
   */
1✔
51
  onRemove(): void {
1✔
NEW
52
    // Clear the _container reference so widget doesn't try to append there
×
NEW
53
    if (this._widget.props._container === this._container) {
×
NEW
54
      this._widget.props._container = null;
×
NEW
55
    }
×
NEW
56
    this._container?.remove();
×
NEW
57
    this._container = null;
×
NEW
58
  }
×
59

1✔
60
  /**
1✔
61
   * Returns the default position for this control.
1✔
62
   * Uses the widget's placement, which conveniently matches Mapbox control positions.
1✔
63
   * Note: 'fill' placement is not supported by Mapbox controls, defaults to 'top-left'.
1✔
64
   */
1✔
65
  getDefaultPosition(): ControlPosition {
1✔
NEW
66
    const placement = this._widget.placement;
×
NEW
67
    // 'fill' is not a valid Mapbox control position
×
NEW
68
    if (!placement || placement === 'fill') {
×
NEW
69
      return 'top-left';
×
NEW
70
    }
×
NEW
71
    return placement;
×
NEW
72
  }
×
73

1✔
74
  /** Returns the wrapped widget */
1✔
75
  get widget(): Widget {
1✔
NEW
76
    return this._widget;
×
NEW
77
  }
×
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