On this page

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

Constructors

Properties

map: Map

Methods

  • 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

    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?
SDK JS
Reference
default