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 the ArcGIS Runtime SDK for Android 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 the latest version of Android Studio.

Reuse the starter project

If you have completed the Create a starter app tutorial, then copy the project into a new empty folder. Otherwise, download and unzip the project solution. Open, run, and verify the map displays in the device simulator.

Prepare your data

Complete the tutorial Style a vector basemap. You will use the map style created in that tutorial for the custom map required in this tutorial.


  1. In the file app > java > {} >, find the existing setupMap method. Remove all of the code in this function and replace it by setting the initial view point with the latitude, longitude, and scale variables below. Set the initial viewpoint with the variables so the map zooms to the Santa Monica Mountains when the app loads.

    private void setupMap() {
        if (mMapView != null) {
            double latitude = 34.09042;
            double longitude = -118.71511;
            double scale = 300000;
            map.setInitialViewpoint(new Viewpoint(latitude, longitude, scale));
  2. The Forest and Parks Canvas Map is stored on ArcGIS Online (portal). Create a new [Portal](/android/latest/api-reference/reference/com/esri/arcgisruntime/portal/Portal.html) that references ArcGIS Online with Create a [PortalItem](/android/latest/api-reference/reference/com/esri/arcgisruntime/portal/PortalItem.html) and pass the portalService and the itemId to the constructor to create the layer.

            /* ** ADD ** */
            String myLayerId = "d2ff12395aeb45998c1b154e25d680e5";
            Portal portalService = new Portal("", false);
            PortalItem portalItemLayer = new PortalItem(portalService, myLayerId);
  3. Create a new basemap from your portal item, and then configure a new ArcGISMap object to use your custom basemap. Once the map object is configured, assign it to the map view.

            /* ** ADD ** */
            ArcGISVectorTiledLayer myCustomTileLayer = new ArcGISVectorTiledLayer(portalItemLayer);
            ArcGISMap map = new ArcGISMap(new Basemap(myCustomTileLayer));
  4. 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 your solution 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 Android and replace the setupMap method with your new custom basemap version.