npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

strapi-plugin-map-box

v0.0.4

Published

MapBox map field.

Readme

Strapi Plugin MapBox

A Strapi plugin that adds a custom MapBox field to your content types. Select locations on an interactive map with search functionality, and store coordinates, zoom level, and address data.

Features

  • Interactive MapBox map field for Strapi content types
  • Location search with autocomplete
  • Click or drag marker to set location
  • Stores longitude, latitude, zoom, pitch, bearing, and address
  • Debug mode for viewing raw JSON data
  • Fullscreen, navigation, and geolocation controls

Requirements

  • Strapi v5.x
  • MapBox account with access token

Installation

From npm

npm install strapi-plugin-map-box
# or
yarn add strapi-plugin-map-box

For local development

# Clone the plugin
git clone https://github.com/PaulBratslavsky/strapi-plugin-map-box.git

# Install dependencies
cd strapi-plugin-map-box
yarn install

# Build the plugin
yarn build

Configuration

1. Add plugin configuration

Create or update config/plugins.ts in your Strapi project:

export default () => ({
  'map-box': {
    enabled: true,
    config: {
      public: {
        accessToken: process.env.MAPBOX_ACCESS_TOKEN,
        debugMode: process.env.MAPBOX_DEBUG_MODE === 'true',
      },
    },
  },
});

2. Add environment variables

Add to your .env file:

MAPBOX_ACCESS_TOKEN=pk.your_mapbox_public_token_here
MAPBOX_DEBUG_MODE=false

Get your access token from MapBox Account.

3. Update Content Security Policy

Update config/middlewares.ts to allow MapBox resources:

export default [
  'strapi::logger',
  'strapi::errors',
  {
    name: 'strapi::security',
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'script-src': ["'self'", "'unsafe-inline'", 'blob:'],
          'worker-src': ["'self'", 'blob:'],
          'connect-src': ["'self'", 'https:', 'blob:', 'https://api.mapbox.com', 'https://events.mapbox.com'],
          'img-src': ["'self'", 'data:', 'blob:', 'https://api.mapbox.com', 'https://*.mapbox.com'],
        },
      },
    },
  },
  'strapi::cors',
  'strapi::poweredBy',
  'strapi::query',
  'strapi::body',
  'strapi::session',
  'strapi::favicon',
  'strapi::public',
];

4. Rebuild Strapi

yarn build
yarn develop

Usage

Adding the field to a content type

  1. Go to Content-Type Builder in Strapi admin
  2. Select or create a content type
  3. Click Add another field
  4. Select Custom tab
  5. Choose MapBox field
  6. Configure field name and settings
  7. Save the content type

Data structure

The MapBox field stores the following JSON structure:

{
  "longitude": -122.4194,
  "latitude": 37.7749,
  "zoom": 13,
  "pitch": 0,
  "bearing": 0,
  "address": "San Francisco, CA, USA"
}

API response

When fetching content via the API, the map data is returned as a JSON object:

GET /api/locations
{
  "data": [
    {
      "id": 1,
      "documentId": "abc123",
      "mapData": {
        "longitude": -122.4194,
        "latitude": 37.7749,
        "zoom": 13,
        "pitch": 0,
        "bearing": 0,
        "address": "San Francisco, CA, USA"
      }
    }
  ]
}

Local Development

Link to a Strapi project

Using the resolve path in your Strapi project's config/plugins.ts:

export default () => ({
  'map-box': {
    enabled: true,
    resolve: '../path-to/strapi-plugin-map-box',
    config: {
      public: {
        accessToken: process.env.MAPBOX_ACCESS_TOKEN,
        debugMode: true,
      },
    },
  },
});

Watch mode

yarn watch

Frontend Integration

React / Next.js

npm install react-map-gl mapbox-gl
import Map, { Marker } from 'react-map-gl/mapbox';
import 'mapbox-gl/dist/mapbox-gl.css';

function LocationMap({ location }) {
  return (
    <Map
      initialViewState={{
        longitude: location.longitude,
        latitude: location.latitude,
        zoom: location.zoom,
        pitch: location.pitch,
        bearing: location.bearing,
      }}
      mapStyle="mapbox://styles/mapbox/streets-v12"
      mapboxAccessToken={process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN}
    >
      <Marker
        longitude={location.longitude}
        latitude={location.latitude}
        color="#4945ff"
      />
    </Map>
  );
}

React Native (Expo)

npx expo install @rnmapbox/maps
import Mapbox, { Camera, MapView, PointAnnotation } from '@rnmapbox/maps';

Mapbox.setAccessToken(process.env.EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN);

function LocationMap({ location }) {
  return (
    <MapView style={{ flex: 1 }}>
      <Camera
        centerCoordinate={[location.longitude, location.latitude]}
        zoomLevel={location.zoom}
        pitch={location.pitch}
        heading={location.bearing}
      />
      <PointAnnotation
        id="marker"
        coordinate={[location.longitude, location.latitude]}
      />
    </MapView>
  );
}

TypeScript

type MapLocation = {
  longitude: number;
  latitude: number;
  zoom: number;
  pitch: number;
  bearing: number;
  address?: string;
};

License

MIT

Author

Paul Bratslavsky (@PaulBratslavsky)