Codementor Events

Mapbox without an access token? Check out MapLibre

Published Aug 16, 2022
Mapbox without an access token? Check out MapLibre

This is cross-posted from my blog at Digital Mapmaking. See the accompanying video for this post at https://www.youtube.com/watch?v=pZXjWKpHyJM.


Do you want to avoid using a Mapbox access token, but still want to use Mapbox? Well, with MapLibre you have a possible solution. In this post we’ll be going over these two libraries and how to get started with MapLibre.

Libraries and Costs

Mapbox GL JS has got to be one of the best libraries out there for working with digital mapping, and specifically when it comes to handling vector maps online. I make use of it every day, and ever since I became a heavy user of it, I recommend it for a huge number of the projects I work on with clients.

There are other great libraries out there — Google Maps API, Leaflet, Apple Maps, OpenLayers — but none is quite as professional and constantly pushing new features the way Mapbox does. Google Maps API and Leaflet are good solutions for developers working with more traditional raster-type tile maps, and OpenLayers is a super solution if you’re strict about working with open source projects or don’t need more advanced features of Mapbox.

One big drawback with Mapbox, however, is the access token issue. You need to create an account and an access token, which opens up your map to potential billing. For most users, this is no big deal — you’ll never normally cross the free limit — but if you do cross it, costs can pile up pretty quickly and get quite significant.

For example, when my Native Land map crossed the free boundary, things quickly exploded to thousands every month! Luckily, Mapbox became a partner and helped us out with their nonprofit program, but if not for that, we would have had to switch libraries very quickly.

Changing Token Requirements

In the past, it was possible to use Mapbox GL JS without an access token in certain circumstances. For instance, if you never loaded a Mapbox style or any Mapbox services (such as geocoding or directions), you could still initialize your map object just fine. This would let you load external tile services (your own tile server, for instance, or OpenStreetMaps rasters), or just draw shapes directly onto a blank style.

free-mapbox.PNG

However, with Mapbox V2, Mapbox changed this situation. Now, it’s absolutely required to have and define a Mapbox Access Token just in order to initialize a map object. You can read more here and see a Github issue about it here. There were also some license changes, meaning the library is now copyrighted and not completely open.

This obviously upset quite a lot of people who had really loved Mapbox contributing so openly to the community and giving us all a library to use as we wished. While everybody recognizes that Mapbox needs to make sure they are profitable, there’s also a need to use the open source library without access tokens — at least for some developers or clients.

As a result, MapLibre was born!

What’s Maplibre?

maplibre-gh.PNG

Maplibre is essentially the Mapbox GL JS library, held at the last point at which it was still open-source and usable without an access token. The community who supports Maplibre will continue to make updates to ensure it stays stable as different technologies emerge on browsers and web development, since Mapbox no longer actively supports pre-v2 Mapbox GL JS.

So this is a great opportunity for you to create a Mapbox map, but to use a different tileset if you like, and thereby avoid even having to create a Mapbox account at all! It’s a very good solution and we actively use it in our Mapster WP Maps plugin to provide a “free” map solution for users.

You won’t get access to v2 Mapbox features — like globe view, projections, or other new fancy shiny things — but that might not matter to you. You can, also, optionally add Mapbox services like geocoding, although for that you will need an access token.

Hope this helps you out!

Discover and read more posts from Victor Gerard Temprano
get started
post commentsBe the first to share your opinion
Show more replies