L.esri.IdentifyFeatures

Extends L.esri.Task

L.esri.IdentifyFeatures is an abstraction for the Identify API found in Map Services. It provides a chainable API for building request parameters and executing the request.

Constructor

ConstructorDescription
L.esri.identifyFeatures(<MapService>endpoint)L.esri.identifyFeatures(<Object>options)Accepts either an options object or an instance of .

Options

OptionTypeDefaultDescription
urlString''URL of the ArcGIS service you would like to consume.
proxyStringfalseURL of an ArcGIS API for JavaScript proxy or ArcGIS Resource Proxy to use for proxying POST requests.
useCorsBooleantrueIf this task should use CORS when making GET requests.

Methods

MethodReturnsDescription
on(<Map>map)thisThe map to identify features on.
at(<Geometry>geometry)thisIdentifies features at a given LatLng. geometry can also be an instance of L.Marker, L.Polygon, L.Polyline , L.LatLngBounds, L.GeoJSON or a valid GeoJSON object literal.
layerDef(<Integer>id, <String>where)thisAdd a layer definition to the query.
between(<Date>from, <Date>to)thisIdentifies features within a given time range.
layers(<String>layers)this

By default, all features will be identified, but it is possible to specify both an alternative strategy and array of individual layers. See the REST API documentation for more information about valid combinations. ex: .layers('all:0').

precision(<Integer>precision)thisUsed to cap the number of decimal points included in output geometries.
tolerance(<Integer>precision)thisBuffer the identify area by a given number of screen pixels.
returnGeometry(<Boolean>returnGeometry)thisReturn geometry with results. Default is true.
simplify(<Map>map, <Number>factor)thisSimplify the geometries of the output features for the current map view. the factor parameter controls the amount of simplification between 0 (no simplification) and 1 (the most basic shape possible).
format(<Boolean>formatResponse)thisUse false to ensure that the server returns unformatted feature attributes.Only available for ArcGIS Server 10.5+.
token(<String>token)thisAdds a token to this request if the service requires authentication. Will be added automatically if used with a service.
run(<Function>callback, <Object>context)thisExecutes the identify request with the current parameters, identified features will be passed to callback as a GeoJSON FeatureCollection. Accepts an optional function context

Example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var map = new L.Map('map').setView([45.543, -122.621], 5);

L.esri.identifyFeatures({
    url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer'
})
    .on(map)
    .at([45.543, -122.621])
    .layers('visible:1')
    .run(function (error, featureCollection, response) {
        if (error) {
        console.log(error);
        return;
        }
    console.log('UTC Offset: ' + featureCollection.features[0].properties.ZONE);
});

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.