ol-mapbox-style
    Preparing search index...

    Class MapboxVectorLayer

    import {MapboxVectorLayer} from 'ol-mapbox-style';
    

    A vector tile layer based on a Mapbox/MapLibre style that uses a single vector source. Configure the layer with the styleUrl and accessToken shown in Mapbox Studio's share panel. If the style uses more than one source, use the source property to choose a single vector source. If you want to render a subset of the layers in the style, use the layers property (all layers must share the same vector source). See the constructor options for more detail.

    const map = new Map({
      view: new View({
        center: [0, 0],
        zoom: 1,
      }),
      layers: [
        new MapboxVectorLayer({
          styleUrl: 'mapbox://styles/mapbox/bright-v9',
          accessToken: 'your-mapbox-access-token-here',
        }),
      ],
      target: 'map',
    });
    

    On configuration or loading error, the layer will trigger an 'error' event. Listeners will receive an object with an error property that can be used to diagnose the problem.

    Instances of this class emit an error event when an error occurs during style loading:

    layer.on('error', function() {
      console.error('Error loading style');
    }
    

    Note for users of the full build: The MapboxVectorLayer requires the ol-mapbox-style library to be loaded as well.

    Options.

    Hierarchy

    • VectorTileLayer
      • MapboxVectorLayer
    Index

    Constructors

    Properties

    Constructors

    Properties

    accessToken: string