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

visgl / deck.gl / 21416546016

27 Jan 2026 10:23PM UTC coverage: 91.118% (+0.02%) from 91.101%
21416546016

Pull #9963

github

web-flow
Merge 61466c357 into 914c3d2c2
Pull Request #9963: feat(mapbox): Add widget support to MapboxOverlay via IControl adapter

6874 of 7552 branches covered (91.02%)

Branch coverage included in aggregate %.

128 of 132 new or added lines in 2 files covered. (96.97%)

37 existing lines in 1 file now uncovered.

56927 of 62468 relevant lines covered (91.13%)

14363.35 hits per line

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

94.05
/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✔
29
    this._widget = widget;
6✔
30
  }
6✔
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✔
38
    this._container = document.createElement('div');
6✔
39
    this._container.className = 'maplibregl-ctrl mapboxgl-ctrl deck-widget-ctrl';
6✔
40

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

6✔
45
    return this._container;
6✔
46
  }
6✔
47

1✔
48
  /**
1✔
49
   * Called when the control is removed from the map.
1✔
50
   */
1✔
51
  onRemove(): void {
1✔
52
    // Clear the _container reference so widget doesn't try to append there
6✔
53
    if (this._widget.props._container === this._container) {
6✔
54
      this._widget.props._container = null;
6✔
55
    }
6✔
56
    this._container?.remove();
6✔
57
    this._container = null;
6✔
58
  }
6✔
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✔
66
    const placement = this._widget.placement;
6✔
67
    // 'fill' is not a valid Mapbox control position
6✔
68
    if (!placement || placement === 'fill') {
6!
NEW
69
      return 'top-left';
×
NEW
70
    }
×
71
    return placement;
6✔
72
  }
6✔
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