Services Overview
esri-gl provides service classes that integrate Esri ArcGIS REST services with MapLibre GL JS and Mapbox GL JS.
Architecture
Service-Source Pattern
Services create MapLibre/Mapbox GL sources and manage their lifecycle:
const service = new DynamicMapService('source-id', map, { url: '...' })
map.addLayer({ id: 'layer-id', type: 'raster', source: 'source-id' })
Universal Constructor
All services follow this signature:
new ServiceClass(sourceId: string, map: Map, esriOptions: Options, sourceOptions?: SourceOptions)
Service Comparison
| Service | Data Type | Performance | Customization | Best For |
|---|---|---|---|---|
| DynamicMapService | Server raster | Moderate | Full | Interactive layers, real-time data |
| TiledMapService | Cached raster | Excellent | Limited | Basemaps, reference layers |
| ImageService | Analytical raster | Variable | Full | Satellite imagery, elevation |
| FeatureService | GeoJSON / Vector tiles | Good | Full | Editable features, client-side styling |
| VectorTileService | Vector tiles | Excellent | Full | Large vector datasets |
| VectorBasemapStyle | Style definition | Excellent | Themed | Professional basemaps |
Common Patterns
Service Lifecycle
// Create
const service = new DynamicMapService('my-source', map, { url: '...' });
map.addLayer({ id: 'my-layer', type: 'raster', source: 'my-source' });
// Update
service.setLayerDefs({ 0: 'NEW_FILTER = 1' });
// Remove
service.remove();
Task-Based Operations
Services support identify and query operations:
// Identify at a click location
const results = await dynamicService.identify(e.lngLat, true);
// Standalone task with chaining
const results = await new IdentifyFeatures({ url: '...' })
.at({ lng: -95, lat: 37 })
.on(map)
.layers('visible:0,1,2')
.tolerance(5)
.run();
See individual service pages for detailed documentation, live demos, and examples.