<?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 Render list of CIM Symbols in Web Style in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/render-list-of-cim-symbols-in-web-style/m-p/1229345#M79255</link>
    <description>&lt;P&gt;I'd like to render a list of every symbol in a web style, similar to the sketch widget in the Map Viewer. I've tried creating a list of web style symbols and then using fetchCIMSymbol to get the related data, fetched symbols are then used by renderPreviewHTML.&lt;/P&gt;&lt;P&gt;Is there a better way of doing this?&amp;nbsp;My current method is quite slow as each 'fetchCIMSymbol' call will go off and fetch the style item data, so the fetchCIMSymbol calls don't run in parallel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const itemId = "1fbb242c54e4415d9b8e8a343ca7a9d0";
const item = new PortalItem({ id: itemId });
await item.load();
const itemData = await item.fetchData();
const symbolNames = itemData.items.map((item) =&amp;gt; item.name);
const styleUrl =
  "https://local-maps.maps.arcgis.com/sharing/rest/content/items/1fbb242c54e4415d9b8e8a343ca7a9d0/data";
// const firstSymbol = await new WebStyleSymbol({
//   styleUrl,
//   name: symbolNames[0],
// }).fetchCIMSymbol();
const symbols = await Promise.all(
  symbolNames.map((name) =&amp;gt; new WebStyleSymbol({ styleUrl, name }))
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Nov 2022 21:32:08 GMT</pubDate>
    <dc:creator>JoshGore</dc:creator>
    <dc:date>2022-11-07T21:32:08Z</dc:date>
    <item>
      <title>Render list of CIM Symbols in Web Style</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/render-list-of-cim-symbols-in-web-style/m-p/1229345#M79255</link>
      <description>&lt;P&gt;I'd like to render a list of every symbol in a web style, similar to the sketch widget in the Map Viewer. I've tried creating a list of web style symbols and then using fetchCIMSymbol to get the related data, fetched symbols are then used by renderPreviewHTML.&lt;/P&gt;&lt;P&gt;Is there a better way of doing this?&amp;nbsp;My current method is quite slow as each 'fetchCIMSymbol' call will go off and fetch the style item data, so the fetchCIMSymbol calls don't run in parallel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const itemId = "1fbb242c54e4415d9b8e8a343ca7a9d0";
const item = new PortalItem({ id: itemId });
await item.load();
const itemData = await item.fetchData();
const symbolNames = itemData.items.map((item) =&amp;gt; item.name);
const styleUrl =
  "https://local-maps.maps.arcgis.com/sharing/rest/content/items/1fbb242c54e4415d9b8e8a343ca7a9d0/data";
// const firstSymbol = await new WebStyleSymbol({
//   styleUrl,
//   name: symbolNames[0],
// }).fetchCIMSymbol();
const symbols = await Promise.all(
  symbolNames.map((name) =&amp;gt; new WebStyleSymbol({ styleUrl, name }))
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 21:32:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/render-list-of-cim-symbols-in-web-style/m-p/1229345#M79255</guid>
      <dc:creator>JoshGore</dc:creator>
      <dc:date>2022-11-07T21:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Render list of CIM Symbols in Web Style</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/render-list-of-cim-symbols-in-web-style/m-p/1229415#M79256</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/420340"&gt;@JoshGore&lt;/a&gt;&amp;nbsp;- If your Web Style symbols have a thumbnail defined, you can just load those as the preview initially, and then convert the symbol to a CIMSymbol once the user selects the symbol in your styler widget. This might be faster than converting them all to CIM symbols initially.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function initializeWebStyles() {
  esriRequest(styleUrl + "/data", {
     responseType: "json"
  }).then(function (response) {
     response.data.items.forEach((item, index) =&amp;gt; {
       let card = document.createElement("calcite-card");
       let cardImage = document.createElement("img");
       // use the webstyle symbol thumbnail to populate the card image
       cardImage.src=styleUrl + item.thumbnail.href.substring(1);
       cardImage.width = 50;
       card.appendChild(cardImage);
       card.style.width = "75px";
       // update the symbol when the item is clicked
       card.addEventListener("click", () =&amp;gt; updateWebStyle(item.name));
       document.getElementById("styles").appendChild(card);
     });
   });
}&lt;/LI-CODE&gt;&lt;P&gt;That snippet can be found in this sample in our documentation:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/cim-marker-placement/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/cim-marker-placement/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 02:08:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/render-list-of-cim-symbols-in-web-style/m-p/1229415#M79256</guid>
      <dc:creator>AnneFitz</dc:creator>
      <dc:date>2022-11-08T02:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Render list of CIM Symbols in Web Style</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/render-list-of-cim-symbols-in-web-style/m-p/1229650#M79267</link>
      <description>&lt;P&gt;Thanks Anne, I'd missed that sample!&lt;BR /&gt;I got around the above by using the undocumented "webStyleSymbolUtils" as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  fetchSymbols = async () =&amp;gt; {
    const data = await this.portalItem.fetchData();
    const symbols = await Promise.all(
      data.items.map(async item =&amp;gt; {
        const webSymbol = new WebStyleSymbol({
          styleUrl: `${this.portalItem.itemUrl}/data`,
          name: item.name,
        });
        // const symbol = await webSymbol.fetchCIMSymbol();
        const symbol = await webStyleSymbolUtils.fetchSymbolFromStyle(
          {
            data,
            baseUrl: this.portalItem.itemUrl,
            styleUrl: `${this.portalItem.itemUrl}/data`,
          },
          item.name,
          { portal: this.portalItem.portal },
          'cimRef',
        );
        return { symbol, name: webSymbol.name };
      }),
    );
    return symbols;
  };&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 08 Nov 2022 19:35:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/render-list-of-cim-symbols-in-web-style/m-p/1229650#M79267</guid>
      <dc:creator>JoshGore</dc:creator>
      <dc:date>2022-11-08T19:35:25Z</dc:date>
    </item>
  </channel>
</rss>

