Display a custom vector tile style
Learn how to add a styled 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 the basemap styles service or you can create your own custom styles with the ArcGIS Vector Tile Style Editor for specific mapping applications.
In this tutorial you use OpenLayers to display a styled vector basemap layer in a map.
You need an ArcGIS Developer or ArcGIS Online account to access the developer dashboard and create an API key.
Create a new pen
- To get started, either complete the Display a map tutorial or .
Set the API key
To access location services, you need an API key or OAuth 2.0 access token. To learn how to create and scope your key, visit the Create an API key tutorial.
Go to your dashboard to get an API key. The API key must be scoped to access the services used in this tutorial.
In CodePen, update
apito use your key.
Key Use dark colors for code blocks Change line
const apiKey = "YOUR_API_KEY"; const basemapId = "ArcGIS:Streets"; const basemapURL = "https://basemaps-api.arcgis.com/arcgis/rest/services/styles/" + basemapId + "?type=style&token=" + apiKey; olms.apply(map, basemapURL);
Add the vector tile layer
You can access a basemap layer by referencing its item ID. You can find a layer's item ID by accessing it inArcGIS Online or the ArcGIS Vector Tile Style Editor.
Go to the Forest and Parks Canvas vector tile layer in ArcGIS Online and find its item ID. The ID is at the end of the URL.
ArcGIS:to your own item ID.
Streets Expand Use dark colors for code blocks Change line
const apiKey = "YOUR_API_KEY"; const basemapId = "6976148c11bd497d8624206f9ee03e30"; // Custom vector tile style const basemapURL = "https://basemaps-api.arcgis.com/arcgis/rest/services/styles/" + basemapId + "?type=style&token=" + apiKey; olms.apply(map, basemapURL);
Run the app
In CodePen, run your code to display the map.
It should display the Forest and Parks Canvas vector basemap layer.
Learn how to use additional ArcGIS location services in these tutorials: