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
fetchOptionsobjectCustom fetch options (headers, etc.)
tokenstringArcGIS authentication token
getAttributionFromServicebooleantrueFetch copyright text from service metadata

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