<?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 modify symbol used for a graphic? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/modify-symbol-used-for-a-graphic/m-p/1218043#M78891</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;is there a way to modify part of a symbol used for a graphic, e.g. outline color, w/o re-creating the whole symbol?&lt;/P&gt;&lt;P&gt;something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function mapClickHandler(hitTestResult) {
  const graphic = hitTestResult.results[0].graphic
  // does not work
  graphic.symbol.outline.color = new Color("red")
  // nor does the setColor method
  graphic.symbol.outline.color.setColor("red")
  // nor does re-creating just the SLS:
  graphic.symbol.outline = {
    type: "simple-line", 
    width: 2, 
    color: [213, 23, 23, 1] 
  }
  // this works but seems like a hack
  const symbol_copy = graphic.symbol.toJSON()
  symbol_copy.outline.color = new Color("red")
  graphic.symbol = fromJSON(symbol_copy)

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Sep 2022 23:24:47 GMT</pubDate>
    <dc:creator>john_cartwright_noaa</dc:creator>
    <dc:date>2022-09-30T23:24:47Z</dc:date>
    <item>
      <title>modify symbol used for a graphic?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/modify-symbol-used-for-a-graphic/m-p/1218043#M78891</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;is there a way to modify part of a symbol used for a graphic, e.g. outline color, w/o re-creating the whole symbol?&lt;/P&gt;&lt;P&gt;something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function mapClickHandler(hitTestResult) {
  const graphic = hitTestResult.results[0].graphic
  // does not work
  graphic.symbol.outline.color = new Color("red")
  // nor does the setColor method
  graphic.symbol.outline.color.setColor("red")
  // nor does re-creating just the SLS:
  graphic.symbol.outline = {
    type: "simple-line", 
    width: 2, 
    color: [213, 23, 23, 1] 
  }
  // this works but seems like a hack
  const symbol_copy = graphic.symbol.toJSON()
  symbol_copy.outline.color = new Color("red")
  graphic.symbol = fromJSON(symbol_copy)

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 23:24:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/modify-symbol-used-for-a-graphic/m-p/1218043#M78891</guid>
      <dc:creator>john_cartwright_noaa</dc:creator>
      <dc:date>2022-09-30T23:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: modify symbol used for a graphic?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/modify-symbol-used-for-a-graphic/m-p/1218058#M78892</link>
      <description>&lt;P&gt;I thought that would have worked, but doesn't look like it. You can clone the symbol though, modify the outline and replace it.&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/odoe/pen/zYjjOPm?editors=0010" target="_blank"&gt;https://codepen.io/odoe/pen/zYjjOPm?editors=0010&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// something like this
view.on("click", async (e) =&amp;gt; {
	const { results } = await view.hitTest(e);
	for (let result of results) {
		if (result.type === "graphic") {
			const sym = result.graphic.symbol.clone();
			const idx = Math.floor(Math.random() * 10);
			sym.outline &amp;amp;&amp;amp; (sym.outline.color = colors[
				Math.floor(Math.random() * 10)
			]);
			sym.color = colors[
				Math.floor(Math.random() * 10)
			];
			result.graphic.symbol = sym;
		}
	}
});&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 30 Sep 2022 23:36:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/modify-symbol-used-for-a-graphic/m-p/1218058#M78892</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-09-30T23:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: modify symbol used for a graphic?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/modify-symbol-used-for-a-graphic/m-p/1220083#M78939</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt;! This is cleaner than the toJSON/fromJSON approach I was using. Where is the clone method assigned for the Symbol class? TypeScript doesn't recognize it.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 23:01:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/modify-symbol-used-for-a-graphic/m-p/1220083#M78939</guid>
      <dc:creator>john_cartwright_noaa</dc:creator>
      <dc:date>2022-10-07T23:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: modify symbol used for a graphic?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/modify-symbol-used-for-a-graphic/m-p/1220091#M78940</link>
      <description>&lt;P&gt;For TS, you'd need to help TS a bit doing something like if (symbol.type === "simple-fill"). It's not on the base Symbol, but main classes. You'll see it sprinkled around in the doc like here.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#clone" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#clone&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Oct 2022 00:14:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/modify-symbol-used-for-a-graphic/m-p/1220091#M78940</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-10-08T00:14:44Z</dc:date>
    </item>
  </channel>
</rss>

