1 class CombinedControlGroup {
2 constructor(controls) {
3 // array of MapLibre controls
4 this.controls = controls;
5 // DOM containers returned by onAdd()
10 this._container = document.createElement("div");
11 this._container.className = "maplibregl-ctrl maplibregl-ctrl-group";
13 for (const ctrl of this.controls) {
14 const ctrlContainer = ctrl.onAdd(map);
15 this.containers.push(ctrlContainer);
17 // Extract buttons from the control's container and add to our wrapper
18 const buttons = ctrlContainer.querySelectorAll("button");
19 buttons.forEach(button => {
20 this._container.appendChild(button);
24 return this._container;
28 for (const ctrl of this.controls) ctrl.onRemove?.();
30 if (this._container) this._container.remove();
34 OSM.CombinedControlGroup = CombinedControlGroup;