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.
PrerequisitesYou need a free ArcGIS developer account to access your dashboard and API keys . The API key must be scoped to access the services used in this tutorial.
Steps Create a new penTo get started, either complete the Display a map tutorial or use this pen . Set the API keyTo access ArcGIS services , you need an API key .
Go to your dashboard to get an API key .
In CodePen , set the apiKey
to your key, so it can be used to access basemap layer and location services.
Change line
esriConfig.apiKey = "YOUR-API-KEY" ;
const map = new Map ({
basemap : "arcgis-topographic" //Basemap layer service
});
Add modulesIn the require
statement, add the VectorTileLayer
module.
More info The ArcGIS API for JavaScript uses AMD modules . The require
function is used to load modules so they can be used in the main function
. It's important to keep the module references and function parameters in the same order.
Show more lines
Add line. Change line
< html >
< head >
< meta charset = "utf-8" />
< meta
name = "viewport"
content = "initial-scale=1,maximum-scale=1,user-scalable=no"
/>
< title > ArcGIS API for JavaScript: Add a vector tile layer </ title >
< style >
html ,
body ,
#viewDiv {
padding : 0 ;
margin : 0 ;
height : 100% ;
width : 100% ;
}
</ style >
< link rel = "stylesheet" href = "https://js.arcgis.com/4.18/esri/themes/light/main.css" >
< script src = "https://js.arcgis.com/4.18/" > </ script >
< script >
require ([
"esri/config" ,
"esri/Map" ,
"esri/layers/VectorTileLayer" ,
"esri/views/MapView"
], function ( esriConfig,Map, VectorTileLayer, MapView ) {
const vtlLayer = new VectorTileLayer({
url : "https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer/"
});
esriConfig.apiKey = "YOUR-API-KEY" ;
const map = new Map ({
basemap : "arcgis-light-gray" ,
layers : [vtlLayer]
});
const view = new MapView({
container : "viewDiv" ,
center : [ -118.80543 , 34.02700 ],
zoom : 13 ,
map : map
});
});
</ script >
</ head >
< body >
< div id = "viewDiv" > </ div >
</ body >
</ html >
Show more lines
Add the vector tile layerCreate a VectorTileLayer
. Set the the url
property to reference the vector tile layer .
Show more lines
Add line. Add line. Add line.
< html >
< head >
< meta charset = "utf-8" />
< meta
name = "viewport"
content = "initial-scale=1,maximum-scale=1,user-scalable=no"
/>
< title > ArcGIS API for JavaScript: Add a vector tile layer </ title >
< style >
html ,
body ,
#viewDiv {
padding : 0 ;
margin : 0 ;
height : 100% ;
width : 100% ;
}
</ style >
< link rel = "stylesheet" href = "https://js.arcgis.com/4.18/esri/themes/light/main.css" >
< script src = "https://js.arcgis.com/4.18/" > </ script >
< script >
require ([
"esri/config" ,
"esri/Map" ,
"esri/layers/VectorTileLayer" ,
"esri/views/MapView"
], function ( esriConfig,Map, VectorTileLayer, MapView ) {
const vtlLayer = new VectorTileLayer({
url : "https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer/"
});
esriConfig.apiKey = "YOUR-API-KEY" ;
const map = new Map ({
basemap : "arcgis-light-gray" ,
layers : [vtlLayer]
});
const view = new MapView({
container : "viewDiv" ,
center : [ -118.80543 , 34.02700 ],
zoom : 13 ,
map : map
});
});
</ script >
</ head >
< body >
< div id = "viewDiv" > </ div >
</ body >
</ html >
Show more lines
Update the mapUpdate the basemap
property to display a gray basemap. Set the layers
to the vtlLayer
element.
Show more lines
Change line Add line.
< html >
< head >
< meta charset = "utf-8" />
< meta
name = "viewport"
content = "initial-scale=1,maximum-scale=1,user-scalable=no"
/>
< title > ArcGIS API for JavaScript: Add a vector tile layer </ title >
< style >
html ,
body ,
#viewDiv {
padding : 0 ;
margin : 0 ;
height : 100% ;
width : 100% ;
}
</ style >
< link rel = "stylesheet" href = "https://js.arcgis.com/4.18/esri/themes/light/main.css" >
< script src = "https://js.arcgis.com/4.18/" > </ script >
< script >
require ([
"esri/config" ,
"esri/Map" ,
"esri/layers/VectorTileLayer" ,
"esri/views/MapView"
], function ( esriConfig,Map, VectorTileLayer, MapView ) {
const vtlLayer = new VectorTileLayer({
url : "https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer/"
});
esriConfig.apiKey = "YOUR-API-KEY" ;
const map = new Map ({
basemap : "arcgis-light-gray" ,
layers : [vtlLayer]
});
const view = new MapView({
container : "viewDiv" ,
center : [ -118.80543 , 34.02700 ],
zoom : 13 ,
map : map
});
});
</ script >
</ head >
< body >
< div id = "viewDiv" > </ div >
</ body >
</ html >
Show more lines
Run the AppIn CodePen , run your code to display the map.
You should see the vector tile layer with parcels displayed on the basemap layer.
Learn how to use additional API features and
ArcGIS services in these tutorials: