<?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 Style Vector Tiles from an attribute in JS API 4.20 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/style-vector-tiles-from-an-attribute-in-js-api-4/m-p/1100279#M74731</link>
    <description>&lt;P&gt;I am trying to apply attribute-driven client-side styling to a custom vector tile layer (published to ArcGIS Online from Pro) in the ArcGIS JavaScript API v 4.20 .&amp;nbsp; Specifically, I would like to use color stops to style polygon fill-color based on an attribute.&amp;nbsp; I have been able to use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#setPaintProperties" target="_blank" rel="noopener"&gt;setPaintProperties&lt;/A&gt;&amp;nbsp;to change the default color of the layer (code below).&amp;nbsp; However, I have not been able to set the "property" to an attribute, as described in the &lt;A href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/" target="_blank" rel="noopener"&gt;Mapbox style layer documentation&lt;/A&gt; that is linked from the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#setPaintProperties" target="_blank" rel="noopener"&gt;setPaintProperties&lt;/A&gt; documentation.&amp;nbsp; I have successfully used this approach with Mapbox GL using vector tiles, but am unsure if it is possible in the JS API v4.20.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I'm trying to get to work.&amp;nbsp; When executed, it applies the red default color.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  styleMap(){
  
    const paintProperties = vtLayer.getPaintProperties("myLayer");
    var fill ={
      property: "myAttribute",
      default: 'red',
      stops: [
        [0 , '#a1a1a1'],
        [10000, '#ccece6'],
        [200000, '#99d8c9'],
        [500000, '#66c2a4'],
        [1000000, '#2ca25f'],
        [15000000, '#006d2c'],
      ]
    }
    paintProperties["fill-color"] =fill;
    vtLayer.setPaintProperties("myLayer", paintProperties);
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Is this supported and/or are there plans for it to be supported in future versions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Erik&lt;/P&gt;</description>
    <pubDate>Tue, 21 Sep 2021 13:45:33 GMT</pubDate>
    <dc:creator>ErikMartin</dc:creator>
    <dc:date>2021-09-21T13:45:33Z</dc:date>
    <item>
      <title>Style Vector Tiles from an attribute in JS API 4.20</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/style-vector-tiles-from-an-attribute-in-js-api-4/m-p/1100279#M74731</link>
      <description>&lt;P&gt;I am trying to apply attribute-driven client-side styling to a custom vector tile layer (published to ArcGIS Online from Pro) in the ArcGIS JavaScript API v 4.20 .&amp;nbsp; Specifically, I would like to use color stops to style polygon fill-color based on an attribute.&amp;nbsp; I have been able to use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#setPaintProperties" target="_blank" rel="noopener"&gt;setPaintProperties&lt;/A&gt;&amp;nbsp;to change the default color of the layer (code below).&amp;nbsp; However, I have not been able to set the "property" to an attribute, as described in the &lt;A href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/" target="_blank" rel="noopener"&gt;Mapbox style layer documentation&lt;/A&gt; that is linked from the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#setPaintProperties" target="_blank" rel="noopener"&gt;setPaintProperties&lt;/A&gt; documentation.&amp;nbsp; I have successfully used this approach with Mapbox GL using vector tiles, but am unsure if it is possible in the JS API v4.20.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I'm trying to get to work.&amp;nbsp; When executed, it applies the red default color.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  styleMap(){
  
    const paintProperties = vtLayer.getPaintProperties("myLayer");
    var fill ={
      property: "myAttribute",
      default: 'red',
      stops: [
        [0 , '#a1a1a1'],
        [10000, '#ccece6'],
        [200000, '#99d8c9'],
        [500000, '#66c2a4'],
        [1000000, '#2ca25f'],
        [15000000, '#006d2c'],
      ]
    }
    paintProperties["fill-color"] =fill;
    vtLayer.setPaintProperties("myLayer", paintProperties);
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Is this supported and/or are there plans for it to be supported in future versions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Erik&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 13:45:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/style-vector-tiles-from-an-attribute-in-js-api-4/m-p/1100279#M74731</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2021-09-21T13:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Style Vector Tiles from an attribute in JS API 4.20</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/style-vector-tiles-from-an-attribute-in-js-api-4/m-p/1103634#M74848</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is supported and should work. I do see couple of issues in your paint properties json... All property names should be surrounded by double quotes (") and also the color names should be surrounded by double quotes. JSON does not accept single quotes (').&amp;nbsp;&lt;/P&gt;&lt;P&gt;So please try changing your json to the following and it should work.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; var fill ={
      "property": "myAttribute",
      "default": "red",
      "stops": [
        [0 , "#a1a1a1"],
        [10000, "#ccece6"],
        [200000, "#99d8c9"],
        [500000, "#66c2a4"],
        [1000000, "#2ca25f"],
        [15000000, "#006d2c"],
      ]
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/U_B_U/pen/GREeQLY?editors=1000" target="_self"&gt;This test app&lt;/A&gt; shows how to change circle-color paint properties the same way you want to change and it is working. I added two buttons to the app... One button shows how to use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#setPaintProperties" target="_self"&gt;setPaintProperties&lt;/A&gt; and the other button uses &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#setStyleLayer" target="_self"&gt;setStyleLayer&lt;/A&gt; method to change the style properties.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 17:32:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/style-vector-tiles-from-an-attribute-in-js-api-4/m-p/1103634#M74848</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-09-30T17:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Style Vector Tiles from an attribute in JS API 4.20</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/style-vector-tiles-from-an-attribute-in-js-api-4/m-p/1104567#M74874</link>
      <description>&lt;P&gt;Thank you, Undral, for the reply.&amp;nbsp; Those were good suggestions but, after wracking my brain for hours staring at the JS, it turns out my issue was in the vector tile generation -- needed to go back, select the attributes I wanted to include in the tiles and rebuild the cache.&amp;nbsp; Thanks again for the help!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 20:37:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/style-vector-tiles-from-an-attribute-in-js-api-4/m-p/1104567#M74874</guid>
      <dc:creator>ErikMartin</dc:creator>
      <dc:date>2021-10-04T20:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Style Vector Tiles from an attribute in JS API 4.20</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/style-vector-tiles-from-an-attribute-in-js-api-4/m-p/1181356#M77647</link>
      <description>&lt;P&gt;can you change fill-color paint properties in these test app?&lt;BR /&gt;I have a problem&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/is-expression-supported-in-the-styles-in-arcgis/m-p/1180554#M77617" target="_blank"&gt;https://community.esri.com/t5/arcgis-api-for-javascript-questions/is-expression-supported-in-the-styles-in-arcgis/m-p/1180554#M77617&lt;/A&gt;&lt;BR /&gt;I view source code failed to resolve, but it feel like there is something wrong with the source code&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2022 04:37:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/style-vector-tiles-from-an-attribute-in-js-api-4/m-p/1181356#M77647</guid>
      <dc:creator>3kmsdistance</dc:creator>
      <dc:date>2022-06-09T04:37:52Z</dc:date>
    </item>
  </channel>
</rss>

