Function applyBackground

  • Applies properties of the Mapbox/MapLibre Style's first background layer to the provided map or layer (group).

    Example:

    import {applyBackground} from 'ol-mapbox-style';
    import {Map} from 'ol';

    const map = new Map({target: 'map'});
    applyBackground(map, 'https://api.maptiler.com/maps/basic/style.json?key=YOUR_OPENMAPTILES_TOKEN');

    Parameters

    • mapOrLayer: Map | BaseLayer

      OpenLayers Map or layer (group).

    • glStyle: any

      Mapbox/MapLibre Style object or url.

    • options: Options = {}

      Options.

    Returns Promise<any>

    Promise that resolves when the background is applied.