Add a published vector tile layer to an existing map.
A vector tile layer is a hosted data layer. The data is vector tile data. You can create a vector tile layer by publishing your data with data management tools.
In this tutorial, you display a parcels layer from a public vector tile service, using the default styling.
Prerequisites
You need an ArcGIS Developer or ArcGIS Online account to access the dashboard and create an API key.
Steps
Create a new pen
- To get started, either complete the Display a map tutorial or .
Set the API key
To access ArcGIS services, you need an API key.
- Go to your dashboard to get an API key.
- In CodePen, set the
api
to your key, so it can be used to access basemap layer and location services.Key
esriConfig.apiKey = "YOUR_API_KEY";
const map = new Map({
basemap: "arcgis/topographic" // basemap styles service
});
Add modules
- In the
require
statement, add theVector
module.Tile Layer
The ArcGIS Maps SDK for JavaScript is available as AMD modules and ES modules, but this tutorial is based on AMD. The AMD require
function uses references to determine which modules will be loaded – for example, you can specify "esri/Map"
for loading the Map module. After the modules are loaded, they are passed as parameters (e.g. Map
) to the callback function where they can be used in your application. It is important to keep the module references and callback parameters in the same order. For more information on the different types of modules, visit the Introduction to Tooling guide topic.
require([
"esri/config",
"esri/Map",
"esri/layers/VectorTileLayer",
"esri/views/MapView"
], function (esriConfig, Map, VectorTileLayer, MapView) {
Add the vector tile layer
- Create a
Vector
. Set the theTile Layer url
property to reference the vector tile layer.
], function (esriConfig, Map, VectorTileLayer, MapView) {
const vtlLayer = new VectorTileLayer({
url: "https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer/"
});
Update the map
esriConfig.apiKey = "YOUR_API_KEY";
const map = new Map({
basemap: "arcgis/light-gray",
layers: [vtlLayer]
});
Run the App
In CodePen, run your code to display the map.
You should see the vector tile layer with parcels displayed on the basemap layer.
What's next?
Learn how to use additional API features and ArcGIS services in these tutorials: