Learn how to add a custom vector basemap layer to a map.
A basemap layer provides the visual context for a map. You can use the default basemap layer styles provided by basemap services or you can create your own custom styles with the ArcGIS Vector Tile Style Editor for specific mapping applications.
In this tutorial, you use ArcGIS Vector Tile Style Editor and MapLibre GL JS to create and display a styled vector basemap layer in a map.
Prerequisites
An ArcGIS Location Platform or ArcGIS Online account.
Steps
Create a custom basemap
You can create your own custom basemap with the ArcGIS Vector Tile Style Editor.
-
Go to the Vector Tile Style Editor.
-
Sign in with your ArcGIS account.
-
Click + New style.
-
In the Select a style to continue panel, click Popular > Light Gray Canvas.
-
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
- Land:
- Colors
-
In the search tool of the map, enter
Yosemite National Park
. -
Click on any green area to open the Admin0 forest or park layer.
-
In the map, zoom out to level 6 so that the layer disappears.
-
In the Layer Editor > Visibility panel, set the first number of the Visible Zoom Range to 3 to make the layer visible.
-
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%
- Color > Settings icon > Set Value by Zoom level:
-
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.
Set up authentication
Create developer credentials in your portal for the type of authentication you selected.
Set developer credentials
Use the API key or OAuth developer credentials so your application can access location services.
Display the custom basemap
You can access a basemap layer by referencing its item ID. You can find a layer's item ID by accessing it in your portal or the ArcGIS Vector Tile Style Editor.
-
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
-
Change the
basemap
fromId arcgis/outdoor
to your own item ID and thestyle
endpoint to enable your custom item.Use dark colors for code blocks /* Use for API key authentication */ const accessToken = "YOUR_ACCESS_TOKEN"; // or /* Use for user authentication */ // const session = await arcgisRest.ArcGISIdentityManager.beginOAuth2({ // clientId: "YOUR_CLIENT_ID", // Your client ID from OAuth credentials // redirectUri: "YOUR_REDIRECT_URI", // The redirect URL registered in your OAuth credentials // portal: "YOUR_PORTAL_URL" // Your portal URL // }) // const accessToken = session.token; const basemapEnum = "9d94a890b76a417cad8a748df4f97336"; // Custom vector tile style const map = new maplibregl.Map({ container: "map", // the id of the div element style: `https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/items/${basemapEnum}?token=${accessToken}`, zoom: 10, // starting zoom center: [-118.805, 34.027] // starting location [longitude, latitude] });
Run the app
Run the app.
It should display your custom vector basemap layer.What's next?
Learn how to use additional ArcGIS location services in these tutorials: