MapboxMap is a Vue component that provides a declarative way to create and manage interactive maps using Mapbox GL JS. It handles map initialization, viewport management, and provides a context for child components to interact with the map instance.
A basic example of how to use the MapboxMap component with a supercluster component to render markers and clusters.
<script setup lang="ts">
const mapboxMap = ref();
const features = ref([{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [-74.5, 40]
},
properties: {
ROAD_NAME: 'Example Road'
}
}]);
// Access map instance
onMounted(() => {
// Example: Focus on features after a delay
setTimeout(() => {
mapboxMap.value?.focusFeatures(features.value);
}, 2000);
});
</script>
<template>
<section class="h-120 relative overflow-hidden">
<MapboxMap
ref="mapboxMap"
:features="features"
:initialize-with="{
padding: {
top: 100,
right: 100,
bottom: 100,
left: 100,
},
}"
>
<!-- Feature clustering -->
<MapboxSupercluster>
<!-- Individual markers -->
<template #marker="ctx">
<MapboxMarker
:id="ctx.id"
:feature="ctx.feature"
class="size-10 bg-[cyan] rounded-full"
>
{{ ctx.feature.properties.ROAD_NAME }}
</MapboxMarker>
</template>
<!-- Cluster markers -->
<template #cluster="ctx">
<MapboxClusterMarker
:id="ctx.id"
:feature="ctx.feature"
class="flex items-center justify-center rounded-full size-10 bg-black text-bold text-white"
/>
</template>
</MapboxSupercluster>
<!-- Location marker -->
<template #location="ctx">
<MapboxMarker
:id="ctx.id"
:feature="ctx.feature"
class="size-10 bg-[cyan] rounded-full"
>
Location
</MapboxMarker>
</template>
</MapboxMap>
</section>
</template>
type MapboxMapProps = {
/**
* The options to initialize the map with.
* @see {@link MapOptions}
*/
initializeWith?: Omit<MapOptions & {
/**
* The bounds to initialize the map with.
* @see {@link LngLatBounds}
*/
bounds?: LngLatBounds;
/**
* The padding to apply to the map.
*/
padding?: { left: number; top: number; right: number; bottom: number };
}, "container">;
/**
* The point and cluster features to display on the map.
* @see {@link PointFeature|PointFeature}
* @see {@link ClusterFeature|ClusterFeature}
*/
features?: Array<PointFeature<any> | ClusterFeature<any>>;
/**
* A single point to display on the map.
*
* _(Coordinates are in [longitude, latitude] format)_
* @see {@link Position}
*/
location?: Position;
} & MapboxMapEvents;
type MapboxMapContext = {
/**
* The Mapbox GL map instance.
* @see {@link Map}
*/
map: Ref<Map | null | undefined>;
/**
* The features to display on the map.
* @see {@link PointFeature|PointFeature}
* @see {@link ClusterFeature|ClusterFeature}
*/
features: Ref<Array<PointFeature<any> | ClusterFeature<any>>>;
/**
* The viewport of the map.
* @see {@link MapboxViewport}
*/
viewport: Ref<MapboxViewport>;
};
type MapboxMapEvents = {
/**
* Event handler for the `boxzoomcancel` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:boxzoomcancel|Mapbox GL Docs - boxzoomcancel event}
*/
onBoxzoomcancel?: (event: MapEventOf<"boxzoomcancel">) => void;
/**
* Event handler for the `boxzoomend` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:boxzoomend|Mapbox GL Docs - boxzoomend event}
*/
onBoxzoomend?: (event: MapEventOf<"boxzoomend">) => void;
/**
* Event handler for the `boxzoomstart` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:boxzoomstart|Mapbox GL Docs - boxzoomstart event}
*/
onBoxzoomstart?: (event: MapEventOf<"boxzoomstart">) => void;
/**
* Event handler for the `click` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:click|Mapbox GL Docs - click event}
*/
onClick?: (event: MapEventOf<"click">) => void;
/**
* Event handler for the `contextmenu` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:contextmenu|Mapbox GL Docs - contextmenu event}
*/
onContextmenu?: (event: MapEventOf<"contextmenu">) => void;
/**
* Event handler for the `data` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:data|Mapbox GL Docs - data event}
*/
onData?: (event: MapEventOf<"data">) => void;
/**
* Event handler for the `dataloading` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:dataloading|Mapbox GL Docs - dataloading event}
*/
onDataloading?: (event: MapEventOf<"dataloading">) => void;
/**
* Event handler for the `dblclick` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:dblclick|Mapbox GL Docs - dblclick event}
*/
onDblclick?: (event: MapEventOf<"dblclick">) => void;
/**
* Event handler for the `drag` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:drag|Mapbox GL Docs - drag event}
*/
onDrag?: (event: MapEventOf<"drag">) => void;
/**
* Event handler for the `dragend` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:dragend|Mapbox GL Docs - dragend event}
*/
onDragend?: (event: MapEventOf<"dragend">) => void;
/**
* Event handler for the `dragstart` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:dragstart|Mapbox GL Docs - dragstart event}
*/
onDragstart?: (event: MapEventOf<"dragstart">) => void;
/**
* Event handler for the `error` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:error|Mapbox GL Docs - error event}
*/
onError?: (event: MapEventOf<"error">) => void;
/**
* Event handler for the `idle` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:idle|Mapbox GL Docs - idle event}
*/
onIdle?: (event: MapEventOf<"idle">) => void;
/**
* Event handler for the `load` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:load|Mapbox GL Docs - load event}
*/
onLoad?: (event: MapEventOf<"load">) => void;
/**
* Event handler for the `mousedown` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:mousedown|Mapbox GL Docs - mousedown event}
*/
onMousedown?: (event: MapEventOf<"mousedown">) => void;
/**
* Event handler for the `mouseenter` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:mouseenter|Mapbox GL Docs - mouseenter event}
*/
onMouseenter?: (event: MapEventOf<"mouseenter">) => void;
/**
* Event handler for the `mouseleave` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:mouseleave|Mapbox GL Docs - mouseleave event}
*/
onMouseleave?: (event: MapEventOf<"mouseleave">) => void;
/**
* Event handler for the `mousemove` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:mousemove|Mapbox GL Docs - mousemove event}
*/
onMousemove?: (event: MapEventOf<"mousemove">) => void;
/**
* Event handler for the `mouseout` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:mouseout|Mapbox GL Docs - mouseout event}
*/
onMouseout?: (event: MapEventOf<"mouseout">) => void;
/**
* Event handler for the `mouseover` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:mouseover|Mapbox GL Docs - mouseover event}
*/
onMouseover?: (event: MapEventOf<"mouseover">) => void;
/**
* Event handler for the `mouseup` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:mouseup|Mapbox GL Docs - mouseup event}
*/
onMouseup?: (event: MapEventOf<"mouseup">) => void;
/**
* Event handler for the `move` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:move|Mapbox GL Docs - move event}
*/
onMove?: (event: MapEventOf<"move">) => void;
/**
* Event handler for the `moveend` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:moveend|Mapbox GL Docs - moveend event}
*/
onMoveend?: (event: MapEventOf<"moveend">) => void;
/**
* Event handler for the `movestart` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:movestart|Mapbox GL Docs - movestart event}
*/
onMovestart?: (event: MapEventOf<"movestart">) => void;
/**
* Event handler for the `pitch` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:pitch|Mapbox GL Docs - pitch event}
*/
onPitch?: (event: MapEventOf<"pitch">) => void;
/**
* Event handler for the `pitchend` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:pitchend|Mapbox GL Docs - pitchend event}
*/
onPitchend?: (event: MapEventOf<"pitchend">) => void;
/**
* Event handler for the `pitchstart` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:pitchstart|Mapbox GL Docs - pitchstart event}
*/
onPitchstart?: (event: MapEventOf<"pitchstart">) => void;
/**
* Event handler for the `preclick` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:preclick|Mapbox GL Docs - preclick event}
*/
onPreclick?: (event: MapEventOf<"preclick">) => void;
/**
* Event handler for the `remove` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:remove|Mapbox GL Docs - remove event}
*/
onRemove?: (event: MapEventOf<"remove">) => void;
/**
* Event handler for the `render` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:render|Mapbox GL Docs - render event}
*/
onRender?: (event: MapEventOf<"render">) => void;
/**
* Event handler for the `renderstart` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:renderstart|Mapbox GL Docs - renderstart event}
*/
onRenderstart?: (event: MapEventOf<"renderstart">) => void;
/**
* Event handler for the `resize` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:resize|Mapbox GL Docs - resize event}
*/
onResize?: (event: MapEventOf<"resize">) => void;
/**
* Event handler for the `rotate` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:rotate|Mapbox GL Docs - rotate event}
*/
onRotate?: (event: MapEventOf<"rotate">) => void;
/**
* Event handler for the `rotateend` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:rotateend|Mapbox GL Docs - rotateend event}
*/
onRotateend?: (event: MapEventOf<"rotateend">) => void;
/**
* Event handler for the `rotatestart` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:rotatestart|Mapbox GL Docs - rotatestart event}
*/
onRotatestart?: (event: MapEventOf<"rotatestart">) => void;
/**
* Event handler for the `sourcedata` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:sourcedata|Mapbox GL Docs - sourcedata event}
*/
onSourcedata?: (event: MapEventOf<"sourcedata">) => void;
/**
* Event handler for the `sourcedataloading` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:sourcedataloading|Mapbox GL Docs - sourcedataloading event}
*/
onSourcedataloading?: (event: MapEventOf<"sourcedataloading">) => void;
/**
* Event handler for the `styledata` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:styledata|Mapbox GL Docs - styledata event}
*/
onStyledata?: (event: MapEventOf<"styledata">) => void;
/**
* Event handler for the `styledataloading` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:styledataloading|Mapbox GL Docs - styledataloading event}
*/
onStyledataloading?: (event: MapEventOf<"styledataloading">) => void;
/**
* Event handler for the `styleimagemissing` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:styleimagemissing|Mapbox GL Docs - styleimagemissing event}
*/
onStyleimagemissing?: (event: MapEventOf<"styleimagemissing">) => void;
/**
* Event handler for the `style.import.load` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:style.import.load|Mapbox GL Docs - style.import.load event}
*/
onStyleimportload?: (event: MapEventOf<"style.import.load">) => void;
/**
* Event handler for the `style.load` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:style.load|Mapbox GL Docs - style.load event}
*/
onStyleload?: (event: MapEventOf<"style.load">) => void;
/**
* Event handler for the `touchcancel` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:touchcancel|Mapbox GL Docs - touchcancel event}
*/
onTouchcancel?: (event: MapEventOf<"touchcancel">) => void;
/**
* Event handler for the `touchend` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:touchend|Mapbox GL Docs - touchend event}
*/
onTouchend?: (event: MapEventOf<"touchend">) => void;
/**
* Event handler for the `touchmove` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:touchmove|Mapbox GL Docs - touchmove event}
*/
onTouchmove?: (event: MapEventOf<"touchmove">) => void;
/**
* Event handler for the `touchstart` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:touchstart|Mapbox GL Docs - touchstart event}
*/
onTouchstart?: (event: MapEventOf<"touchstart">) => void;
/**
* Event handler for the `webglcontextlost` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:webglcontextlost|Mapbox GL Docs - webglcontextlost event}
*/
onWebglcontextlost?: (event: MapEventOf<"webglcontextlost">) => void;
/**
* Event handler for the `webglcontextrestored` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:webglcontextrestored|Mapbox GL Docs - webglcontextrestored event}
*/
onWebglcontextrestored?: (event: MapEventOf<"webglcontextrestored">) => void;
/**
* Event handler for the `wheel` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:wheel|Mapbox GL Docs - wheel event}
*/
onWheel?: (event: MapEventOf<"wheel">) => void;
/**
* Event handler for the `zoom` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:zoom|Mapbox GL Docs - zoom event}
*/
onZoom?: (event: MapEventOf<"zoom">) => void;
/**
* Event handler for the `zoomend` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:zoomend|Mapbox GL Docs - zoomend event}
*/
onZoomend?: (event: MapEventOf<"zoomend">) => void;
/**
* Event handler for the `zoomstart` event.
* @see {@link https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:zoomstart|Mapbox GL Docs - zoomstart event}
*/
onZoomstart?: (event: MapEventOf<"zoomstart">) => void;
/**
* @deprecated Use the `load` event instead.
*/
onLoaded?: (event: boolean) => void;
};
type MapboxMapEmits = {
boxzoomcancel: [event: MapEventOf<"boxzoomcancel">];
boxzoomend: [event: MapEventOf<"boxzoomend">];
boxzoomstart: [event: MapEventOf<"boxzoomstart">];
click: [event: MapEventOf<"click">];
contextmenu: [event: MapEventOf<"contextmenu">];
data: [event: MapEventOf<"data">];
dataloading: [event: MapEventOf<"dataloading">];
dblclick: [event: MapEventOf<"dblclick">];
drag: [event: MapEventOf<"drag">];
dragend: [event: MapEventOf<"dragend">];
dragstart: [event: MapEventOf<"dragstart">];
error: [event: MapEventOf<"error">];
idle: [event: MapEventOf<"idle">];
load: [event: MapEventOf<"load">];
mousedown: [event: MapEventOf<"mousedown">];
mouseenter: [event: MapEventOf<"mouseenter">];
mouseleave: [event: MapEventOf<"mouseleave">];
mousemove: [event: MapEventOf<"mousemove">];
mouseout: [event: MapEventOf<"mouseout">];
mouseover: [event: MapEventOf<"mouseover">];
mouseup: [event: MapEventOf<"mouseup">];
move: [event: MapEventOf<"move">];
moveend: [event: MapEventOf<"moveend">];
movestart: [event: MapEventOf<"movestart">];
pitch: [event: MapEventOf<"pitch">];
pitchend: [event: MapEventOf<"pitchend">];
pitchstart: [event: MapEventOf<"pitchstart">];
preclick: [event: MapEventOf<"preclick">];
remove: [event: MapEventOf<"remove">];
render: [event: MapEventOf<"render">];
renderstart: [event: MapEventOf<"renderstart">];
resize: [event: MapEventOf<"resize">];
rotate: [event: MapEventOf<"rotate">];
rotateend: [event: MapEventOf<"rotateend">];
rotatestart: [event: MapEventOf<"rotatestart">];
sourcedata: [event: MapEventOf<"sourcedata">];
sourcedataloading: [event: MapEventOf<"sourcedataloading">];
styledata: [event: MapEventOf<"styledata">];
styledataloading: [event: MapEventOf<"styledataloading">];
styleimagemissing: [event: MapEventOf<"styleimagemissing">];
styleimportload: [event: MapEventOf<"style.import.load">];
styleload: [event: MapEventOf<"style.load">];
touchcancel: [event: MapEventOf<"touchcancel">];
touchend: [event: MapEventOf<"touchend">];
touchmove: [event: MapEventOf<"touchmove">];
touchstart: [event: MapEventOf<"touchstart">];
webglcontextlost: [event: MapEventOf<"webglcontextlost">];
webglcontextrestored: [event: MapEventOf<"webglcontextrestored">];
wheel: [event: MapEventOf<"wheel">];
zoom: [event: MapEventOf<"zoom">];
zoomend: [event: MapEventOf<"zoomend">];
zoomstart: [event: MapEventOf<"zoomstart">];
/**
* @deprecated Use the `load` event instead.
*/
loaded: [event: boolean];
};
| Prop | Default | Type |
|---|---|---|
initializeWith | Omit<MapOptions & { bounds?: LngLatBounds; padding?: {left: number; top: number; right: number; bottom: number }; }, 'container'>The options to initialize the map with. | |
features | [] | Array<PointFeature<any> | ClusterFeature<any>> |
location | Position |
| Event | Payload |
|---|---|
loaded | (map: Map) => voidEmitted when the map is fully loaded and ready. |
boxzoomcancel | (event: MapEventOf<'boxzoomcancel'>) => voidEvent handler for the |
boxzoomend | (event: MapEventOf<'boxzoomend'>) => voidEvent handler for the |
boxzoomstart | (event: MapEventOf<'boxzoomstart'>) => voidEvent handler for the |
click | (event: MapEventOf<'click'>) => voidEvent handler for the |
contextmenu | (event: MapEventOf<'contextmenu'>) => voidEvent handler for the |
data | (event: MapEventOf<'data'>) => voidEvent handler for the |
dataloading | (event: MapEventOf<'dataloading'>) => voidEvent handler for the |
dblclick | (event: MapEventOf<'dblclick'>) => voidEvent handler for the |
drag | (event: MapEventOf<'drag'>) => voidEvent handler for the |
dragend | (event: MapEventOf<'dragend'>) => voidEvent handler for the |
dragstart | (event: MapEventOf<'dragstart'>) => voidEvent handler for the |
error | (event: MapEventOf<'error'>) => voidEvent handler for the |
idle | (event: MapEventOf<'idle'>) => voidEvent handler for the |
load | (event: MapEventOf<'load'>) => voidEvent handler for the |
mousedown | (event: MapEventOf<'mousedown'>) => voidEvent handler for the |
mouseenter | (event: MapEventOf<'mouseenter'>) => voidEvent handler for the |
mouseleave | (event: MapEventOf<'mouseleave'>) => voidEvent handler for the |
mousemove | (event: MapEventOf<'mousemove'>) => voidEvent handler for the |
mouseout | (event: MapEventOf<'mouseout'>) => voidEvent handler for the |
mouseover | (event: MapEventOf<'mouseover'>) => voidEvent handler for the |
mouseup | (event: MapEventOf<'mouseup'>) => voidEvent handler for the |
move | (event: MapEventOf<'move'>) => voidEvent handler for the |
moveend | (event: MapEventOf<'moveend'>) => voidEvent handler for the |
movestart | (event: MapEventOf<'movestart'>) => voidEvent handler for the |
pitch | (event: MapEventOf<'pitch'>) => voidEvent handler for the |
pitchend | (event: MapEventOf<'pitchend'>) => voidEvent handler for the |
pitchstart | (event: MapEventOf<'pitchstart'>) => voidEvent handler for the |
preclick | (event: MapEventOf<'preclick'>) => voidEvent handler for the |
remove | (event: MapEventOf<'remove'>) => voidEvent handler for the |
render | (event: MapEventOf<'render'>) => voidEvent handler for the |
renderstart | (event: MapEventOf<'renderstart'>) => voidEvent handler for the |
resize | (event: MapEventOf<'resize'>) => voidEvent handler for the |
rotate | (event: MapEventOf<'rotate'>) => voidEvent handler for the |
rotateend | (event: MapEventOf<'rotateend'>) => voidEvent handler for the |
rotatestart | (event: MapEventOf<'rotatestart'>) => voidEvent handler for the |
sourcedata | (event: MapEventOf<'sourcedata'>) => voidEvent handler for the |
sourcedataloading | (event: MapEventOf<'sourcedataloading'>) => voidEvent handler for the |
styledata | (event: MapEventOf<'styledata'>) => voidEvent handler for the |
styledataloading | (event: MapEventOf<'styledataloading'>) => voidEvent handler for the |
styleimagemissing | (event: MapEventOf<'styleimagemissing'>) => voidEvent handler for the |
styleimportload | (event: MapEventOf<'styleimportload'>) => voidEvent handler for the |
styleload | (event: MapEventOf<'styleload'>) => voidEvent handler for the |
touchcancel | (event: MapEventOf<'touchcancel'>) => voidEvent handler for the |
touchend | (event: MapEventOf<'touchend'>) => voidEvent handler for the |
touchmove | (event: MapEventOf<'touchmove'>) => voidEvent handler for the |
touchstart | (event: MapEventOf<'touchstart'>) => voidEvent handler for the |
webglcontextlost | (event: MapEventOf<'webglcontextlost'>) => voidEvent handler for the |
webglcontextrestored | (event: MapEventOf<'webglcontextrestored'>) => voidEvent handler for the |
wheel | (event: MapEventOf<'wheel'>) => voidEvent handler for the |
zoom | (event: MapEventOf<'zoom'>) => voidEvent handler for the |
zoomend | (event: MapEventOf<'zoomend'>) => voidEvent handler for the |
zoomstart | (event: MapEventOf<'zoomstart'>) => voidEvent handler for the |
| Slot | Payload |
|---|---|
default | Default content to be rendered on the map |
location | { id: string, feature: PointFeature<any> }A single point to display on the map. |
loader | Content to show while the map is loading |
| Exposed | Type |
|---|---|
map | Ref<Map | null> |
focusFeatures() | (features: MapboxFeatures) => voidFocus the map on specific features |
The component provides a context that can be injected by child components
| Context | Type |
|---|---|
map | Ref<Map | null>The Mapbox map instance |
features | Ref<Array<Feature<Point, any>>>The point and cluster features to display on the map. |
viewport | Ref<MapboxViewport>The viewport of the map |
<script setup lang="ts">
const { map, features, viewport } = injectMapboxMapContext();
</script>
<template>
<div>{{ map }}</div>
<div>{{ features }}</div>
<div>{{ viewport }}</div>
</template>