🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

nuxt-mapbox

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-mapbox

Elegant Mapbox GL JS integration with Nuxt

npmnpm
Version
1.6.3
Version published
Weekly downloads
3.3K
6.32%
Maintainers
1
Weekly downloads
 
Created
Source

Nuxt-Mapbox

Elegant Mapbox integration with Nuxt

đź“– Check out the new docs!

npm version npm downloads License

Features

  • 🏗  Easily add Mapbox to your Nuxt app with Vue components
  • 🌎  useMapbox Composable for easy access
  • đź‘·  defineMapboxMarker & defineMapboxPopup for making custom components
  • 🎛️  defineMapboxControl for creating your own controls
  • đź“–  Persistent map instances across routes

Quick Setup

  • Add nuxt-mapbox & mapbox-gl dependencies to your project
npx nuxi@latest module add nuxt-mapbox
npm install --save-dev mapbox-gl
  • Add nuxt-mapbox to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxt-mapbox'
  ]
})
  • Add your Mapbox API key to the mapbox section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxt-mapbox'
  ],
  mapbox: {
    accessToken: '{API_KEY}'
  }
})

Usage

View the Mapbox GL JS Docs for reference.

Map instances are created with components. You can provide all the options through component props

Example:

    <MapboxMap
      map-id="{ID}"
      style="position: absolute; top: 0; bottom: 0; left: 250px; width: 500px;"
      :options="{
        style: 'mapbox://styles/mapbox/light-v11', // style URL
        center: [-68.137343, 45.137451], // starting position
        zoom: 5 // starting zoom
      }"
    />

You can add Layers, Sources & Controls by nesting their respective components inside the Map

Examples:

    <MapboxMap
      ...
    >
      <MapboxSource 
        source-id="{ID}"
        :source="{
          type: 'geojson',
          data: '/test.geojson'
        }"
      />
      <MapboxLayer
        :layer="{
          source: '{ID}',
          id: 'geojson-layer',
          type: 'fill'
        }"
      />
      <MapboxGeolocateControl position="top-left" />
    </MapboxMap>

Development

# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release

Keywords

mapbox

FAQs

Package last updated on 31 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts