Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ add another resource


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


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.


Save Automatically?

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.


                Query Results:<br/><br />

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





                // More info:
require(["esri/layers/FeatureLayer", "dojo/domReady!"], function (
) {
  // 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
        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, [
        } else {
          return Promise.resolve([...featuresSoFar, ...results.features]);

  const featureLayer = new FeatureLayer({

  // 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);