L.esri.Vector.vectorBasemapLayer

Extends L.esri.Vector.vectorTileLayer

L.esri.Vector.vectorBasemapLayer uses the esri-leaflet-vector plugin to display vector tile basemaps from the Basemap styles service. It also handles basemap attribution.

Constructor

ConstructorDescription
L.esri.Vector.vectorBasemapLayer(<String> key, <Object> options)

key refers to a basemap style enumeration, or to the item ID of a custom basemap style. Defaults to ArcGIS:Streets.

The required key parameter can be used to display either a basemap style enumeration or a custom basemap style.

Basemap style enumerations

Basemap style enumerations represent predefined basemap styles provided by ArcGIS. Set the key parameter to a valid style enumeration to load a basemap into your application.

V1 enumerations

Style enumerations from the Basemap styles service v1 contain two or three parts separated by a colon (:). Each part is written in camel case without spaces between words:

  • {Provider}:{StyleName}
  • {Provider}:{StyleName}:{Component}

Some examples include:

  • ArcGIS:Imagery
  • ArcGIS:HumanGeography:Detail
  • OSM:Standard

V2 enumerations

Style enumerations from the Basemap styles service (v2) contain two or three parts separated by a forward slash (/). Each part is written in lowercase with words separated by dashes:

  • {provider}/{style-name}
  • {provider}/{style-name}/{component}

Some examples include:

  • arcgis/imagery
  • arcgis/human-geography/detail
  • osm/standard

Custom basemap styles

L.esri.Vector.vectorBasemapLayer also supports custom basemap styles created with the Vector Tile Style Editor. To load a custom basemap style, set the key parameter to its item ID.

Options

L.esri.Vector.vectorBasemapLayer accepts all L.esri.Vector.vectorTileLayer options, though portalUrl has no effect. A valid API key or token is required to load a vector basemap layer.

OptionTypeDescription
apikeyString

Inherited from VectorTileLayer. A valid API key or token is required to access the Basemap styles service.

tokenString

Inherited from VectorTileLayer. A valid API key or token is required to access the Basemap styles service.

versionString

Specifies the version of the Basemap styles service to be used. Accepted values are 1 or 2. If unspecified, the version will be set automatically based on the provided key.

languageString

Only supported by the Basemap styles service v2. Sets the language of the place labels on the map. Input must be a supported language code. Right-to-left languages like Arabic and Hebrew require additional configuration using the setRTLTextPlugin method.

worldviewString

Only supported by the Basemap styles service v2 on certain styles. Changes the political worldview. Input must be a supported worldview code.

placesString

Only supported by the Basemap styles service v2 on certain styles. Displays places of interest on the basemap. Input must be a supported value: none, all, or attributed.

styleFunction

Inherited from VectorTileLayer . Function that can be used to customize the individual layers in a basemap style.

function (style) {
    // make changes to the style object
    // return your style overrides
    return newStyleObj;

}

Default panes

By default, L.esri.Vector.vectorBasemapLayer objects are added to Leaflet maps using the following panes:

Basemap typeLeaflet PanezIndex

Label enumeration ending in :Labels or /labels

esri-labels300

Detail enumeration ending in :Detail or /detail

esri-detail250

Default (all other basemaps)

tilePane200

Methods

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

Examples

Display a basemap style (v1)

This example loads the ArcGIS Streets basemap using a v1 style enumeration.

Use dark colors for code blocksCopy
1
2
3
4
5
  const map = L.map("map").setView([40.706, -73.926], 14);

  L.esri.Vector.vectorBasemapLayer("ArcGIS:Streets", {
      apikey: "YOUR-API-KEY", // provide either apikey or token
  }).addTo(map);

Display a basemap style (v2)

This example loads the ArcGIS Outdoor basemap using a v2 style enumeration.

Use dark colors for code blocksCopy
1
2
3
4
5
6
  const map = L.map("map").setView([40.706, -73.926], 14);

  L.esri.Vector.vectorBasemapLayer("arcgis/outdoor", {
      apikey: "YOUR-API-KEY", // provide either apikey or token
      version: 2 // this property is optional
  }).addTo(map);

Display a custom basemap

This example loads a custom basemap by referencing its ArcGIS item ID. This method defaults to using the v1 service, but is also supported through the v2 service.

Use dark colors for code blocksCopy
1
2
3
4
5
  const map = L.map("map").setView([40.706, -73.926], 14);

  L.esri.Vector.vectorBasemapLayer("6976148c11bd497d8624206f9ee03e30", {
      apikey: "YOUR-API-KEY", // provide either apikey or token
  }).addTo(map);

Display places labels in a different language

This example changes the language of place labels on a basemap. The language property is only supported for v2 style enumerations, and is not currently supported for custom basemaps.

Use dark colors for code blocksCopy
1
2
3
4
5
6
  const map = L.map("map").setView([40.706, -73.926], 14);

  L.esri.Vector.vectorBasemapLayer("arcgis/streets", {
      apikey: "YOUR-API-KEY", // provide either apikey or token
      language: "uk" // set language to Ukranian
  }).addTo(map);

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