queryFeatures
FunctionqueryFeatures(requestOptions: IQueryFeaturesOptions & { f: "json" }): Promise<IQueryFeaturesResponse | IQueryResponse>Query a feature service. See REST Documentation for more information.
import { queryFeatures } from '@esri/arcgis-rest-feature-service';
const response = await queryFeatures({
url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
where: "STATE_NAME = 'Alaska'"
});TypeScript note: return types for queryFeatures() depend on the literal value of f .
Inline objects infer literal f values automatically, but pre-declared objects may widen f to string .
To preserve a narrow return type for pre-declared objects, use a const assertion, explicit type with a literal declaration, or a satisfies clause.
const options = {
url: "https://.../FeatureServer/0",
f: "geojson" as const
};
const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollectionconst typedOptions: IQueryFeaturesOptions & { f: "geojson" } = {
url: "https://.../FeatureServer/0",
f: "geojson"
};
const typedResponse = await queryFeatures(typedOptions);
// typedResponse is EsriGeoJSONFeatureCollectionconst options = {
url: "https://.../FeatureServer/0",
f: "geojson"
} satisfies IQueryFeaturesOptions;
const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollectionParameters
| Parameter | Type | Notes |
|---|---|---|
request | IQueryFeaturesOptions & { f: "json" } | Options for the request |
Returns
Promise<IQueryFeaturesResponse | IQueryResponse>A Promise that will resolve with the query response.
queryFeatures(requestOptions: IQueryFeaturesOptions & { f: "geojson" | "pbf-as-geojson" }): Promise<EsriGeoJSONFeatureCollection>Query a feature service. See REST Documentation for more information.
import { queryFeatures } from '@esri/arcgis-rest-feature-service';
const response = await queryFeatures({
url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
where: "STATE_NAME = 'Alaska'"
});TypeScript note: return types for queryFeatures() depend on the literal value of f .
Inline objects infer literal f values automatically, but pre-declared objects may widen f to string .
To preserve a narrow return type for pre-declared objects, use a const assertion, explicit type with a literal declaration, or a satisfies clause.
const options = {
url: "https://.../FeatureServer/0",
f: "geojson" as const
};
const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollectionconst typedOptions: IQueryFeaturesOptions & { f: "geojson" } = {
url: "https://.../FeatureServer/0",
f: "geojson"
};
const typedResponse = await queryFeatures(typedOptions);
// typedResponse is EsriGeoJSONFeatureCollectionconst options = {
url: "https://.../FeatureServer/0",
f: "geojson"
} satisfies IQueryFeaturesOptions;
const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollectionParameters
| Parameter | Type | Notes |
|---|---|---|
request | IQueryFeaturesOptions & { f: "geojson" | "pbf-as-geojson" } | Options for the request |
Returns
Promise<EsriGeoJSONFeatureCollection>A Promise that will resolve with the query response.
queryFeatures(requestOptions: IQueryFeaturesOptions & { f: "pbf-as-arcgis" }): Promise<IQueryFeaturesResponse>Query a feature service. See REST Documentation for more information.
import { queryFeatures } from '@esri/arcgis-rest-feature-service';
const response = await queryFeatures({
url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
where: "STATE_NAME = 'Alaska'"
});TypeScript note: return types for queryFeatures() depend on the literal value of f .
Inline objects infer literal f values automatically, but pre-declared objects may widen f to string .
To preserve a narrow return type for pre-declared objects, use a const assertion, explicit type with a literal declaration, or a satisfies clause.
const options = {
url: "https://.../FeatureServer/0",
f: "geojson" as const
};
const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollectionconst typedOptions: IQueryFeaturesOptions & { f: "geojson" } = {
url: "https://.../FeatureServer/0",
f: "geojson"
};
const typedResponse = await queryFeatures(typedOptions);
// typedResponse is EsriGeoJSONFeatureCollectionconst options = {
url: "https://.../FeatureServer/0",
f: "geojson"
} satisfies IQueryFeaturesOptions;
const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollectionParameters
| Parameter | Type | Notes |
|---|---|---|
request | IQueryFeaturesOptions & { f: "pbf-as-arcgis" } | Options for the request |
Returns
Promise<IQueryFeaturesResponse>A Promise that will resolve with the query response.
queryFeatures(requestOptions: IQueryFeaturesOptions): Promise<IQueryFeaturesResponse | IQueryResponse>Query a feature service. See REST Documentation for more information.
import { queryFeatures } from '@esri/arcgis-rest-feature-service';
const response = await queryFeatures({
url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
where: "STATE_NAME = 'Alaska'"
});TypeScript note: return types for queryFeatures() depend on the literal value of f .
Inline objects infer literal f values automatically, but pre-declared objects may widen f to string .
To preserve a narrow return type for pre-declared objects, use a const assertion, explicit type with a literal declaration, or a satisfies clause.
const options = {
url: "https://.../FeatureServer/0",
f: "geojson" as const
};
const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollectionconst typedOptions: IQueryFeaturesOptions & { f: "geojson" } = {
url: "https://.../FeatureServer/0",
f: "geojson"
};
const typedResponse = await queryFeatures(typedOptions);
// typedResponse is EsriGeoJSONFeatureCollectionconst options = {
url: "https://.../FeatureServer/0",
f: "geojson"
} satisfies IQueryFeaturesOptions;
const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollectionParameters
| Parameter | Type | Notes |
|---|---|---|
request | IQueryFeaturesOptions | Options for the request |
Returns
Promise<IQueryFeaturesResponse | IQueryResponse>A Promise that will resolve with the query response.