Skip to main content

TiledMapService

Pre-rendered cached map tiles from ArcGIS Tiled Map Services. Fast performance, consistent styling, ideal for basemaps.

Live Demo

Interactive demo showing pre-rendered cached map tiles with layer visibility controls.

Quick Start

npm install esri-gl maplibre-gl
import { TiledMapService } from 'esri-gl';

const service = new TiledMapService('topo-source', map, {
url: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer'
});

map.addLayer({
id: 'topo-layer',
type: 'raster',
source: 'topo-source'
});

Constructor

new TiledMapService(id, map, esriServiceOptions, rasterSourceOptions?)
ParameterTypeDescription
idstringUnique source ID for MapLibre
mapMapMapLibre map instance
esriServiceOptionsobjectService configuration (see below)
rasterSourceOptionsobjectOptional MapLibre raster source overrides

Options (esriServiceOptions)

OptionTypeDefaultDescription
urlstringrequiredArcGIS MapServer URL
fetchOptionsobjectDeprecated — no longer forwarded to requests; use authentication instead.
tokenstringArcGIS authentication token
apiKeystringArcGIS Location Platform API key (sent as the token parameter)
authenticationIAuthenticationManager | stringArcGIS REST JS auth manager (preferred for OAuth/user sign-in)
getAttributionFromServicebooleantrueFetch copyright text from service metadata

Authentication runs on ArcGIS REST JS. See the Authentication guide for tokens, API keys, and auth managers.

Methods

MethodReturnsDescription
getMetadata()Promise<ServiceMetadata>Fetches service metadata (tile info, extent, attribution)
setToken(token)voidUpdates the authentication token

Examples

Opacity Control

map.setPaintProperty('topo-layer', 'raster-opacity', 0.5);

Layer Visibility

map.setLayoutProperty('topo-layer', 'visibility', 'none');    // Hide
map.setLayoutProperty('topo-layer', 'visibility', 'visible'); // Show

Service Information

const info = await service.getServiceInfo();
console.log(info.tileInfo); // Tile scheme information
console.log(info.fullExtent); // Service extent
console.log(info.copyrightText); // Attribution text