<?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: Customise symbol based on data separate from feature layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209698#M78589</link>
    <description>&lt;P&gt;The JSAPI isn't open-source, so we don't provide the unminified code anywhere.&lt;/P&gt;&lt;P&gt;We only have custom layer extensibility for Tiled layers, not FeatureLayers.&lt;/P&gt;&lt;P&gt;We also have request interceptors, where you can modify the response before the layers use it, but no guarantee we don't use the service defined fields for other parts of the drawing and query stuff, you might be able to do some stuff here, but you're just adding to query time here too by pulling in new data requests.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#RequestInterceptor" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#RequestInterceptor&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you have Enterprise portal, you can do this via a SOE. Doing this on the client is probably going to require a custom worker one way or another&lt;/P&gt;</description>
    <pubDate>Mon, 05 Sep 2022 16:40:12 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2022-09-05T16:40:12Z</dc:date>
    <item>
      <title>Customise symbol based on data separate from feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209015#M78566</link>
      <description>&lt;P&gt;Using ArcGIS JS API 4.x, I'm presenting a FeatureLayer, and want to customise the symbol used to render the features based on data that is &lt;EM&gt;not&lt;/EM&gt; part of the layer, it's a completely separate not-ArcGIS data source.&lt;/P&gt;&lt;P&gt;More specifically, I have a feature layer on ArcGIS server, and the only object attribute saved on that layer is the unique ID for features. Those unique IDs are referenceed in a completely different data storage, which has the detail of what symbol I want to display. I can access that separate data storage client-side with JS, but I don't know how to "combine" the two sources of data.&lt;/P&gt;&lt;P&gt;I've looked at the option of subclassing SimpleRenderer, but I've been drawing a blank there as I can't figure out what functions I'd need to override that can let me specify a different symbol based on the unique ID of the feature. I might be missing something?&lt;/P&gt;&lt;P&gt;Alternatively, I wonder whether I could do some sort of client-side combining of the FeatureLayer along with the separate data source, and then use visualVariables in the SimpleRenderer. Whether that would require subclassing FeatureLayer, or there's some other way to combine data sources, I don't know.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 05:03:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209015#M78566</guid>
      <dc:creator>JasonDoingMaps</dc:creator>
      <dc:date>2022-09-02T05:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Customise symbol based on data separate from feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209159#M78569</link>
      <description>&lt;P&gt;There is a similar question here&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/joining-api-response-json-data-to-featurelayer/m-p/1207571#M78494" target="_blank"&gt;https://community.esri.com/t5/arcgis-api-for-javascript-questions/joining-api-response-json-data-to-featurelayer/m-p/1207571#M78494&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You would need to create a client-side FeatureLayer and manually do the join. It might be worth using a web worker as linked in that post too if the operation blocks page interaction. I've had to do this in the past working an admin who was pretty adamant at keeping "business data" outside the GIS data, and it was always a headache, lol.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 14:38:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209159#M78569</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-09-02T14:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Customise symbol based on data separate from feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209543#M78581</link>
      <description>&lt;P&gt;Thanks for the input &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt; , some great insights there.&lt;/P&gt;&lt;P&gt;As you pointed out in the linked "similar question" (emphasis mine):&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Query all the features from your source FeatureLayer. &lt;EM&gt;&lt;STRONG&gt;This could be troublesome if you have a large amount of data&lt;/STRONG&gt;&lt;/EM&gt;, so you might need to paginate your requests.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, that's an unfortunate downside of this approach. I &lt;EM&gt;do&lt;/EM&gt; have enough data in my instance that pagination would be necessary. And the inefficiency of having to load &lt;EM&gt;all&lt;/EM&gt; geometry upfront, rather than letting the users zoom + pan actions load geometry on the fly is far from ideal.&lt;/P&gt;&lt;P&gt;Two favourable alternatives would be:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;A customised renderer. E.g. I can set a callback function that is provided the Graphic object as an input parameter, and allows me to set properties of the renderer (size, colour, etc.). Or;&lt;/LI&gt;&lt;LI&gt;Data "pipeline" functionality for the FeatureLayer. So whenever the JS API makes a call to the server-side feature layer URL, I have the opportunity to amend the request and / or response. I.e. when the response comes back, add some attributes to the Graphic objects.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I'm a &lt;EM&gt;little&lt;/EM&gt; surprised that there appears to be no straightforward way to accomplish either of these. I suppose subclassing, or even monkey-patching the JS could make it happen. But it's difficult to reverse engineer the JS API from the minified version to figure out how such subclassing or patching could accomplish the goal.&lt;/P&gt;&lt;P&gt;Regarding the JS being minified, per here - &lt;A href="https://github.com/Esri/arcgis-js-api" target="_blank"&gt;https://github.com/Esri/arcgis-js-api &lt;/A&gt;- "A minified, unbuilt version of the &lt;A href="https://developers.arcgis.com/javascript/" rel="nofollow" target="_blank"&gt;ArcGIS API for JavaScript&lt;/A&gt; ES modules." Am I missing something (i.e. is there a *not* minified version available?), or is it intentional that there's only a minified version available?&lt;/P&gt;&lt;P&gt;Here's a good example of a custom layer created using subclassing - &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/layers-custom-blendlayer/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/layers-custom-blendlayer/&lt;/A&gt; But, even knowing that it's the "load" function that should be overridden is not obvious without this very direct example. I mean you go look at the code for the BaseTileLayer class and its class declaration is:&lt;/P&gt;&lt;P&gt;let y = class extends(n(c(m(a))))&lt;/P&gt;&lt;P&gt;So it extends... what exactly? &lt;EM&gt;Very&lt;/EM&gt; difficult to read, figure out behaviour, and now what / where to override to get customised behaviour.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 23:22:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209543#M78581</guid>
      <dc:creator>JasonDoingMaps</dc:creator>
      <dc:date>2022-09-03T23:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Customise symbol based on data separate from feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209698#M78589</link>
      <description>&lt;P&gt;The JSAPI isn't open-source, so we don't provide the unminified code anywhere.&lt;/P&gt;&lt;P&gt;We only have custom layer extensibility for Tiled layers, not FeatureLayers.&lt;/P&gt;&lt;P&gt;We also have request interceptors, where you can modify the response before the layers use it, but no guarantee we don't use the service defined fields for other parts of the drawing and query stuff, you might be able to do some stuff here, but you're just adding to query time here too by pulling in new data requests.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#RequestInterceptor" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#RequestInterceptor&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you have Enterprise portal, you can do this via a SOE. Doing this on the client is probably going to require a custom worker one way or another&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 16:40:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209698#M78589</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-09-05T16:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Customise symbol based on data separate from feature layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209749#M78593</link>
      <description>&lt;P&gt;RequestInterceptor looks like just the thing I need.&lt;/P&gt;&lt;P&gt;Firstly, the JS API queries the feature layer to get metadata (spatial reference, extents, etc.). I listen for that response, checking for presence of the "supportedQueryFormats" property in the response. The layer I'm querying supports PBF format, which isn't easy to manipulate, so I override the "supportedQueryFormats" property in the response to &lt;EM&gt;only&lt;/EM&gt; list "JSON", so subsequent feature queries request JSON responses. Like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const myFeatureUrl = 'https://....';
