Skip to content

Add a published vector tile layer to an existing map.

Pan and zoom the map to explore the 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

Steps

Create a new pen

  1. To get started, either complete the Display a map tutorial or .

Get an access token

You need an access token with the correct privileges to access the location services used in this tutorial.

  1. Go to the Create an API key tutorial and create an API key with the following 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.
  2. In CodePen, set the apiKey property on the global esriConfig variable to your access token.
    var esriConfig = {
    apiKey: "YOUR_ACCESS_TOKEN",
    };

To learn about other ways to get an access token, go to Types of authentication.

Update the map

  1. Update the basemap attribute to display a gray basemap and change the zoom level.
    26 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Add a vector tile layer</title>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    <script>
    var esriConfig = { apiKey: "YOUR_ACCESS_TOKEN" };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    </head>
    <body>
    <arcgis-map basemap="arcgis/light-gray" center="-118.805, 34.020" zoom="12">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    4 collapsed lines
    </body>
    </html>

Add modules

  1. In a new <script> at the bottom of the <body>, use $arcgis.import to add the VectorTileLayer module.
    31 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Add a vector tile layer</title>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    <script>
    var esriConfig = { apiKey: "YOUR_ACCESS_TOKEN" };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    </head>
    <body>
    <arcgis-map basemap="arcgis/light-gray" center="-118.805, 34.020" zoom="12">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const VectorTileLayer = await $arcgis.import("@arcgis/core/layers/VectorTileLayer.js");
    </script>
    4 collapsed lines
    </body>
    </html>

Add the vector tile layer

  1. Use the viewOnReady method to wait until the Map component is ready before adding the layer.

    31 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Add a vector tile layer</title>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    <script>
    var esriConfig = { apiKey: "YOUR_ACCESS_TOKEN" };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    </head>
    <body>
    <arcgis-map basemap="arcgis/light-gray" center="-118.805, 34.020" zoom="12">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const VectorTileLayer = await $arcgis.import("@arcgis/core/layers/VectorTileLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    </script>
    4 collapsed lines
    </body>
    </html>
  2. Create a VectorTileLayer and set the url property to reference the vector tile layer .

    31 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Add a vector tile layer</title>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    <script>
    var esriConfig = { apiKey: "YOUR_ACCESS_TOKEN" };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    </head>
    <body>
    <arcgis-map basemap="arcgis/light-gray" center="-118.805, 34.020" zoom="12">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const VectorTileLayer = await $arcgis.import("@arcgis/core/layers/VectorTileLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    const vtlLayer = new VectorTileLayer({
    url: "https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer/",
    });
    </script>
    4 collapsed lines
    </body>
    </html>
  3. Add the VectorTileLayer to the map.

    31 collapsed lines
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Add a vector tile layer</title>
    <style>
    html,
    body {
    height: 100%;
    margin: 0;
    }
    </style>
    <script>
    var esriConfig = { apiKey: "YOUR_ACCESS_TOKEN" };
    </script>
    <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
    <script type="module" src="https://js.arcgis.com/5.0/"></script>
    </head>
    <body>
    <arcgis-map basemap="arcgis/light-gray" center="-118.805, 34.020" zoom="12">
    <arcgis-zoom slot="top-left"></arcgis-zoom>
    </arcgis-map>
    <script type="module">
    const VectorTileLayer = await $arcgis.import("@arcgis/core/layers/VectorTileLayer.js");
    const viewElement = document.querySelector("arcgis-map");
    await viewElement.viewOnReady();
    const vtlLayer = new VectorTileLayer({
    url: "https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer/",
    });
    viewElement.map.add(vtlLayer);
    </script>
    4 collapsed lines
    </body>
    </html>

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 SDK features and ArcGIS services in these tutorials: