Migrate to Maplibre in JavaScript

How to migrate from Mapbox traces to Maplibre traces.


New to Plotly?

Plotly is a free and open-source graphing library for JavaScript. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.

With the release of Plotly.js v2.35.0, we are introducing a new set of trace types for maps with tile underlays:

  • Choroplethmap
  • Scattermap
  • Densitymap

These traces replace the existing Mapbox traces, Choroplethmapbox, Scattermapbox, Densitymapbox, but use MapLibre as the map renderer rather than Mapbox.

When switching to the new traces, keep an eye out for improved rendering performance, WebGL2 support, and over time, improved features in the Plotly map traces inherited from the MapLibre renderer, including projection support, globe views, terrain support, and support for modern mapping standards.

You can learn more about the motivations for this change in our announcement post.

As a result of removing Mapbox as the rendering engine, we're also removing the Mapbox branding from these trace names. This means that migrating from Mapbox traces to MapLibre traces will require some code changes in your projects.

  1. Change trace names from *mapbox to *map. For any existing trace name ending in *mapbox, ensure you've removed the "box" suffix.
  2. If in use, update layout.mapbox argument in your layout configuration to layout.map. The nested properties are identical in the new map traces, so no other changes should be required.
  3. If in use, update mapbox_style to map_style.
  4. Verify your map_style settings. With mapbox traces, we bundle basic, streets, outdoors, light, dark, satellite, and satellite-streets styles, using Mapbox styling. These style names are still available, but they now reference slightly different styles provided by other tools.

Note that Mapbox API keys are no longer required for Plotly-provided styles, but using external styles in your Plotly maps remains supported with the existing API.