esriConfig.request.interceptors.push({
    after: (response) =&amp;gt; {
        if (response.url.indexOf(myFeatureUrl) !== -1) {
            if (response.data.supportedQueryFormats) {
                // Force feature querying to use JSON instead of PBF,
                // to make it easier to intercept and manipulate.
                response.data.supportedQueryFormats = 'JSON';
            }
        }
    }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subsequent responses, despite being JSON, come in an ArrayBuffer, but I can at least convert that, manipulate the content, then convert it back to an ArrayBuffer so later parts of the ArcGIS JS query pipeline are happy. Like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// ab2str and str2ab are external functions for ArrayBuffer / string conversion.

const myFeatureUrl = 'https://....';
const otherData = []; // Populated otherwise...

esriConfig.request.interceptors.push({
    after: (response) =&amp;gt; {
        if (response.url.indexOf(myFeatureUrl) !== -1) {
            if (response.data instanceof ArrayBuffer) {

                // Convert the response into a JS object, add extra attributes to
                // the features, then convert back to ArrayBuffer for the sake
                // of later parts in the ArcGIS JS API pipeline.

                let responseData = JSON.parse(ab2str(response.data));

                if (responseData.features) {
                    for (let feature of responseData.features) {
                        let keyValue = feature.attributes.keyProperty;

                        if (keyValue) {
                            let data = otherData.filter(d =&amp;gt; d.keyProperty === keyValue)[0];
                            if (data) {
                                feature.attributes.extraAttribute1 = data.extraAttribute1;
                                feature.attributes.extraAttribute2 = data.extraAttribute2;
                            }
                        }
                    }

                    response.data = str2ab(JSON.stringify(responseData));
                }
            }
        }
    }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;The JSAPI isn't open-source, so we don't provide the unminified code anywhere.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Combined with limited documentation on the subject, this does unfortunately make extensibility difficult.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;We only have custom layer extensibility for Tiled layers, not FeatureLayers.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks for clarifying. It's not easy to discover this otherwise. I've found documentation for Tiled layer extensibility, there's a good example of the "blend layer" approach. But a lack of similar documentation for Feature layers doesn't make it obvious that it's not intended to be extended from. I imagine if I could dig deep enough, and reverse engineer the minified code, it would be possible, but it feels like swimming upstream.&lt;/P&gt;&lt;P&gt;From the outset, I hoped, and kind of &lt;EM&gt;expected&lt;/EM&gt; that for feature rendering I'd find a function callback where I'd receive the graphic / feature to be rendered as input, and be able to provide the rendering properties / symbol on that basis. Arcade expressions, visual variables, etc. are OK, but if I've got a use case they don't fit, it looks like I'd be left with few (no?) alternatives. I &lt;EM&gt;guess&lt;/EM&gt; this is because the arcade expressions approach is a means to provide a common abstraction across all platforms? But it would be great to still have the option to get one step deeper and have more control over the rendering. What's the preferred avenue for providing such feedback to the product team?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 05:53:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/customise-symbol-based-on-data-separate-from/m-p/1209749#M78593</guid>
      <dc:creator>JasonDoingMaps</dc:creator>
      <dc:date>2022-09-06T05:53:25Z</dc:date>
    </item>
  </channel>
</rss>

