<?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: Custom symbol that renders differently based on attributes? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-symbol-that-renders-differently-based-on/m-p/361724#M33474</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure I understand exactly what your asking for, but it sounds similar to something I have done in the past.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I run a query and get back a featureSet, in each feature that returns there is an attribute object in my case there was a particular variable in that attribute object called entityType.&amp;nbsp; Depending on the entityType I displayed a different symbol on the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for example if the feature had an entityType of "Person" I displayed a red teardrop, if the feature had an entityType of "Organization" I displayed a green teardrop, for "Vehicle" it was yellow, etc, etc...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I handled this by setting up what I called a symbolBank, which was a javascript object that worked pretty much like a java HashMap; the code looks like this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
symbolBank = {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Person": new esri.symbol.PictureMarkerSymbol('/images/red_teardrop.png', 25, 25),
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Organization": new esri.symbol.PictureMarkerSymbol('/images/green_teardrop.png', 25, 25),
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Vehicle": new esri.symbol.PictureMarkerSymbol('/images/yellow_teardrop.png', 25, 25)
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Access the object by looping through the featureSet and keying off of the attribute you need to create the symbol.&amp;nbsp; In my case it looks like this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
dojo.forEach(featureSet, function(feature){
&amp;nbsp;&amp;nbsp;&amp;nbsp; var symbol = symbolBank[feature.attributes.entityType];
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphic = new esri.Graphic(feature.geometry, symbol);
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.add(graphic);
});
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:52:21 GMT</pubDate>
    <dc:creator>JacobBrozenick</dc:creator>
    <dc:date>2021-12-11T16:52:21Z</dc:date>
    <item>
      <title>Custom symbol that renders differently based on attributes?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-symbol-that-renders-differently-based-on/m-p/361721#M33471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to render features using something similar to the ClassBreaksRenderer, but instead of discrete breaks, I want a smoothly sliding scale.&amp;nbsp; I accomplished this in the Flex API by creating a custom Symbol which had a different color based on an attribute value.&amp;nbsp; I'm brand new to the javascript API, (and not too experienced with Javascript in general -- I come from a Java background), and I'd like to know how to do something similar with Javascript.&amp;nbsp; Is this possible?&amp;nbsp; I've been told that Javascript is classless, so I'm not clear on what the objects (Layer,Symbol,etc) really are.&amp;nbsp; Any help would be greatly appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Dec 2010 19:50:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-symbol-that-renders-differently-based-on/m-p/361721#M33471</guid>
      <dc:creator>DavidElies</dc:creator>
      <dc:date>2010-12-14T19:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Custom symbol that renders differently based on attributes?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-symbol-that-renders-differently-based-on/m-p/361722#M33472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;you can use the setColor() method to change the color of your symbol based on what ever you are basing a change on....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/editor.htm"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/editor.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Dec 2010 22:19:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-symbol-that-renders-differently-based-on/m-p/361722#M33472</guid>
      <dc:creator>timgogl</dc:creator>
      <dc:date>2010-12-14T22:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Custom symbol that renders differently based on attributes?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-symbol-that-renders-differently-based-on/m-p/361723#M33473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your response lowgas!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The link you posted points to the editor widget.&amp;nbsp; Since I'm not editing anything, I don't think this is what I'm looking for.&amp;nbsp; Should I not be using a feature layer if I'm not doing selection/editing?&amp;nbsp; If you have any more ideas about how to change the look of individual graphics in a feature layer based on their attributes, please let me know.&amp;nbsp; Otherwise, I will probably have to use the ClassBreaksRenderer and choose some arbitrary breaks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other question I had was if it were possible to create a custom symbol.&amp;nbsp; Does anybody have any ideas or suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Dec 2010 19:44:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-symbol-that-renders-differently-based-on/m-p/361723#M33473</guid>
      <dc:creator>DavidElies</dc:creator>
      <dc:date>2010-12-16T19:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Custom symbol that renders differently based on attributes?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-symbol-that-renders-differently-based-on/m-p/361724#M33474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure I understand exactly what your asking for, but it sounds similar to something I have done in the past.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I run a query and get back a featureSet, in each feature that returns there is an attribute object in my case there was a particular variable in that attribute object called entityType.&amp;nbsp; Depending on the entityType I displayed a different symbol on the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for example if the feature had an entityType of "Person" I displayed a red teardrop, if the feature had an entityType of "Organization" I displayed a green teardrop, for "Vehicle" it was yellow, etc, etc...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I handled this by setting up what I called a symbolBank, which was a javascript object that worked pretty much like a java HashMap; the code looks like this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
symbolBank = {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Person": new esri.symbol.PictureMarkerSymbol('/images/red_teardrop.png', 25, 25),
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Organization": new esri.symbol.PictureMarkerSymbol('/images/green_teardrop.png', 25, 25),
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Vehicle": new esri.symbol.PictureMarkerSymbol('/images/yellow_teardrop.png', 25, 25)
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Access the object by looping through the featureSet and keying off of the attribute you need to create the symbol.&amp;nbsp; In my case it looks like this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
dojo.forEach(featureSet, function(feature){
&amp;nbsp;&amp;nbsp;&amp;nbsp; var symbol = symbolBank[feature.attributes.entityType];
&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphic = new esri.Graphic(feature.geometry, symbol);
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.add(graphic);
});
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:52:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-symbol-that-renders-differently-based-on/m-p/361724#M33474</guid>
      <dc:creator>JacobBrozenick</dc:creator>
      <dc:date>2021-12-11T16:52:21Z</dc:date>
    </item>
  </channel>
</rss>

