L.esri.Vector.vectorTileLayer

Extends L.Layer

L.esri.Vector.vectorTileLayer uses the esri-leaflet-vector plugin to display vector tile service layers and their styles published from user data.

Your vector tile service must be published using the Web Mercator Auxiliary Sphere tiling scheme (WKID 102100/3857) and the default scale options used by Google Maps, Bing Maps and ArcGIS Online. The esri-leaflet-vector plugin will not support any other spatial reference for vector tile layers because it relies directly upon maplibre-gl-js.

Constructor

Note: There are two ways to construct this layer with the required key parameter, either with an item ID or service URL of a hosted vector tile layer.

ConstructorDescription
L.esri.Vector.vectorTileLayer(<String> key, <Object> options)key refers to the specific item ID or service URL of a hosted vector tile layer you'd like to add.

Options

L.esri.Vector.vectorTileLayer accepts all L.Layer options.

OptionTypeDefaultDescription
apikeyStringIf you pass an apikey in your options it will be included in all requests to the service.
tokenStringIf you pass a token in your options it will be included in all requests to the service.
portalUrlString'https://www.arcgis.com'Specify the ArcGIS Enterprise base URL if your layer is not hosted on ArcGIS Online.
styleFunctionFunction that can be used to customize the style. It gets the default style from the service and returns the new style to be used. See example below.
preserveDrawingBufferBooleanfalseSets the associated property in the underlying Maplibre GL library. Set to true to resolve WebGL printing issues in Firefox. It is set to false by default for performance reasons.

Methods

L.esri.Vector.vectorTileLayer inherits all methods from L.Layer.

Examples

Add a vector tile layer

This example displays a vector tile layer hosted in ArcGIS Online using its ArcGIS item ID.

Use dark colors for code blocksCopy
1
<script src="./esri-leaflet-vector.js"></script>
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
const map = L.map('map').setView([34.02,-118.805], 13);

// using an item ID of an hosted ArcGIS Online content item
// https://esri.maps.arcgis.com/home/item?id=f40326b0dea54330ae39584012807126
L.esri.Vector.vectorTileLayer("f40326b0dea54330ae39584012807126").addTo(map);

// or, using a service URL instead
L.esri.Vector.vectorTileLayer(
    "https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer"
).addTo(map);

Style a vector tile layer

This example performs client-side styling of a vector tile layer by accessing the underlying maplibre object used in Esri Leaflet Vector.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
const map = L.map('map').setView([34.02,-118.805], 13);

L.esri.Vector.vectorTileLayer(
"https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer", {
    style: function (style) {
        style.layers[0].paint['fill-color'] = '#ff0000';
        return style;
    }
}).addTo(map);

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.