Join us online - 19th of November
Save your spot
For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Class defaultMaptiler

Interface for interactive controls added to the map. This is a specification for implementers to model: it is not an exported method or class.

Controls must implement onAdd and onRemove, and must own an element, which is often a div element. To use MapLibre GL JS's default control styling, add the maplibregl-ctrl class to your control's node.

class HelloWorldControl: IControl {
    onAdd(map) {
        this._map = map;
        this._container = document.createElement('div');
        this._container.className = 'maplibregl-ctrl';
        this._container.textContent = 'Hello, world';
        return this._container;
    }

    onRemove() {
        this._container.remove();
        this._map = undefined;
    }
}

Implements

Index
map: Map
  • Parameters

    • layer:
          | CustomLayerInterface
          | (
              LayerSpecification & { source?: string | SourceSpecification | undefined; }
          )
    • OptionalbeforeId: string

    Returns Map

  • Parameters

    • id: string
    • OptionalbeforeId: string

    Returns Map

  • Register a control on the map and give it a chance to register event listeners and resources. This method is called by Map.addControl internally.

    Parameters

    • parentMap: Map

    Returns HTMLElement

    The control's container element. This should be created by the control and returned by onAdd without being attached to the DOM: the map will insert the control's element into the DOM as necessary.

  • Unregister a control on the map and give it a chance to detach event listeners and resources. This method is called by Map.removeControl internally.

    Returns void

  • Parameters

    • id: string

    Returns this

  • Parameters

    • layerId: string
    • minzoom: number
    • maxzoom: number

    Returns this

  • Parameters

    Returns this

  • Parameters

    Returns this

Was this helpful?