<?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: FeatureLayer use symbol for render in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1516614#M85254</link>
    <description>&lt;P&gt;I dig into it a little more and had ChatGPT help out. I modified this code it gave as an example. Seems to work wonders. Thanks for pointing me in the right direction!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;script&amp;gt;
  import { onMount } from 'svelte';
  import { loadModules } from 'esri-loader';

  let map;

  onMount(async () =&amp;gt; {
    const [Map, MapView, FeatureLayer, UniqueValueRenderer, PictureMarkerSymbol] = await loadModules([
      'esri/Map',
      'esri/views/MapView',
      'esri/layers/FeatureLayer',
      'esri/renderers/UniqueValueRenderer',
      'esri/symbols/PictureMarkerSymbol'
    ]);

    // Create the map
    map = new Map({
      basemap: 'topo-vector'
    });

    // Create the view
    const view = new MapView({
      container: 'viewDiv',
      map: map,
      center: [-100.33, 25.69], // Longitude, latitude
      zoom: 10
    });

    // Define the UniqueValueRenderer
    const renderer = new UniqueValueRenderer({
      field: 'type',
      uniqueValueInfos: [
        {
          value: 'type1',
          symbol: new PictureMarkerSymbol({
            url: 'path/to/image1.png',
            width: '24px',
            height: '24px'
          })
        },
        {
          value: 'type2',
          symbol: new PictureMarkerSymbol({
            url: 'path/to/image2.png',
            width: '24px',
            height: '24px'
          })
        }
        // Add more unique values as needed
      ]
    });

    // Create a FeatureLayer with inline features
    const featureLayer = new FeatureLayer({
      source: [
        {
          geometry: {
            type: 'point',
            longitude: -100.33,
            latitude: 25.69
          },
          attributes: {
            type: 'type1'
          }
        },
        {
          geometry: {
            type: 'point',
            longitude: -100.35,
            latitude: 25.70
          },
          attributes: {
            type: 'type2'
          }
        }
        // Add more features as needed
      ],
      objectIdField: 'ObjectID', // This must be defined for FeatureLayer
      fields: [
        {
          name: 'ObjectID',
          alias: 'ObjectID',
          type: 'oid'
        },
        {
          name: 'type',
          alias: 'Type',
          type: 'string'
        }
      ],
      renderer: renderer
    });

    // Add the layer to the map
    map.add(featureLayer);
  });
&amp;lt;/script&amp;gt;

&amp;lt;style&amp;gt;
  #viewDiv {
    height: 100%;
    width: 100%;
  }
&amp;lt;/style&amp;gt;

