query-all-features v1.0.0
Query All Features
Query all features of an ArcGIS Feature Service
This package calls queryFeatures multiple times until it gets all the features.
Quick Start
npm install query-all-features
Then:
import { queryAllFeatures } from "query-all-features";
queryAllFeatures(
{
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"
}
).then((results) => {
console.log('results', results);
}, (err) => {
console.error('err', err);
});
API Reference
queryAllFeatures
Query a feature service, repeatedly paging through the results to get all the features.
Parameters
Parameter | Type | Notes |
---|---|---|
requestOptions | IQueryFeaturesOptions | This is the same input object that you would pass into ArcGIS REST JS queryFeatures. |
additionalOptions | IQueryFeaturesAllAdditionalOptions | Additional options specific to this module. See table below. |
IQueryFeaturesAllAdditionalOptions
Parameter | Type | Notes |
---|---|---|
pageBy (optional) | number | How many records to request from the service at a time. By default, the service info will be checked to find the maxRecordCount of the service, and that will be used as the pageBy value. If this pageBy value is provided, that additional request will not be made. |
import { queryAllFeatures } from "query-all-features";
queryAllFeatures(
{
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"
}, {
pageBy: 100
}
).then((results) => {
console.log('results', results);
}, (err) => {
console.error('err', err);
});
Returns
A Promise that will resolve with the same query response as queryFeatures.
Usage
Node JS
npm install query-all-features
Then:
const { queryAllFeatures } = require("query-all-features");
queryAllFeatures({url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"}).then((results) => {
console.log('results', results);
}, (err) => {
console.error('err', err);
});
Browser - ES Modules
Distributed as an ES module which should work "out-of-the-box" with most popular module bundlers. See "Quick Start" above.
Browser - ES Modules via CDN
<script type="module">
import { queryAllFeatures } from "https://cdn.skypack.dev/query-all-features";
queryAllFeatures({url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"}).then((results) => {
console.log('results', results);
}, (err) => {
console.error('err', err);
});
</script>
Browser - Script tag via UMD CDN
<!-- arcgis-rest-request and arcgis-rest-feature-service are dependencies: -->
<script src="https://unpkg.com/@esri/arcgis-rest-request@4"></script>
<script src="https://unpkg.com/@esri/arcgis-rest-feature-service@4"></script>
<script src="https://unpkg.com/query-all-features"></script>
<script>
queryAllFeatures.queryAllFeatures({url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"}).then((results) => {
console.log('results', results);
}, (err) => {
console.log('err', err);
});
</script>
License
Copyright 2022 Gavin Rehkemper
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.