All docsMapbox GL JS Seats

Mapbox GL JS Seats

Current version: v1.12.0View changelog

  • Seats-based billing
  • Custom map styles
  • Fast vector maps
  • Compatible with other Mapbox tools

Mapbox GL JS Seats is a JavaScript library built on top of Mapbox GL JS that offers metering and billing of Mapbox APIs by seats. It uses WebGL to render interactive maps from vector tiles and Mapbox styles.

Pricing

A seat consists of a single user who uses Mapbox services within your web application during your month-long billing period. Each user can use unlimited Vector Tiles API and Raster Tiles API requests per month. After access to Mapbox GL JS Seats is added to your account, you will be able to view usage by seat on your Statistics page. Details about the number of seats included in the free tier and the cost per seat beyond what is included in the free tier are available on the pricing page.

Access Mapbox GL JS Seats

Mapbox GL JS Seats is available with an Annual Purchase Agreement. Current Mapbox customers with an Annual Purchase Agreement should talk to their Technical Account Manager or Account Manager about metering usage by seats. New customers should contact Mapbox sales.

Download

Talk with your Technical Account Manager directly or contact our sales team to learn more about accessing Mapbox GL JS Seats. After access has been added to your account, download all Mapbox GL JS Seats resources in a single zip file below.

Quickstart

After downloading the package, import the library and initialize your first map.

Import the library

You will need to host the files you downloaded above and include all contents in your project. Then, include the JavaScript and CSS files in the <head> of your HTML file.

<script src='LOCATION_OF_SEATS_FILES/mapbox-gl-seats.js'></script>
<link href='LOCATION_OF_SEATS_FILES/mapbox-gl-seats.css' rel='stylesheet' />

Initialize a map

Include the following code in the <body> of your HTML file. You'll need to get an access token and a style URL. You can choose from one of our professionally-designed styles or create your own using Mapbox Studio.

<div id='map' style='width: 400px; height: 300px;'></div>
<script>
mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v11'
});
</script>

SDK updates

Mapbox GL JS Seats releases will happen with Mapbox GL JS releases. To update to a newer version of Mapbox GL JS Seats in your application, you will need to download that version above and replace it in your project.

CSP Directives

As a mitigation for Cross-Site Scripting and other types of web security vulnerabilities, you may use a Content Security Policy (CSP) to specify security policies for your website. If you do, Mapbox GL JS Seats requires the following CSP directives:

worker-src blob: ;
child-src blob: ;
img-src data: blob: ;

Requesting styles from Mapbox or other services will require additional directives. For Mapbox, you can use this connect-src directive:

connect-src https://*.tiles.mapbox.com https://api.mapbox.com https://events.mapbox.com

For strict CSP environments without worker-src blob: ; child-src blob: enabled, there's a separate Mapbox GL JS bundle (mapbox-gl-seats-csp.js and mapbox-gl-seats-csp-worker.js) which requires setting the path to the worker manually:

<script src='LOCATION_OF_SEATS_FILES/mapbox-gl-seats-csp.js'></script>
<script>
mapboxgl.workerUrl = 'LOCATION_OF_SEATS_FILES/mapbox-gl-seats-csp-worker.js';
...
</script>

Mapbox GL CSS

The CSS referenced in the Quickstart is used to style DOM elements created by Mapbox code. Without the CSS, elements like Popups and Markers won't work. Including it with a <link> in the head of the document via the Mapbox CDN is the simplest and easiest way to provide the CSS, but it is also bundled in the Mapbox module, meaning that if you have a bundler that can handle CSS, you can import the CSS from mapbox-gl-seats.css.

Note too that if the CSS isn't available by the first render, as soon as the CSS is provided, the DOM elements that depend on this CSS should recover.

More resources

See the Mapbox GL JS API documentation and examples for more information on how to build with Mapbox GL JS.