Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                Note: this logic is wrapped up in a package you can use here: <a href="https://www.npmjs.com/package/query-all-features">https://www.npmjs.com/package/query-all-features</a>
<br /><br />
Query Results:<br/><br />

<pre id="results"></pre>

              
            
!

CSS

              
                
              
            
!

JS

              
                // Note: this logic is wrapped up in a package you can use here:
// https://www.npmjs.com/package/query-all-features
// 
// demo here: https://codepen.io/gavinr/pen/ExQYegd?editors=0010
//
// More info: https://gavinr.com/arcgis-javascript-query-all-features/
//
require(["esri/layers/FeatureLayer"], function (
  FeatureLayer
) {
  
  // The "public" function that can be called by passing a reference to the
  // layer. Only provided so the "user" of this module (you) does not have to rememeber
  // to pass [] as the second parameter to the recursive function.
  const getAllFeatures = (layer) => {
    return _getAllFeaturesRecursive(layer, []);
  };

  // Recursive function - Handles calling the service multiple times if necessary.
  const _getAllFeaturesRecursive = (layer, featuresSoFar) => {
    console.log("got features:", featuresSoFar.length);

    return layer
      .queryFeatures({
        start: featuresSoFar.length,
        num: layer.capabilities.query.maxRecordCount,
        // where: "st = 'CA'",
        outFields: ['*']
      })
      .then((results) => {
      // If "exceededTransferLimit" is true, then make another request (call 
      //  this same function) with a new "start" position. If not, we're at the end
      // and we should just concatenate the results and return what we have.
        if (
          results.exceededTransferLimit &&
          results.exceededTransferLimit === true
        ) {
          return _getAllFeaturesRecursive(layer, [
            ...featuresSoFar,
            ...results.features
          ]);
        } else {
          return Promise.resolve([...featuresSoFar, ...results.features]);
        }
      });
  };

  const featureLayer = new FeatureLayer({
    url:
      "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"
  });

  // We're calling `.when()` and `.load()` below because the layer is not being loaded in a Map and 
  // MapView --
  // Most likely your app is using Map and MapView/SceneView.when(), so you can ignore that and simply:
  //
  // 1. Copy the above functions (getAllFeatures and _getAllFeaturesRecursive) into your app
  // 2. Call: getAllFeatures(featureLayer).then((results) => { ... });
  //
  featureLayer.when(() => {
    getAllFeatures(featureLayer).then((results) => {
      console.log('results', results);
      document.getElementById('results').innerHTML = `${results.length} results: <br /><br />` +  JSON.stringify(results, null, 4);
    });
  });
  featureLayer.load();
});

              
            
!
999px

Console