<MapboxSource>

Gitlab
A component for adding and managing data sources in a Mapbox map.
Added since: v0.1.0
Last changed:
This is generally only needed if you want to use custom layers.

Usage

MapboxSource is a component that allows you to add and manage data sources in your Mapbox map. It supports various source types including GeoJSON, Vector Tiles, Raster Tiles, and Image sources. The component handles source lifecycle management, including adding, updating, and removing sources.

Basic example

MapComponent.vue
<template>
  <MapboxMap>
    <MapboxSource
      id="my-source"
      :source="{
        type: 'geojson',
        data: {
          type: 'FeatureCollection',
          features: [...]
        }
      }"
    />
  </MapboxMap>
</template>

Type Definition

type 
MapboxSourceProps
= {
/** * Id of the source * @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#instance-members-sources|Mapbox GL Docs - Sources} */
id
: string;
/** * Source specification * @defaultValue {} * @see {@link SourceSpecification|SourceSpecification} * @see {@link https://docs.mapbox.com/mapbox-gl-js/api/sources/#source-specification|Mapbox GL Docs - Source Specification} */
source
:
SourceSpecification
;
/** * Options for the source * * Needs implementation * @defaultValue {} * @see {@link GeoJSONSourceSpecification|GeoJSONSourceSpecification} * @see {@link https://docs.mapbox.com/mapbox-gl-js/api/sources/#source-options|Mapbox GL Docs - Source Options} */
options
?:
GeoJSONSourceSpecification
;
};

API Reference

Props

PropDefaultType
id*
string

Unique identifier for the source

See MapboxGL Instance members - sources for more information.

source*
SourceSpecification

Source specification object that defines the source type and data

See MapboxGL Source specification for more information.
Or see the Source Types section for more information.

options
{}GeoJSONSourceSpecification

Additional options for GeoJSON sources

! Not Yet Implemented

Slots

SlotPayload
default

Content to render inside the source

Source Types

The component supports the following source types:

GeoJSON Source

Used for GeoJSON data
Supports dynamic data updates
Example.json
{
    "type": "geojson",
    "data": {
        "type": "FeatureCollection",
        "features": [...]
    }
}

Vector Tile Source

Used for vector tile data
Supports URL or tiles array
Example.json
{
    "type": "vector",
    "url": "mapbox://mapbox.mapbox-streets-v8"
}

Raster Tile Source

Used for raster tile data
Supports URL or tiles array
Example.json
{
    "type": "raster",
    "url": "mapbox://mapbox.satellite"
}

Image Source

Used for single image overlays
Requires URL and coordinates
Example.json
{
    "type": "image",
    "url": "https://example.com/image.png",
    "coordinates": [
        [-76.54, 39.18],
        [-76.52, 39.18],
        [-76.52, 39.17],
        [-76.54, 39.17]
    ]
}

Changelog

v0.2.3

on

#ebea626c

-

improvement: added full typescript support