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

Constructor Description
L.esri.identifyFeatures(<MapService> endpoint)

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

Options

Option Type Default Description
url String '' URL of the ArcGIS service you would like to consume.
proxy String false URL of an ArcGIS API for JavaScript proxy or ArcGIS Resource Proxy to use for proxying POST requests.
useCors Boolean true If this task should use CORS when making GET requests.

Methods

Method Returns Description
on(<Map> map) this The map to identify features on.
at(<Geometry> geometry) this Identifies 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) this Add a layer definition to the query.
between(<Date> from, <Date> to) this Identifies 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) this Used to cap the number of decimal points included in output geometries.
tolerance(<Integer> precision) this Buffer the identify area by a given number of screen pixels.
returnGeometry(<Boolean> returnGeometry) this Return geometry with results. Default is true.
simplify(<Map> map, <Number> factor) this Simplify 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) this Use false to ensure that the server returns unformatted feature attributes.
Only available for ArcGIS Server 10.5+.
token(<String> token) this Adds a token to this request if the service requires authentication. Will be added automatically if used with a service.
run(<Function> callback, <Object> context) this Executes the identify request with the current parameters, identified features will be passed to callback as a GeoJSON FeatureCollection. Accepts an optional function context

Example

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);
  });

Edit this page on GitHub