require(["esri/tasks/geoenrichment/GeographyQuery"], function(GeographyQuery) { /* code goes here */ });
Description
(Added at v3.12)
(Currently in beta)
Represents StandardGeographyQuery parameters to search for geographies by ID or Name.
Samples
Search for
samples that use this class.
Class hierarchy
esri/tasks/geoenrichment/GeographyQueryBase
|_esri/tasks/geoenrichment/GeographyQuery
Constructors
Properties
Methods
Constructor Details
Creates a new instance of the GeographyQuery object.
Sample: Query for zip codes in San Diego
require([
"esri/tasks/geoenrichment/GeographyQuery", ...
], function(GeographyQuery, ...) {
var query = new GeographyQuery({
countryID: "US",
datasetID: "USA_ESRI_2013",
generalizationLevel: "6",
geographyIDs: ["92129", "92126"],
geographyLayerIDs: ["US.ZIP5"],
returnGeometry: "true"
});
...
});
Query for cities and counties in the US that contain "San" in their name
require([
"esri/tasks/geoenrichment/GeographyQuery", ...
], function(GeographyQuery, ...) {
var query = new GeographyQuery({
countryID: "US",
datasetID: "USA_ESRI_2013",
generalizationLevel: "6",
geographyLayerIDs: ["US.Counties", "US.Places"],
returnGeometry: "true",
returnCentroids: "true",
where: "San"
});
...
});
Query for all municipalities in France
require([
"esri/tasks/geoenrichment/GeographyQuery", ...
], function(GeographyQuery, ...) {
var query = new GeographyQuery({
countryID: "FR",
datasetID: "FRANCE",
generalizationLevel: "6",
geographyLayerIDs: ["FR.Commune"],
returnGeometry: "true"
});
...
});
Property Details
Two-digit country code. For example: "US".
Optional string that denotes the ID of a dataset associated with a particular country.
Sample: query.datasetID = 'US.Census2010';
Optional integer value where you can limit the number of features that are returned from the geographyQuery. If null
, the server will default to 1000.
Optional integer that specifies the level of generalization of the geometries. A value of 0 returns the most detailed and 6 is most generalized. Some geography layers, like 'countries', do not support returning highly detailed geometries.
Known values: 0|1|2|3|4|5|6
Default value: 0
Array of geography IDs. Use this property to return attributes and/or geometries for standard geographic areas for administrative areas where you already know the ID, for example, if you know the Federal Information Processing Standard (FIPS) Codes for a U.S. state or county; or, in Canada, to return the geometry and attributes for a Forward Sortation Area (FSA). Note: only returns features from layers specified in the geographyLayerIDs property.
Array of geography layer IDs.
Determines spatial reference for output geometry if returnGeometry is set to true.
Use this parameter to return all the geometries as points. For example, you could return all U.S. ZIP Codes as centroids. Only applies if the returnGeometry property is also set to true.
Known values: true | false
Default value: false
Determines whether response will also include geometries.
Known values: true | false
Default value: false
Optional boolean to enable fuzzy search. See the
REST API for details about using fuzzy logic.
Known values: true | false
Default value: false
A where clause for the query. Use this property to query for specific areas, for example, all U.S. counties that contain the word "orange".
Optionally, you can specify to search by ID or by Name, for example:
query.where = 'ID:06069'
or
query.where = 'NAME:"Orange County"'
.
Notes
- Use the geographyLayerIDs property to define which layers are being searched. To achieve optimal performance, it is strongly recommended that at least one layer is defined in the geographyLayerIDs property. If no geographyLayerIDs are provided, all standard geography layers will be searched within sourceCountry. This will adversely affect performance.
- If the useFuzzySearch property is set to true, all words submitted with geographyQuery will be searched with fuzzy logic. If it is set to false, a standard text search is performed for all text submitted.
- Searches within the geography query are not case sensitive.
See
Standard geograpy query REST API for more details on the query syntax.
Method Details
Converts object to its JSON representation. Field names in the JSON will match field names used by the
REST API.