Use Atlas with other Mapbox products
To build with Mapbox GL JS and other Mapbox products and to serve your Atlas maps, you will need the Atlas token that you created as part of the installation process. This Atlas public token is unique to your Atlas instance, and will not work on Mapbox.com.
Available Mapbox APIs
With Atlas, you can use the following Mapbox APIs offline:
- Vector Tiles API
- Raster Tiles API
- Legacy Maps API
- Styles API
- Static Images API
- Static Tiles API
- Tilequery API
- Geocoding API
Right now, Atlas only supports calls to these APIs that require public access (pk
) tokens. For example, it's not possible to programmatically create, edit, or delete map styles using the Styles API since these calls require a secret access (sk
) token, but you can do all these functions with the Atlas instance of Mapbox Studio.
Use Mapbox GL JS with Atlas
Note: Atlas supports Mapbox GL JS versions 0.40.0
through 1.6.1
.
To use a Mapbox GL JS application with Atlas, make the following changes to the relevant files:
- Update
mapboxgl.accessToken
to a public access token created on your Atlas Studio Account page. - Set
mapboxgl.config.API_URL = '<your-atlas-url>';
within your application. - Update the
mapbox-gl-js
library URLs in your HTML:
<script src="<your-atlas-url>/mapbox-gl-js/v1.3.1/mapbox-gl.js"></script>
<link
href="<your-atlas-url>/mapbox-gl-js/v1.3.1/mapbox-gl.css"
rel="stylesheet"
/>
If you use additional APIs in your application, you need to make sure that all APIs have been updated to the appropriate Atlas URL instead of the default api.mapbox.com
.
Looking for inspiration? You can use Mapbox GL JS examples as a baseline to build off of, then make the above changes for working with Atlas.
Use Mapbox.js with Atlas
Note: Atlas supports Mapbox.js versions 2.0.0
through 3.2.1
. While Mapbox.js is stable, it is not in active development. We recommend you to use Mapbox GL JS instead if possible.
Mapbox Studio styles with L.mapbox.styleLayer
are supported when you use Mapbox.js with Atlas. Mapbox Studio Classic styles are not supported.
To use a Mapbox.js application with Atlas, make the following changes to your file:
- Update
L.mapbox.accessToken
to a public access token created on your Atlas Studio Account page. - Update
L.mapbox.config.HTTPS_URL
to set the appropriate hostname and port for your Atlas installation. - Use
L.mapbox.styleLayer
to set the style.- For example:
L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v10').addTo(map);
- For example:
- Update the
mapbox.js
library URLs in your HTML:
<script src="https://<your-atlas-url>/mapbox.js/v3.1.1/mapbox.js"></script>
<link
href="https://<your-atlas-url>/mapbox.js/v3.1.1/mapbox.css"
rel="stylesheet"
/>
If you use additional APIs in your application, you need to make sure that all APIs have been updated to the appropriate Atlas URL instead of the default api.mapbox.com
.
Use mobile and AR SDKs with Atlas
Atlas maps can also be used in mobile apps that use the Mapbox Android Maps SDK or the iOS Maps SDK, or in AR apps that use the Mapbox Unity SDK. You can make all apps that work on Mapbox.com also work with Atlas using the proper app configuration.
Use the Mapbox Maps SDK for Android with Atlas
Install and launch your local Atlas instance by following the Atlas installation instructions.
Log into your Mapbox Studio account and use the bundled Studio to create a new style. Copy the map style's ID.
Add a new
Style
object to the map with the style ID that you've copied above:mapboxMap.setStyle(new Style.Builder().fromUri(uniqueStyleUrl), new Style.OnStyleLoaded() { @Override public void onStyleLoaded(@NonNull Style style) {
}});
For more information about changing the map style on Android, see Changing the map style
Use the Maps SDK's
mapbox_apiBaseUri
XML attribute to update the map's API endpoint to your local IP address:mapbox:mapbox_apiBaseUri="https://XXX.XXX.XXX.XX:XXXX"
Add
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
to the top-level parentViewGroup
of the XML file that you've adjusted in step #4 above.Update the project's Mapbox access token with a token from your Atlas Studio Account page. For more information about keeping Mapbox access tokens safe on Android, see our Private access token on mobile guide.
Create a new class that extends your app's
Application
class and then override itsonCreate()
method.Use an
OkHttpClient
that trusts an SSL certificate.Update the
OkHttpClient
client to accept the self-signed certificate when your project is in development.Set up a regular certificate that would be accepted by a regular
OkHttpClient
instance when your project is live in production.
Navigate to your app to successfully view Mapbox map tiles.
Static examples
Your Atlas installation comes with several static map examples that you can use for reference as you create your own Atlas maps. There is a vector map example used in a webpage powered by Mapbox GL JS, a raster map example in a page powered by Mapbox.js, an Atlas Search example, and an Enterprise Boundaries example. The HTML for all these files are hosted on your atlas instance at ATLAS_URL/static/EXAMPLE_NAME
where ATLAS_URL
is the URL your atlas instance is deployed to and EXAMPLE_NAME
is one of the following:
index.html
(Mapbox GL JS)mapbox-js.html
(Mapbox.js)geocoder.html
(Atlas Search)enterprise-boundaries.html
(Enterprise Boundaries)
- Navigate to the file in your browser (for example
ATLAS_URL/static/index.html
) and note that nothing appears — this is expected as the file needs placeholder values filled out to correctly point to your Atlas instance. - Save the file (HTML only) and open it in your text editor. Each of the examples will have two placeholders — you'll need to replace
ATLAS_URL_HERE
with your Atlas instance's URL andATLAS_TOKEN_HERE
with your Atlas token (available at your Atlas instance's URL). - Open the edited file in your browser.