<MapboxMap>

Gitlab
A Vue component that provides a wrapper around the Mapbox GL JS library for creating interactive maps.
Added since: v0.1.0
Last changed:

Usage

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.

Basic example

A basic example of how to use the MapboxMap component with a supercluster component to render markers and clusters.

MapComponent.vue
<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 Definition

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];
};

API Reference

Props

PropDefaultType
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

Events

EventPayload
loaded(map: Map) => void

Emitted when the map is fully loaded and ready.

Depricated Use the @load event instead.

boxzoomcancel(event: MapEventOf<'boxzoomcancel'>) => void

Event handler for the boxzoomcancel event.
See Mapbox GL Docs - boxzoomcancel event for more information.

boxzoomend(event: MapEventOf<'boxzoomend'>) => void

Event handler for the boxzoomend event.
See Mapbox GL Docs - boxzoomend event for more information.

boxzoomstart(event: MapEventOf<'boxzoomstart'>) => void

Event handler for the boxzoomstart event.
See Mapbox GL Docs - boxzoomstart event for more information.

click(event: MapEventOf<'click'>) => void

Event handler for the click event.
See Mapbox GL Docs - click event for more information.

contextmenu(event: MapEventOf<'contextmenu'>) => void

Event handler for the contextmenu event.
See Mapbox GL Docs - contextmenu event for more information.

data(event: MapEventOf<'data'>) => void

Event handler for the data event.
See Mapbox GL Docs - data event for more information.

dataloading(event: MapEventOf<'dataloading'>) => void

Event handler for the dataloading event.
See Mapbox GL Docs - dataloading event for more information.

dblclick(event: MapEventOf<'dblclick'>) => void

Event handler for the dblclick event.
See Mapbox GL Docs - dblclick event for more information.

drag(event: MapEventOf<'drag'>) => void

Event handler for the drag event.
See Mapbox GL Docs - drag event for more information.

dragend(event: MapEventOf<'dragend'>) => void

Event handler for the dragend event.
See Mapbox GL Docs - dragend event for more information.

dragstart(event: MapEventOf<'dragstart'>) => void

Event handler for the dragstart event.
See Mapbox GL Docs - dragstart event for more information.

error(event: MapEventOf<'error'>) => void

Event handler for the error event.
See Mapbox GL Docs - error event for more information.

idle(event: MapEventOf<'idle'>) => void

Event handler for the idle event.
See Mapbox GL Docs - idle event for more information.

load(event: MapEventOf<'load'>) => void

Event handler for the load event.
See Mapbox GL Docs - load event for more information.

mousedown(event: MapEventOf<'mousedown'>) => void

Event handler for the mousedown event.
See Mapbox GL Docs - mousedown event for more information.

mouseenter(event: MapEventOf<'mouseenter'>) => void

Event handler for the mouseenter event.
See Mapbox GL Docs - mouseenter event for more information.

mouseleave(event: MapEventOf<'mouseleave'>) => void

Event handler for the mouseleave event.
See Mapbox GL Docs - mouseleave event for more information.

mousemove(event: MapEventOf<'mousemove'>) => void

Event handler for the mousemove event.
See Mapbox GL Docs - mousemove event for more information.

mouseout(event: MapEventOf<'mouseout'>) => void

Event handler for the mouseout event.
See Mapbox GL Docs - mouseout event for more information.

mouseover(event: MapEventOf<'mouseover'>) => void

Event handler for the mouseover event.
See Mapbox GL Docs - mouseover event for more information.

mouseup(event: MapEventOf<'mouseup'>) => void

Event handler for the mouseup event.
See Mapbox GL Docs - mouseup event for more information.

move(event: MapEventOf<'move'>) => void

Event handler for the move event.
See Mapbox GL Docs - move event for more information.

moveend(event: MapEventOf<'moveend'>) => void

Event handler for the moveend event.
See Mapbox GL Docs - moveend event for more information.

movestart(event: MapEventOf<'movestart'>) => void

Event handler for the movestart event.
See Mapbox GL Docs - movestart event for more information.

pitch(event: MapEventOf<'pitch'>) => void

Event handler for the pitch event.
See Mapbox GL Docs - pitch event for more information.

pitchend(event: MapEventOf<'pitchend'>) => void

Event handler for the pitchend event.
See Mapbox GL Docs - pitchend event for more information.

pitchstart(event: MapEventOf<'pitchstart'>) => void

Event handler for the pitchstart event.
See Mapbox GL Docs - pitchstart event for more information.

preclick(event: MapEventOf<'preclick'>) => void

Event handler for the preclick event.
See Mapbox GL Docs - preclick event for more information.

remove(event: MapEventOf<'remove'>) => void

Event handler for the remove event.
See Mapbox GL Docs - remove event for more information.

