<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using CDFs, can a single Data Provider return several layers? in ArcGIS Enterprise Extensibility Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-extensibility-questions/using-cdfs-can-a-single-data-provider-return/m-p/1648272#M473</link>
    <description>&lt;P&gt;Hello. Thank you for the question.&lt;BR /&gt;Yes, it is possible to support multiple layers in your custom data provider. We generally advise to keep the provider logic limited to one layer per service to keep provider complexity to a minimum and performance maximized, but there are some recognized cases where multiple layers may be warranted. There are plans to add more documentation and samples around multiple layers in the future, but I can show you how to accomplish this now. Here is some pseudocode for the basics on how it works. In summary, you capture whether the request is a layer-level or service-level request. For the service-level request, return the three properties shown below: `layers`, `tables`, and `metadata`.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  async getData(req) {
    const layer = req.params.layer;
    let response;

    switch (layer) {
      case '0':
        response = this.getLayer0Data();
        break;

      case '1':
        response = this.getLayer1Data();
        break;

      default:
        response = this.getServiceLevelData();
        break;
    }
    return response;
  }

  async getLayer0Data() {
    // layer 0 logic  
    return {
      ...geojson,
      metadata: metadata
    };
  };

  getLayer1Data() {
    // layer 1 logic
    return {
      ...geojson,
      metadata: metadata
    };
  }

  getServiceLevelData() {
    return {
      layers: [this.getLayer0Data(), this.getLayer1Data()],
      tables: [],
      metadata: {
        // metadata
      }
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Sep 2025 16:30:30 GMT</pubDate>
    <dc:creator>John_Hash</dc:creator>
    <dc:date>2025-09-05T16:30:30Z</dc:date>
    <item>
      <title>Using CDFs, can a single Data Provider return several layers?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-extensibility-questions/using-cdfs-can-a-single-data-provider-return/m-p/1648167#M471</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have read through the docs and the Samples Github repo, but I have not yet found clarity regarding multi-layer CDFs.&lt;/P&gt;&lt;P&gt;At developer stage the console is pretty clear regarding the routes:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;debug: ROUTE | [GET, POST] | /test-layers/rest/services/FeatureServer
debug: ROUTE | [GET, POST] | /test-layers/rest/services/FeatureServer/layers
debug: ROUTE | [GET, POST] | /test-layers/rest/services/FeatureServer/:layer([0-9]+)
debug: ROUTE | [GET, POST] | /test-layers/rest/services/FeatureServer/:layer([0-9]+)/info
debug: ROUTE | [GET, POST] | /test-layers/rest/services/FeatureServer/:layer([0-9]+)/query
debug: ROUTE | [GET, POST] | /test-layers/rest/services/FeatureServer/*&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;However all the examples are singled-layer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to publish a custom data provider based service that exposes 2 or more layers?&lt;/P&gt;&lt;P&gt;If so, could a sample be added to the Github repo or shared here?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2025 08:03:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-extensibility-questions/using-cdfs-can-a-single-data-provider-return/m-p/1648167#M471</guid>
      <dc:creator>Francisco_R</dc:creator>
      <dc:date>2025-09-05T08:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using CDFs, can a single Data Provider return several layers?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-extensibility-questions/using-cdfs-can-a-single-data-provider-return/m-p/1648272#M473</link>
      <description>&lt;P&gt;Hello. Thank you for the question.&lt;BR /&gt;Yes, it is possible to support multiple layers in your custom data provider. We generally advise to keep the provider logic limited to one layer per service to keep provider complexity to a minimum and performance maximized, but there are some recognized cases where multiple layers may be warranted. There are plans to add more documentation and samples around multiple layers in the future, but I can show you how to accomplish this now. Here is some pseudocode for the basics on how it works. In summary, you capture whether the request is a layer-level or service-level request. For the service-level request, return the three properties shown below: `layers`, `tables`, and `metadata`.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  async getData(req) {
    const layer = req.params.layer;
    let response;

    switch (layer) {
      case '0':
        response = this.getLayer0Data();
        break;

      case '1':
        response = this.getLayer1Data();
        break;

      default:
        response = this.getServiceLevelData();
        break;
    }
    return response;
  }

  async getLayer0Data() {
    // layer 0 logic  
    return {
      ...geojson,
      metadata: metadata
    };
  };

  getLayer1Data() {
    // layer 1 logic
    return {
      ...geojson,
      metadata: metadata
    };
  }

  getServiceLevelData() {
    return {
      layers: [this.getLayer0Data(), this.getLayer1Data()],
      tables: [],
      metadata: {
        // metadata
      }
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2025 16:30:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-extensibility-questions/using-cdfs-can-a-single-data-provider-return/m-p/1648272#M473</guid>
      <dc:creator>John_Hash</dc:creator>
      <dc:date>2025-09-05T16:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using CDFs, can a single Data Provider return several layers?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-extensibility-questions/using-cdfs-can-a-single-data-provider-return/m-p/1648485#M477</link>
      <description>&lt;P&gt;Aha!&amp;nbsp;&lt;BR /&gt;Nice explanation, actually makes sense once you think how your pseudocode handles the getData request.&lt;BR /&gt;I understand the performance and the simplicity arguments. My use case was connected to point clustering at different scale levels.&lt;BR /&gt;&lt;BR /&gt;Thanks for the pseudocode. It was all I needed!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2025 08:57:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-extensibility-questions/using-cdfs-can-a-single-data-provider-return/m-p/1648485#M477</guid>
      <dc:creator>Francisco_R</dc:creator>
      <dc:date>2025-09-08T08:57:38Z</dc:date>
    </item>
  </channel>
</rss>

