Skip To Content ArcGIS for Developers Sign In Dashboard


You will learn: how to build an app that displays a vector basemap with custom styles.

With ArcGIS Runtime SDK for .NET you can build mapping applications that use Esri vector basemaps with custom styles. If you don't already have a custom basemap style, you can create a new one with the ArcGIS Vector Tile Style Editor. This application allows you to create a style interactively and then save the style in ArcGIS Online as a portal item. Each portal item has a unique ID that your application can use to load the style as a layer or a basemap. See Display a map for more details. To learn more about how to create a new custom style with the ArcGIS Vector Tile Style Editor, see the Style a Vector Basemap tutorial.

In this tutorial, you will build a mapping app that loads a custom vector basemap named Forest and Parks Canvas Map. This basemap emphasizes national forests and parks.

Before you begin

Make sure you have installed a supported version of Visual Studio. Please check system requirements for more information.

The ArcGIS Runtime SDK for .NET Visual Studio extension must be installed to use the app templates. Please review the install instructions if you have not done this.


Create a new ArcGIS Runtime App Visual Studio Project

  1. Start Visual Studio.

  2. Choose File > New > Project and select the ArcGIS Runtime App template for your chosen platform.

Add code to access a layer item from ArcGIS Online

  1. Open the MapViewModel.cs code file in your project. Find the definition for the Map property in the class. Notice that the default map is currently set to display a streets basemap. Remove the code that initializes the map (right of the '=', in other words).

    private Map _map;
  2. Add the following function to the MapViewModel class:

    private async void CreateStyledVectorBasemap()
  3. Create a variable to store an ArcGIS Online portal item ID. This is the unique ID for the Forest and Parks Canvas portal item (styled vector layer).

    string customVectorLayerId = "d2ff12395aeb45998c1b154e25d680e5";
  4. At the top of the MapViewModel module, add the following using statement to bring in classes from Esri.ArcGISRuntime.Portal.

    using Esri.ArcGISRuntime.Portal;
  5. Return to the CreateStyledVectorBasemap function and create a new ArcGISPortal that references ArcGIS Online with the URL "".

    ArcGISPortal arcGISOnline = await ArcGISPortal.CreateAsync(new Uri(""));
  6. Get the portal item using the item ID and use it to create an ArcGISVectorTiledLayer.

    PortalItem layerPortalItem = await PortalItem.CreateAsync(arcGISOnline, customVectorLayerId);
    ArcGISVectorTiledLayer customVectorTileLayer = new ArcGISVectorTiledLayer(layerPortalItem);

Configure a new map that uses the layer as a basemap

  1. Create a new basemap from the portal item, and then create a new Map object to use your custom basemap.

    Basemap vectorLayerBasemap = new Basemap(customVectorTileLayer);
    Map map = new Map(vectorLayerBasemap);
  2. Set the initial viewpoint with the variables below so the map zooms to the Santa Monica Mountains when the app loads.

    double initialLatitude = 34.09042;
    double initialLongitude = -118.71511;
    double initialScale = 300000;
    map.InitialViewpoint = new Viewpoint(initialLatitude, initialLongitude, initialScale);
  3. Assign the map to the view model's Map property to expose it through data binding to the app's MapView.

    Map = map;
  4. In the MapViewModel constructor, add a call to the CreateStyledVectorBasemap function.

    public MapViewModel()
  5. Run the code and explore the custom national forest and parks vector styles.

Congratulations, you're done!

Your map should display the custom forest and parks canvas basemap. Compare with our completed solution project.


Use your own custom basemap

Complete the tutorial Style a Vector Basemap and use your own custom basemap instead of the one provided here.

Add layers

Review the tutorial Create a 2D map with a layer and load the trailheads layer on top of your custom basemap.

Handle load errors

Custom basemaps may not load in your app for multiple reasons, including network availability, the item's privacy settings, or an incorrect item id. Add error handling to your app to alert the user if the map does not load and display a message explaining why.

Update completed tutorials

Return to any of your completed ArcGIS tutorials for .NET and add code to replace the basemap with your new custom basemap.