You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow for different Map instances to use different Mapbox access tokens #6331
Currently, a Mapbox access token must be set on the global mapboxgl library object. There are some use cases that require multiple maps on a page, each using a different access token.
Design Alternatives
Do nothing
It's technically possible to use the Map's transformRequest option to get different maps using different access tokens via something like:
It's also arguably possible for someone to want to have two different Mapbox tokens in the same map, to mash up layers from two different accounts. Assuming that doesn't violate any Mapbox policy, might be worth supporting at the same time.
It's also arguably possible for someone to want to have two different Mapbox tokens in the same map, to mash up layers from two different accounts. Assuming that doesn't violate any Mapbox policy, might be worth supporting at the same time.
Licensing aside, I assume you know that by making the tileset public, then it's no longer tied to an access token from that account and you can use any token from any account. Of course this only works when you're happy to make it public.
@andrewharvey I have the exact same use case where I need to show maps from different accounts using their accessToken and the maps cannot be made public. I guess my only option is to set the token on the global object?
@andrewharvey I have the exact same use case where I need to show maps from different accounts using their accessToken and the maps cannot be made public. I guess my only option is to set the token on the global object?
What about setting a transformRequest? and based on the resource being requested you swap the tokens?
@andrewharvey I have a simple find and replace as in the original description but looks like some requests (Sprite and Glyph) don't go through the transform?
Activity
stevage commentedon Mar 22, 2018
It's also arguably possible for someone to want to have two different Mapbox tokens in the same map, to mash up layers from two different accounts. Assuming that doesn't violate any Mapbox policy, might be worth supporting at the same time.
andrewharvey commentedon Jun 19, 2019
Licensing aside, I assume you know that by making the tileset public, then it's no longer tied to an access token from that account and you can use any token from any account. Of course this only works when you're happy to make it public.
asheemmamoowala commentedon Jul 18, 2019
Closed by #8364
3zzy commentedon Aug 1, 2019
@andrewharvey I have the exact same use case where I need to show maps from different accounts using their accessToken and the maps cannot be made public. I guess my only option is to set the token on the global object?
andrewharvey commentedon Aug 1, 2019
What about setting a transformRequest? and based on the resource being requested you swap the tokens?
3zzy commentedon Aug 1, 2019
@andrewharvey I have a simple find and replace as in the original description but looks like some requests (Sprite and Glyph) don't go through the transform?
For example: