javascriptmapboxmapbox-gl-jsmapbox-studio

How do I use a private Mapbox Tileset in Mapbox GL JS?


I have a Frontend build with Mapbox GL JS and would like it to access a private Tileset that I uploaded to Mapbox Studio. However private Tilesets can only be accessed with secret Tokens and Mapbox refuses to work when initialized with those.

Is there a way I can keep my Map private and access it through Mapbox GL?


Solution

  • However private Tilesets can only be accessed with secret Tokens

    I think you are mistaken. Private tilesets can be accessed by any token from the same account, as per the documentation:

    If a tileset is public, the tileset ID can be used by any Mapbox user with their access tokens. But, only the owner of a tileset can make changes or delete a tileset, even if it's public. If a tileset is private, the tileset ID can only be used with an access token from the owner's account. By default, new tilesets created in Mapbox Studio are private.

    So, switch to using a regular public token and it should work.