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.
<template>
<MapboxMap>
<MapboxSource
id="my-source"
:source="{
type: 'geojson',
data: {
type: 'FeatureCollection',
features: [...]
}
}"
/>
</MapboxMap>
</template>
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;
};
| Prop | Default | Type |
|---|---|---|
id* | stringUnique identifier for the source See MapboxGL Instance members - sources for more information. | |
source* | SourceSpecificationSource specification object that defines the source type and data See MapboxGL Source specification for more information. | |
options | {} | GeoJSONSourceSpecificationAdditional options for GeoJSON sources ! Not Yet Implemented |
| Slot | Payload |
|---|---|
default | Content to render inside the source |
The component supports the following source types:
{
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [...]
}
}
{
"type": "vector",
"url": "mapbox://mapbox.mapbox-streets-v8"
}
{
"type": "raster",
"url": "mapbox://mapbox.satellite"
}
{
"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]
]
}