Skip to content

Mapbox access tokens

m0nac0 edited this page Jun 12, 2020 · 3 revisions

Adding a Mapbox Access Token

This project uses Mapbox vector tiles, which requires a Mapbox account and a Mapbox access token. Obtain a free access token on your Mapbox account page.

Even if you do not use Mapbox vector tiles but vector tiles from a different source (like self-hosted tiles) with this plugin, you will need to specify any non-empty string as Access Token as explained below!

Providing your access token in Flutter (recommended)

The recommended way to provide your access token is through the MapboxMap constructor's accessToken parameter, which is available starting from the v0.8 release. Note that you should always use the same token throughout your entire app.


Setting your access token through platform-specific files (old method)

For earlier versions you need to set your access token through platform-specific files as described below. This will also continue to work as a fallback on v0.8. You should not set the access token through both the constructor parameter and platform-specific files!

Android

Add Mapbox access token configuration in the application manifest example/android/app/src/main/AndroidManifest.xml:

<manifest ...
  <application ...
    <meta-data android:name="com.mapbox.token" android:value="YOUR_TOKEN_HERE" />

iOS

Add Mapbox access token configuration to the application Info.plist example/ios/Runner/Info.plist:

<key>io.flutter.embedded_views_preview</key>
<true/>
<key>MGLMapboxAccessToken</key>
<string>YOUR_TOKEN_HERE</string>

Web

Add Mapbox access token configuration to index.html example/web/index.html:

<body>
  ...
  <script>
    mapboxgl.accessToken = 'YOUR_TOKEN_HERE';
  </script>
</body>