&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 08 Aug 2024 12:00:04 GMT</pubDate>
    <dc:creator>Slyke</dc:creator>
    <dc:date>2024-08-08T12:00:04Z</dc:date>
    <item>
      <title>FeatureLayer use symbol for render</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1516109#M85235</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm running the map in SvelteKit.&lt;/P&gt;&lt;P&gt;I have an array of items like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const myArray = [
  {
    x: someThing.coordinates.longitude,
    y: someThing.coordinates.latitude,
    icon: { url: `URL_OF_ICON.svg`, w: '24px', h: '32px' },
    highlightedIcon: {
      url: `URL_OF_HIGHLIGHTED_ICON.svg`,
      w: '32px',
      h: '48px',
      backgroundColor: 'rgba(0, 255, 0, 0.3)',
      borderColor: 'rgba(0, 255, 0, 0.9)',
      circleR: '64px',
      circleBorderW: 2
    },
    someDetails: someThing
  },
  ...
];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;That I'm rendering to the map. I'm looping through this array and creating graphics onto the map:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Object.keys(points).forEach((point) =&amp;gt; {
  try {
    const attributes = {
      someId: points[point].someDetails?.someId,
      someDetails: points[point].someDetails,
      isHighlighted: points[point].isHighlighted
    };

    if (points[point].isHighlighted) {
      const circleSymbol = new SimpleMarkerSymbol({
        style: "circle",
        color: points[point].highlightedIcon?.backgroundColor,
        size: points[point].highlightedIcon?.circleR,
        ...(points[point].highlightedIcon?.borderColor ?
        {
          outline: {
            color: points[point].highlightedIcon?.borderColor,
            width: points[point].highlightedIcon?.circleBorderW || 2
          }
        } : {} )
      });

      const pictureSymbol = new PictureMarkerSymbol({
        url: points[point].highlightedIcon?.url,
        width: points[point].highlightedIcon?.w,
        height: points[point].highlightedIcon?.h
      });
      
      const pointGeometry = new Point({
        longitude: points[point].x,
        latitude: points[point].y
      });

      const circleGraphic = new Graphic({
        geometry: pointGeometry,
        symbol: circleSymbol,
        attributes
      });

      const pictureGraphic = new Graphic({
        geometry: pointGeometry,
        symbol: pictureSymbol,
        attributes
      });
      graphicsToAdd.push(circleGraphic);
      graphicsToAdd.push(pictureGraphic);
    } else {
      const graphic = new Graphic({
        geometry: new Point({
          longitude: points[point].x,
          latitude: points[point].y
        }),
        symbol: new PictureMarkerSymbol({
          url: points[point].icon.url,
          width: points[point].icon.w,
          height: points[point].icon.h
        }),
        attributes
      });
      graphicsToAdd.push(graphic);
    }
  } catch (err) {
    console.log(`Error: `, err);
  }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;graphicsToAdd is essentially being added to a&amp;nbsp;GraphicsLayer that is a layer on the map.&lt;/P&gt;&lt;P&gt;I have another section of code that essentially detects if the mouse is hovering over one of the graphics, and changes the array so that isHighlighted is true for that item, and it'll render the highlighted icon, with the background graphic, and also show a popup.&lt;/P&gt;&lt;P&gt;The problem comes when I want to cluster these points so that when the user zooms out they clump together. I'm not sure what to do for the FeatureLayer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const iconLayer = new FeatureLayer({
  source: [],
  fields: [
    {
      name: 'objectId',
      alias: 'objectId',
      type: 'oid'
    },
    {
      name: 'someId',
      alias: 'someId',
      type: 'string'
    }
  ],
  objectIdField: 'objectId',
  geometryType: 'point',
  renderer: {
    type: "simple",
    symbol: {
      type: "picture-marker",
      // What goes here?
    }
  }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems there's no way to get the FeatureLayer to render the graphics being attached to it via applyEdits(). I can make them show up as dots on the map, and can get them to cluster. But I can't get them to use their own icons. I haven't tried getting the mouse hover to work yet. I know that I can set a URL under renderer.symbol.type, but I want each graphic to render its own symbol.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Off topic:&lt;/P&gt;&lt;P&gt;Also, is there a way to switch to markdown mode when posting here? I can't edit my code snippets once they are inserted.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 14:32:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1516109#M85235</guid>
      <dc:creator>Slyke</dc:creator>
      <dc:date>2024-08-07T14:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer use symbol for render</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1516198#M85240</link>
      <description>&lt;P&gt;If I'm understanding this correctly, I think the problem is that &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html" target="_self"&gt;FeatureLayer&lt;/A&gt; ignores the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#symbol" target="_self"&gt;symbol&lt;/A&gt; property of its graphics.&amp;nbsp; If you want each graphic to be rendered uniquely, I think your best bet is to create and populate a&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html" target="_self"&gt;UniqueValueRenderer&lt;/A&gt; object, and set it to the layer's &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#renderer" target="_self"&gt;renderer&lt;/A&gt; property.&amp;nbsp; You could add the url to the graphic's attributes, and use that as the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field" target="_self"&gt;field&lt;/A&gt; for your renderer.&lt;/P&gt;&lt;P&gt;Also, if you've created a code block in one of your posts, you can double-click it to re-open and edit.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 16:37:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1516198#M85240</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-08-07T16:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer use symbol for render</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1516579#M85251</link>
      <description>&lt;P&gt;Hey Joel,&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;I'm unsure what you mean by `populate a UniqueValueRenderer object, and set it to the layer's renderer property`.&lt;/P&gt;&lt;P&gt;Are there any examples of using a Layer that has a custom graphic for each icon, and updating the icon dynamically (either by mouseover or otherwise)? I essentially want to be able to cluster a set of Graphics.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 10:09:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1516579#M85251</guid>
      <dc:creator>Slyke</dc:creator>
      <dc:date>2024-08-08T10:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer use symbol for render</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1516614#M85254</link>
      <description>&lt;P&gt;I dig into it a little more and had ChatGPT help out. I modified this code it gave as an example. Seems to work wonders. Thanks for pointing me in the right direction!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;script&amp;gt;
  import { onMount } from 'svelte';
  import { loadModules } from 'esri-loader';

  let map;

  onMount(async () =&amp;gt; {
    const [Map, MapView, FeatureLayer, UniqueValueRenderer, PictureMarkerSymbol] = await loadModules([
      'esri/Map',
      'esri/views/MapView',
      'esri/layers/FeatureLayer',
      'esri/renderers/UniqueValueRenderer',
      'esri/symbols/PictureMarkerSymbol'
    ]);

    // Create the map
    map = new Map({
      basemap: 'topo-vector'
    });

    // Create the view
    const view = new MapView({
      container: 'viewDiv',
      map: map,
      center: [-100.33, 25.69], // Longitude, latitude
      zoom: 10
    });

    // Define the UniqueValueRenderer
    const renderer = new UniqueValueRenderer({
      field: 'type',
      uniqueValueInfos: [
        {
          value: 'type1',
          symbol: new PictureMarkerSymbol({
            url: 'path/to/image1.png',
            width: '24px',
            height: '24px'
          })
        },
        {
          value: 'type2',
          symbol: new PictureMarkerSymbol({
            url: 'path/to/image2.png',
            width: '24px',
            height: '24px'
          })
        }
        // Add more unique values as needed
      ]
    });

    // Create a FeatureLayer with inline features
    const featureLayer = new FeatureLayer({
      source: [
        {
          geometry: {
            type: 'point',
            longitude: -100.33,
            latitude: 25.69
          },
          attributes: {
            type: 'type1'
          }
        },
        {
          geometry: {
            type: 'point',
            longitude: -100.35,
            latitude: 25.70
          },
          attributes: {
            type: 'type2'
          }
        }
        // Add more features as needed
      ],
      objectIdField: 'ObjectID', // This must be defined for FeatureLayer
      fields: [
        {
          name: 'ObjectID',
          alias: 'ObjectID',
          type: 'oid'
        },
        {
          name: 'type',
          alias: 'Type',
          type: 'string'
        }
      ],
      renderer: renderer
    });

    // Add the layer to the map
    map.add(featureLayer);
  });
&amp;lt;/script&amp;gt;

&amp;lt;style&amp;gt;
  #viewDiv {
    height: 100%;
    width: 100%;
  }
&amp;lt;/style&amp;gt;

&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Aug 2024 12:00:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1516614#M85254</guid>
      <dc:creator>Slyke</dc:creator>
      <dc:date>2024-08-08T12:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer use symbol for render</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1572002#M86303</link>
      <description>&lt;P&gt;When using typescript in Angular, the&amp;nbsp;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;FeatureLayer&lt;/SPAN&gt;&lt;SPAN&gt;({&lt;/SPAN&gt;&lt;SPAN&gt;renderer}) is pointing to&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;RendererProperties and that is pointing to -&amp;gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;authoringInfo&lt;/SPAN&gt;&lt;SPAN&gt;?:&lt;/SPAN&gt; &lt;SPAN&gt;AuthoringInfoProperties,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;so none of the working examples seem to be working with &lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;FeatureLayer&lt;/SPAN&gt; &lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;'@arcgis/core/layers/FeatureLayer' and being able to render.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 01 Jan 2025 17:14:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-use-symbol-for-render/m-p/1572002#M86303</guid>
      <dc:creator>mrgreen8</dc:creator>
      <dc:date>2025-01-01T17:14:49Z</dc:date>
    </item>
  </channel>
</rss>

