How to use Mapbox in your .NET MAUI app

How to use Mapbox in your .NET MAUI app


Mapbox is a well-known service for maps and location and it provides its SDKs for multiple platforms from the web to the mobile. Within the mobile, there are prebuilt SDKs for ReactNative and Flutter, but none for Xamarin.Forms/.NET MAUI.

Recently, I successfully created and published the NuGet package for integrating Mapbox SDKs to a Xamarin.Forms and/or .NET MAUI app.

dotnet add package Mapbox.Maui --version 11.4.0-alpha01

In this blog, I will guide you through the steps to use that mentioned NuGet package in a .NET MAUI app.

TLTR; You can access the full quickstart example from this GitHub repo.


  • Visual Studio for Mac or Visual Studio on Windows (VS Code)

  • .NET 8.0.100

  • .NET workloads for Android, iOS, MAUI


Assumption: We will start with a totally new, empty .NET MAUI app.


At the moment, this setup for iOS and Android is a little bit different, so we have to do it twice, differently for each platform. You can read my blog posts for .NET Android and for .NET iOS for further details.

  • Grab your MAPBOX_DOWNLOADS_TOKEN from your Mapbox account page

  • Put that token ~/.gradle/ from the terminal (Replace YOUR_MAPBOX_DOWNLOADS_TOKEN with yours)

  • Amend your .csproj file with the following lines (Replace YOUR_MAPBOX_DOWNLOADS_TOKEN with yours)
    <GradleRepository Include="">
      maven {
         url = uri("")
         authentication {
         credentials {
             // Do not change the username below.
             // This should always be `mapbox` (not your username).
             username = "mapbox"
             // Use the secret token you stored in as the password
             password = providers.gradleProperty("MAPBOX_DOWNLOADS_TOKEN").get()

NOTE:MAPBOX_DOWNLOADS_TOKENis a sensitive data item, it shouldn't be committed to our git repository. We should put it in an ignored file, but still understandable by the compiler.

2/ Add Mapbox MAUI for .NET to your project

  • Open NuGet Package Manager

  • Search for the package Mapbox.Maui

  • Add it to your project

  • Check the result

  • Try to build the project

    A successful build means you did it well by far

4/ Configure mapbox_access_token

To work with Mapbox APIs, we have to generate a personalized access token from our Mapbox account page and then put it into our project to use

  • Generate/grab the access token

    You can use the default public token for this tutorial. If you want more control over what scopes to be used, please create a new token

  • Amend MauiProgram.cs as the below code snippet

      public static class MauiProgram
          // Please put your MAPBOX_ACCESS_TOKEN here
          const string ACCESS_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN";
          public static MauiApp CreateMauiApp()
              // ...
                  // ...
              // ...

    NOTE: mapbox_access_token is a sensitive data item, it shouldn't be committed to our git repository. We should put it in an ignored file, but still understandable by the compiler.

5/ Add MapView control to your app

  • In XAML MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>

    <mb:MapboxView />
  • Remove all old logic in MainPage.xaml.cs
public partial class MainPage : ContentPage
    public MainPage()
  • Check out the result

NOTE: You can also initialize MapView instance directly from C#.

Wrap up

I just guided you on how to use Mapbox in a .NET MAUI project.

I already ported 10 out of 66 iOS examples to .NET MAUI. You can check out Mapbox SDK for .NET MAUI repository.

I want to port all the rest to .NET MAUI, but it'll be a time-consuming task. Single me will last for a very long time. I hope the community can contribute to this GitHub repo and/or to their repos.