Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/workers
Class: QueryTaskLocationProvider

require(["esri/tasks/locationproviders/QueryTaskLocationProvider"], function(QueryTaskLocationProvider) { /* code goes here */ });

Description

(Added at v3.12)
(Currently in beta)
The QueryTaskLocationProvider performs a query against a ArcGIS Feature service or Map service layer based on common fields that are present in both the data and the ArcGIS layer.

Samples

Search for samples that use this class.

Class hierarchy

esri/tasks/locationproviders/LocationProviderBase
|_esri/tasks/locationproviders/LocationProviderRemoteBase
  |_esri/tasks/locationproviders/QueryTaskLocationProvider

Constructors

NameSummary
new QueryTaskLocationProvider(options?)Creates a new instance of the QueryTaskLocationProvider object.

Properties

NameTypeSummary
geometryTypeStringThe geometry type of the returned features.
loadedBooleanReturns true when the load event has been fired.
queryParametersObjectA query parameter object that will be used to query the ArcGIS layer.
queryTaskQueryTaskAn instance of a QueryTask.
unicodeBooleanSet to true when querying a field that contains unicode characters.
whereFieldsObjectA mapping of the fields in the data and the ArcGIS layer to use to perform a join.

Methods

NameReturn typeSummary
locate(features, options?)DeferredAssigns geometries to the array of Graphic objects.

Events

[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.

Events

NameEvent ObjectSummary
error
{
  error: <Error>
}
Fires when an error occurs during locate.
loadFires after the provider has loaded.
locate-complete
{
  failed: <Graphic[]>,
  features: <Graphic[]>
}
Fires when the locate has completed.
locate-progress
{
  features: <Graphic[]>
}
Fires when the locate() method is in progress.
Constructor Details

new QueryTaskLocationProvider(options?)

Creates a new instance of the QueryTaskLocationProvider object.
Parameters:
<Object> options Optional Define the properties to use when creating the class. See options descriptions for further information.
options properties:
<Object> queryParameters Required Object containing properties that will be used to query the ArcGIS layer. See the queryParameters table for object details.
<QueryTask> queryTask Required An instance of a QueryTask.
<Boolean> unicode Required Set to true when querying a field that contains unicode characters.
<Object> whereFields Required A mapping of the fields in the data and the ArcGIS layer to use to perform a join.
Sample:
require([
  "esri/tasks/locationproviders/QueryTaskLocationProvider",
  "esri/tasks/QueryTask",
  ...
], function(QueryTaskLocationProvider, QueryTask,...) {
   var locationProvider: new QueryTaskLocationProvider({
       unicode: true,
       whereFields: {
         PREFECTURE: 'Prefecture'
       },
       queryParameters: {
         outFields: ['JCODE', 'PREFECTURE']
       },  
       queryTask: new QueryTask("http://services.arcgis.com/wlVTGRSYTzAbjjiC/ArcGIS/rest/services/Japan_Locators/FeatureServer/2")
   });
   ...
   locationProvider.locate(graphicsArray).then(function(results) {
     ...
   });
});
Property Details

<String> geometryType

The geometry type of the returned features.
Known values: "esriGeometryPoint" | "esriGeometryPolygon" | "esriGeometryPolyline"

<Boolean> loaded

Returns true when the load event has been fired.
Known values: true | false

<Object> queryParameters

A query parameter object that will be used to query the ArcGIS layer. See queryParameters table below for object details.
Object Specifications:
<queryParameters>
<Geometry> geometry Required The geometry to apply to the spatial filter.
<Number> maxAllowableOffset Required The maximum allowable offset used for generalizing geometries returned by the query operation.
<String[]> outFields Required Attribute fields to include in the result.
<Boolean> returnGeometry Required If true, each feature in the resulting FeatureSet includes the geometry.
<String> where Required A where clause for the query.

<QueryTask> queryTask

An instance of a QueryTask.

<Boolean> unicode

Set to true when querying a field that contains unicode characters.
Known values: true | false
Default value: false

<Object> whereFields

A mapping of the fields in the data and the ArcGIS layer to use to perform a join.
Method Details

locate(features, options?)

Assigns geometries to the array of Graphic objects.
Return type: Deferred
Parameters:
<Graphic[]> features Required An array of Graphic objects.
<Object> options Optional Optional parameters. See the Object Specifications table below for the structure of the options object.
Object Specifications:
<options>
<SpatialReference> outSpatialReference Required Spatial reference of the output geometry. Defaults to 4326 when not provided.
<Boolean> useExistingGeometries Required A property to notify whether geometry should be located for Graphic object that already has a geometry. The default value is false.
Event Details
[ On Style Events | Connect Style Event ]

error

Fires when an error occurs during locate.
Event Object Properties:
<Error> error Error message returned in a JavaScript error object.

load

Fires after the provider has loaded. The locate method can be called after this event.

locate-complete

Fires when the locate has completed.
Event Object Properties:
<Graphic[]> failed An array of the features that failed to complete successfully.
<Graphic[]> features An array of the completed features.

locate-progress

Fires when the locate() method is in progress.
Event Object Properties:
<Graphic[]> features A status message.