Skip to content

Display a custom basemap style

Learn how to create a custom basemap style using ArcGIS Vector Tile Style Editor and display it in a map.

Display a custom basemap style using API key authentication

A basemap style provides the visual context for a map. You can use the default basemap styles provided by the ArcGIS Basemap services or create a custom basemap style with the ArcGIS Vector Tile Style Editor.

In this tutorial, use ArcGIS Vector Tile Style Editor and the MapLibre ArcGIS plugin to create and display a custom basemap style in a map.

Prerequisites

You need an ArcGIS Location Platform or ArcGIS Online account.

Steps

Create a custom basemap style

You can create your own custom basemap with the ArcGIS Vector Tile Style Editor.

  1. Go to the Vector Tile Style Editor.

  2. Sign in with your ArcGIS account.

  3. Click + New style.

  4. In the Select a style to continue panel, click Popular > Light Gray Canvas.

  5. In left-panel, click Quick Edit. Style the basemap using Colors, Font, Label Size, and Road Width. For example:

    • Colors
      • Land: #cbe8b0
      • Water: #b9dbf7
      • Roads: #f0f1f0
      • Boundaries: #ffffff
      • Buildings: #ebe7dc
      • Nature: #f0fae6
  6. In the search tool of the map, enter Yosemite National Park.

  7. Click on any green area to open the Admin0 forest or park layer.

  8. In the map, zoom out to level 6 so that the layer disappears.

  9. In the Layer Editor > Visibility panel, set the first number of the Visible Zoom Range to 3 to make the layer visible.

  10. In the Layer Editor > Appearance panel, set the fill and outline color properties to change at different zoom levels using either hex codes or the color selector. For example:

    • Color > Settings icon > Set Value by Zoom level:
      • 3 #ddf0ca
      • 6 #cbe5b1
      • Click Add Stop and enter: 10 #bae291.
    • Outline Color: #bbd4a2
    • Opacity: 60%
  11. In the toolbar, click Save As to save your customized basemap. Enter a Title and Tags.

Get the starter app

Select a type of authentication below and follow the steps to create a new application.

You can choose one of the following to create a new CodePen:

  • Option 1: Complete the Display a map tutorial; or,
  • Option 2: Start from the Display a map tutorial .

Set up authentication

Create developer credentials in your portal for the type of authentication you selected.

Create a new API key credential with the correct privileges to access the resources used in this tutorial.

  1. Go to the Create an API key tutorial to follow the steps to get an access token with these privilege(s):
    • Privileges
      • Location services > Basemaps
    • Item access
      • Note: If you are using your own custom data layer for this tutorial, you need to grant the API key credentials access to the layer item. Learn more in Item access privileges.

Set developer credentials

Use the API key or OAuth developer credentials so your application can access ArcGIS services.

  1. Update the accessToken variable to use your API key.

    Expand
    Use dark colors for code blocks
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
        /* Use for API key authentication */
        const accessToken = "YOUR_ACCESS_TOKEN";
    
    Expand

Display the custom basemap style

Use the MapLibre ArcGIS plugin to access the custom basemap style by referencing its item ID. You can find its item ID by accessing it in your portal or the ArcGIS Vector Tile Style Editor.

  1. Go to the item page of the custom basemap style that you previously created and find its item ID. The ID is at the end of the URL, for example 9d94a890b76a417cad8a748df4f97336.

  2. Reference the item ID in your BasemapStyle object.

    Expand
    Use dark colors for code blocks
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
        const basemapStyle = maplibreArcGIS.BasemapStyle.applyStyle(map, {
          style: '9d94a890b76a417cad8a748df4f97336',
          token: accessToken
        });
    
    Expand

Run the app

Run the app.

The map should display the custom basemap style created using ArcGIS Vector Tile Style Editor.

What's next?

Learn how to use additional location services in these tutorials:

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.