Query All Features from a Feature Service
When querying an ArcGIS Feature Service, there is typically a maximum number of features (records) that will be returned from any query – usually set to 1000. If you want to query for all the features in the service, ArcGIS REST JS does not currently do this (see this discussion) - you’ll need to make multiple REST calls to get them all. Use the package query-all-features to do this.
First install the package:
npm install query-all-features
Then use it in your code. It takes as input the same object as the queryFeatures endpoint of ArcGIS REST JS.
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);
});
You can also use it in NodeJS, in the browser via ES Modules (via CDN), and in the browser via a script tag. Here’s a full code sample in action:
More information is on GitHub: github.com/gavinr/query-all-features
Subscribe
Get an email summary of my blog posts (four per year):
... or follow the blog here: