<?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: hitTest - different highlight based on feature value in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hittest-different-highlight-based-on-feature-value/m-p/1217472#M78873</link>
    <description>&lt;LI-CODE lang="javascript"&gt;&lt;/LI-CODE&gt;&lt;P&gt;You should change the highlight colors in your if then statements&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Like here:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if (value = HW: Private)&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (value = HW: Private) {
 view.highlightOptions = {
    color:[160, 32, 240]
  };
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here is a simple codepen app shows how it is done:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/poVLyzr?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/poVLyzr?editors=1000&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Sep 2022 16:07:45 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2022-09-29T16:07:45Z</dc:date>
    <item>
      <title>hitTest - different highlight based on feature value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hittest-different-highlight-based-on-feature-value/m-p/1215504#M78793</link>
      <description>&lt;P&gt;All&lt;/P&gt;&lt;P&gt;I currently have a working hitTest,&amp;nbsp; a customer moves their cursor over a street (from our streets feature layer) and the whole of that street will highlight in orange (based on it's unique street code).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ITApplications_0-1663940175182.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52020i13377AE3817059C5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ITApplications_0-1663940175182.png" alt="ITApplications_0-1663940175182.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've been asked, if the highlight can show as different colours based on an additional attribute in the layer: ownership. Therefore blue if privately owned, and orange if owned by the council. This data is in the feature layer:&amp;nbsp; field:&amp;nbsp; customer_n&amp;nbsp; &amp;nbsp;and the values are:&amp;nbsp; HW: Private&amp;nbsp; and HW: ERYC Highway Maintained&lt;BR /&gt;&lt;BR /&gt;I'm guessing I can use unique value infos&amp;nbsp; something like:&lt;/P&gt;&lt;P&gt;field: "customer_n" and then&lt;/P&gt;&lt;P&gt;if value = HW: Private&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Color: "blue"&amp;nbsp; etc etc.&lt;BR /&gt;&lt;BR /&gt;After some playing around (and failing) I'm unsure how to add this into my code.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;My code for the hitTest is below: the current orange highlight is set in the MapView: I'm wondering if I can put the relevant code into the highlight options as this is where the highlight/color is controlled?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ITApplications_1-1663941459134.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52024i03D0A374474DEB0F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ITApplications_1-1663941459134.png" alt="ITApplications_1-1663941459134.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;view&lt;BR /&gt;.when()&lt;BR /&gt;.then(() =&amp;gt; {&lt;BR /&gt;return streetLayer.when();&lt;BR /&gt;})&lt;BR /&gt;.then((layer) =&amp;gt; {&lt;BR /&gt;const renderer = layer.renderer.clone();&lt;BR /&gt;renderer.symbol.width = 38;&lt;BR /&gt;renderer.symbol.color = [255, 255, 255, 0.1];&lt;BR /&gt;layer.renderer = renderer;&lt;/P&gt;&lt;P&gt;return view.whenLayerView(layer);&lt;BR /&gt;})&lt;BR /&gt;.then((layerView) =&amp;gt; {&lt;BR /&gt;view.on("pointer-move", eventHandler);&lt;BR /&gt;&lt;BR /&gt;function eventHandler(event) {&lt;BR /&gt;const opts = { include: streetLayer&lt;BR /&gt;}&lt;BR /&gt;view.hitTest(event, opts).then(getGraphics);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var highlight, currentCustomer, currentName;&lt;/P&gt;&lt;P&gt;function getGraphics(response) {&lt;BR /&gt;if (response.results.length) {&lt;BR /&gt;const graphic = response.results[0].graphic;&lt;/P&gt;&lt;P&gt;const attributes = graphic.attributes;&lt;BR /&gt;const name = attributes.SITE_NAME;&lt;BR /&gt;const town = attributes.TOWN_NAME;&lt;BR /&gt;const usrn = attributes.SITE_CODE;&lt;BR /&gt;const type = attributes.CUSTOMER_N;&lt;BR /&gt;&lt;BR /&gt;if ( highlight &amp;amp;&amp;amp; (currentName !== usrn || currentCustomer !== cust) ) {&lt;BR /&gt;highlight.remove();&lt;BR /&gt;highlight = null;&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (highlight) {&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;document.getElementById("info").style.visibility = "visible";&lt;BR /&gt;document.getElementById("name").innerHTML = "Street: " + name;&lt;BR /&gt;document.getElementById("town").innerHTML = "Town: " + town;&lt;BR /&gt;document.getElementById("usrn").innerHTML = "USRN: " + usrn;&lt;BR /&gt;document.getElementById("cust").innerHTML = "Customer: " + type;&lt;/P&gt;&lt;P&gt;const query = layerView.createQuery();&lt;BR /&gt;query.where = "SITE_CODE = '" + usrn + "'";&lt;BR /&gt;layerView.queryObjectIds(query).then((ids) =&amp;gt; {&lt;BR /&gt;if (highlight){&lt;BR /&gt;highlight.remove()&lt;BR /&gt;}&lt;BR /&gt;highlight = layerView.highlight(ids);&lt;BR /&gt;currentName = usrn;&lt;BR /&gt;currentCustomer = type;&lt;BR /&gt;&lt;BR /&gt;});&lt;BR /&gt;} else {&lt;BR /&gt;&lt;BR /&gt;if (highlight){&lt;BR /&gt;highlight.remove();&lt;BR /&gt;highlight = null;&lt;BR /&gt;}&lt;BR /&gt;document.getElementById("info").style.visibility = "hidden";&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 14:05:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hittest-different-highlight-based-on-feature-value/m-p/1215504#M78793</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-09-23T14:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: hitTest - different highlight based on feature value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hittest-different-highlight-based-on-feature-value/m-p/1215557#M78799</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You could to something like the following, however, I must admit that this is probably not supported. You can check the attribute value and reset the MapView.highlightOptions object before you setting the layerView.highlight.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (valueOfSomething &amp;lt;= 80){
  view.highlightOptions = {
    color:[160, 32, 240]
  };
}
else {
   view.highlightOptions = {
     color: "orange"
   };
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 23 Sep 2022 15:56:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hittest-different-highlight-based-on-feature-value/m-p/1215557#M78799</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2022-09-23T15:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: hitTest - different highlight based on feature value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hittest-different-highlight-based-on-feature-value/m-p/1217390#M78868</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your response. Where would I put this in my code, in the hittest itself or in the mapview?&lt;/P&gt;&lt;P&gt;Apologies for all the questions, I'm fairly new to JS so not always sure where to place things. Thanks&lt;/P&gt;&lt;P&gt;Ricky&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 14:38:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hittest-different-highlight-based-on-feature-value/m-p/1217390#M78868</guid>
      <dc:creator>ITApplications</dc:creator>
      <dc:date>2022-09-29T14:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: hitTest - different highlight based on feature value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hittest-different-highlight-based-on-feature-value/m-p/1217472#M78873</link>
      <description>&lt;LI-CODE lang="javascript"&gt;&lt;/LI-CODE&gt;&lt;P&gt;You should change the highlight colors in your if then statements&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Like here:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if (value = HW: Private)&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (value = HW: Private) {
 view.highlightOptions = {
    color:[160, 32, 240]
  };
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here is a simple codepen app shows how it is done:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/poVLyzr?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/poVLyzr?editors=1000&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 16:07:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hittest-different-highlight-based-on-feature-value/m-p/1217472#M78873</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2022-09-29T16:07:45Z</dc:date>
    </item>
  </channel>
</rss>

