Skip to main content

React Map GL Components

Drop-in components for using Esri services with react-map-gl. Works with both MapLibre GL and Mapbox GL.

Components

All components share these common props:

PropTypeDescription
idstringRequired Unique layer ID
sourceIdstringCustom source ID (defaults to id)
beforeIdstringInsert layer before this layer ID
visiblebooleanLayer visibility
tokenstringArcGIS token sent as token query param with every request
apiKeystringArcGIS API key sent via X-Esri-Authorization: Bearer header
proxystring | booleanProxy URL or flag forwarded to the service
getAttributionFromServicebooleanWhether to fetch attribution from the service (default true)
requestParamsRecord<string, unknown>Extra params merged into every service request
fetchOptionsRequestInitExtra fetch options used by the service
Authenticated services

Use token (or apiKey) on any layer component to access secured services:

<EsriDynamicLayer
id="secured"
url="https://your-server/arcgis/rest/services/Secure/MapServer"
token="YOUR_TOKEN"
/>

EsriVectorBasemapLayer still takes a required token prop (see below).

EsriDynamicLayer

Renders an Esri Dynamic Map Service as a raster layer.

PropTypeDefaultDescription
urlstringRequired MapService URL
layersnumber[] | number | falseLayer IDs to show
layerDefsRecord<string, string> | falseSQL filters per layer
formatstringImage format
dpinumberOutput DPI
transparentbooleanTransparent background
import { EsriDynamicLayer } from 'esri-gl/react-map-gl';

<Map>
<EsriDynamicLayer
id="census"
url="https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer"
layers={[2, 3]}
layerDefs={{ 2: "STATE_NAME='California'" }}
/>
</Map>

EsriTiledLayer

Renders an Esri Tiled Map Service as a raster layer.

PropTypeDescription
urlstringRequired Tiled MapService URL
import { EsriTiledLayer } from 'esri-gl/react-map-gl';

<Map>
<EsriTiledLayer
id="topo"
url="https://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer"
/>
</Map>

EsriImageLayer

Renders an Esri Image Service as a raster layer.

PropTypeDescription
urlstringRequired ImageService URL
renderingRuleRecord<string, unknown> | falseServer-side rendering rule
mosaicRuleRecord<string, unknown> | falseMosaic rule for image selection
formatstringImage format
import { EsriImageLayer } from 'esri-gl/react-map-gl';

<Map>
<EsriImageLayer
id="landcover"
url="https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover/ImageServer"
/>
</Map>

EsriFeatureLayer

Renders an Esri Feature Service as a GeoJSON vector layer.

PropTypeDefaultDescription
urlstringRequired Feature layer URL
wherestringSQL WHERE filter
outFieldsstring | string[]Fields to include
paintRecord<string, unknown>MapLibre paint properties
layoutRecord<string, unknown>MapLibre layout properties
import { EsriFeatureLayer } from 'esri-gl/react-map-gl';

<Map>
<EsriFeatureLayer
id="states"
url="https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3"
where="POP2000 > 5000000"
outFields={['STATE_NAME', 'POP2000']}
paint={{ 'fill-color': '#0080ff', 'fill-opacity': 0.4 }}
/>
</Map>

EsriVectorTileLayer

Renders an Esri Vector Tile Service. The service handles layer creation internally.

PropTypeDescription
urlstringRequired Vector Tile Service URL
import { EsriVectorTileLayer } from 'esri-gl/react-map-gl';

<Map>
<EsriVectorTileLayer
id="basemap-vtiles"
url="https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer"
/>
</Map>

EsriVectorBasemapLayer

Applies an Esri Vector Basemap Style to the map. Note: this replaces the entire map style rather than adding a layer.

PropTypeDescription
basemapEnumstringRequired Basemap style (e.g., 'arcgis/streets', 'arcgis/navigation')
tokenstringRequired Authentication token
import { EsriVectorBasemapLayer } from 'esri-gl/react-map-gl';

<Map>
<EsriVectorBasemapLayer
id="basemap"
basemapEnum="arcgis/navigation"
token="YOUR_TOKEN"
/>
</Map>

Integration Hooks

These hooks provide access to the underlying map instance and pre-configured service hooks for react-map-gl applications.

useEsriMaplibreLayer

Hook for using Esri services with MapLibre GL via react-map-gl.

Returns:

PropertyTypeDescription
mapMap | nullThe MapLibre GL map instance
useDynamicMapServicefunctionPre-configured hook
useTiledMapServicefunctionPre-configured hook
useImageServicefunctionPre-configured hook
useVectorTileServicefunctionPre-configured hook
useFeatureServicefunctionPre-configured hook
import { useEsriMaplibreLayer } from 'esri-gl/react-map-gl';

function MyLayer() {
const { map, useDynamicMapService } = useEsriMaplibreLayer();
const { service } = useDynamicMapService({
sourceId: 'census',
map,
options: { url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer' },
});
return null;
}

useEsriMapboxLayer

Hook for using Esri services with Mapbox GL via react-map-gl. Same API as useEsriMaplibreLayer but uses the Mapbox provider.

Returns:

PropertyTypeDescription
mapMap | nullThe Mapbox GL map instance
useDynamicMapServicefunctionPre-configured hook
useTiledMapServicefunctionPre-configured hook
useImageServicefunctionPre-configured hook
useVectorTileServicefunctionPre-configured hook
useFeatureServicefunctionPre-configured hook
import { useEsriMapboxLayer } from 'esri-gl/react-map-gl';

function MyLayer() {
const { map, useDynamicMapService } = useEsriMapboxLayer();
const { service } = useDynamicMapService({
sourceId: 'census',
map,
options: { url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer' },
});
return null;
}