render(event: MapEventOf<'render'>) => void

Event handler for the render event.
See Mapbox GL Docs - render event for more information.

renderstart(event: MapEventOf<'renderstart'>) => void

Event handler for the renderstart event.
See Mapbox GL Docs - renderstart event for more information.

resize(event: MapEventOf<'resize'>) => void

Event handler for the resize event.
See Mapbox GL Docs - resize event for more information.

rotate(event: MapEventOf<'rotate'>) => void

Event handler for the rotate event.
See Mapbox GL Docs - rotate event for more information.

rotateend(event: MapEventOf<'rotateend'>) => void

Event handler for the rotateend event.
See Mapbox GL Docs - rotateend event for more information.

rotatestart(event: MapEventOf<'rotatestart'>) => void

Event handler for the rotatestart event.
See Mapbox GL Docs - rotatestart event for more information.

sourcedata(event: MapEventOf<'sourcedata'>) => void

Event handler for the sourcedata event.
See Mapbox GL Docs - sourcedata event for more information.

sourcedataloading(event: MapEventOf<'sourcedataloading'>) => void

Event handler for the sourcedataloading event.
See Mapbox GL Docs - sourcedataloading event for more information.

styledata(event: MapEventOf<'styledata'>) => void

Event handler for the styledata event.
See Mapbox GL Docs - styledata event for more information.

styledataloading(event: MapEventOf<'styledataloading'>) => void

Event handler for the styledataloading event.
See Mapbox GL Docs - styledataloading event for more information.

styleimagemissing(event: MapEventOf<'styleimagemissing'>) => void

Event handler for the styleimagemissing event.
See Mapbox GL Docs - styleimagemissing event for more information.

styleimportload(event: MapEventOf<'styleimportload'>) => void

Event handler for the styleimportload event.
See Mapbox GL Docs - styleimportload event for more information.

styleload(event: MapEventOf<'styleload'>) => void

Event handler for the styleload event.
See Mapbox GL Docs - styleload event for more information.

touchcancel(event: MapEventOf<'touchcancel'>) => void

Event handler for the touchcancel event.
See Mapbox GL Docs - touchcancel event for more information.

touchend(event: MapEventOf<'touchend'>) => void

Event handler for the touchend event.
See Mapbox GL Docs - touchend event for more information.

touchmove(event: MapEventOf<'touchmove'>) => void

Event handler for the touchmove event.
See Mapbox GL Docs - touchmove event for more information.

touchstart(event: MapEventOf<'touchstart'>) => void

Event handler for the touchstart event.
See Mapbox GL Docs - touchstart event for more information.

webglcontextlost(event: MapEventOf<'webglcontextlost'>) => void

Event handler for the webglcontextlost event.
See Mapbox GL Docs - webglcontextlost event for more information.

webglcontextrestored(event: MapEventOf<'webglcontextrestored'>) => void

Event handler for the webglcontextrestored event.
See Mapbox GL Docs - webglcontextrestored event for more information.

wheel(event: MapEventOf<'wheel'>) => void

Event handler for the wheel event.
See Mapbox GL Docs - wheel event for more information.

zoom(event: MapEventOf<'zoom'>) => void

Event handler for the zoom event.
See Mapbox GL Docs - zoom event for more information.

zoomend(event: MapEventOf<'zoomend'>) => void

Event handler for the zoomend event.
See Mapbox GL Docs - zoomend event for more information.

zoomstart(event: MapEventOf<'zoomstart'>) => void

Event handler for the zoomstart event.
See Mapbox GL Docs - zoomstart event for more information.

Slots

SlotPayload
default

Default content to be rendered on the map

location{ id: string, feature: PointFeature<any> }

A single point to display on the map.

(Coordinates are in longitude, latitude format)

loader

Content to show while the map is loading

Exposed

ExposedType
mapRef<Map | null>
focusFeatures()(features: MapboxFeatures) => void

Focus the map on specific features

Context

The component provides a context that can be injected by child components

ContextType
mapRef<Map | null>

The Mapbox map instance

featuresRef<Array<Feature<Point, any>>>

The point and cluster features to display on the map.

viewportRef<MapboxViewport>

The viewport of the map

CustomMapboxMap.vue
<script setup lang="ts">
const { map, features, viewport } = injectMapboxMapContext();
</script>

<template>
  <div>{{ map }}</div>
  <div>{{ features }}</div>
  <div>{{ viewport }}</div>
</template>

Changelog

v0.2.3

on

#7f99a907

-

improvement: added deprecation warning for the @loaded event

#ebea626c

-

improvement: added full typescript support

v0.2.2

on

#93b26e58

-

improvement: updated src structure to match latest internal conventions

v0.1.1

on

#5fe11b2c

-

fix: updated incorrect package name import