Skip to main content

IdentifyFeatures

Identify features at a point across multiple layers in an ArcGIS MapServer.

Interactive Demo

Click anywhere on the map to identify features. Use the layer checkboxes to control which layers are queryable.

Quick Start

import { IdentifyFeatures } from 'esri-gl';

const identifyTask = new IdentifyFeatures({
url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer',
});

const results = await identifyTask
.at({ lng: -100, lat: 40 }, map)
.layers([0, 1, 2])
.tolerance(5)
.returnGeometry(true);

Constructor

new IdentifyFeatures(options: IdentifyOptions)

Options

OptionTypeDefaultDescription
urlstringRequired. MapServer URL
layersArray<number> | string'all'Layers to identify
tolerancenumber3Search tolerance in pixels
returnGeometrybooleanfalseInclude feature geometry
maxAllowableOffsetnumberGeometry simplification
geometryPrecisionnumberDecimal places for geometry
dynamicLayersArray<object>Dynamic layer definitions
mapExtentobjectCurrent map extent
imageDisplayobjectMap image parameters
returnFieldNamebooleanfalseReturn field names with values
returnUnformattedValuesbooleanfalseReturn raw field values
tokenstringAuthentication token

Chainable Methods

MethodParameterDescription
.layers(layers)number[] | stringSet layers to identify (IDs or 'all', 'visible')
.tolerance(pixels)numberSet search radius in pixels
.returnGeometry(include)booleanInclude feature geometry in results
.returnFieldName(include)booleanReturn field names with values
.token(authToken)stringSet authentication token

Execution Methods

.at(point, map, callback?)

Execute identification at a geographic point. Returns a Promise with results.

  • point: {lng: number, lat: number} or [lng, lat]
  • map: MapLibre GL or Mapbox GL map instance
  • callback: Optional callback function

.on(map)

Bind identify to map click events.

  • map: MapLibre GL or Mapbox GL map instance

.run()

Execute the configured identify request manually.

Examples

Basic Identification

const identifyTask = new IdentifyFeatures({
url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer',
});

map.on('click', async e => {
const results = await identifyTask.at(e.lngLat, map);
console.log('Identified features:', results);
});

With Layer Filtering

const identifyTask = new IdentifyFeatures({
url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer',
})
.layers([0, 1, 2])
.tolerance(10)
.returnGeometry(true);

const results = await identifyTask.at({ lng: -95, lat: 37 }, map);