<?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: Cannot detect lastroute update in Directions web component v4.32 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-detect-lastroute-update-in-directions-web/m-p/1609094#M87030</link>
    <description>&lt;P&gt;You can use the `arcgisPropertyChange` event to check the state of the component. If the state is ready, than `lastRoute` has been updated.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;arcgis-map center="-118,34" zoom="12" item-id="45b3b2fb35e94ab09381d0caa0da5946"&amp;gt;
  &amp;lt;arcgis-directions position="top-left" use-default-route-layer&amp;gt;&amp;lt;/arcgis-directions&amp;gt;
&amp;lt;/arcgis-map&amp;gt;
&amp;lt;script type="module"&amp;gt;
  const directionsElement = document.querySelector("arcgis-directions");
  directionsElement.addEventListener("arcgisPropertyChange", (e) =&amp;gt; {
    if (
      event.detail.name !== "state" ||
      directionsElement.state !== "ready"
    ) {
      // You only care about when the `state` of the component is "ready"
      return;
    }
    
    if (directionsElement.lastRoute) {
      console.log("New directions are set");
    }
  })
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://codepen.io/odoe/pen/Pwwpxao?editors=1001" target="_blank"&gt;https://codepen.io/odoe/pen/Pwwpxao?editors=1001&lt;/A&gt;&lt;/P&gt;&lt;P&gt;We can look at adding the `lastRoute` to trigger this change event as well.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Apr 2025 23:22:23 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2025-04-24T23:22:23Z</dc:date>
    <item>
      <title>Cannot detect lastroute update in Directions web component v4.32</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-detect-lastroute-update-in-directions-web/m-p/1609064#M87026</link>
      <description>&lt;P&gt;Hi gents,&lt;BR /&gt;I tried to implement Directions Web components introduced in v4.32 javscript Arcgis API/&lt;/P&gt;&lt;P&gt;I don't find the right way to detect lastroute update once 2 stops are set.&lt;BR /&gt;I supposed &lt;FONT face="courier new,courier"&gt;lastRoute &lt;/FONT&gt;is not a direct property of "&lt;FONT face="courier new,courier"&gt;directionsWidget"&lt;/FONT&gt; object.&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;&lt;P&gt;Here the way I do it :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;inside HTML file&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;lt;arcgis-directions id='arcgisdirections' api-key='API_KEY' position='top-right' unit='kilometers' use-default-route-layer&amp;gt;&amp;lt;/arcgis-directions&amp;gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;inside Javascript file&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;const directionsWidget = document.getElementById("arcgisdirections");&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;reactiveUtils.when(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;() =&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;directionsWidget.lastRoute &amp;amp;&amp;amp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;directionsWidget.lastRoute.routeInfo &amp;amp;&amp;amp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;directionsWidget.lastRoute.routeInfo.geometry,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;() =&amp;gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;console.log("New directions are set");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is working fine with a classic Directions widget, full javascript initiated :&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;const directionsWidget = new Directions({&lt;BR /&gt;view: view,&lt;BR /&gt;apiKey: apiKey,&lt;BR /&gt;layer: routeLayer&lt;BR /&gt;});&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 17:43:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-detect-lastroute-update-in-directions-web/m-p/1609064#M87026</guid>
      <dc:creator>MarcStationsGPL</dc:creator>
      <dc:date>2025-04-25T17:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot detect lastroute update in Directions web component v4.32</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-detect-lastroute-update-in-directions-web/m-p/1609094#M87030</link>
      <description>&lt;P&gt;You can use the `arcgisPropertyChange` event to check the state of the component. If the state is ready, than `lastRoute` has been updated.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;arcgis-map center="-118,34" zoom="12" item-id="45b3b2fb35e94ab09381d0caa0da5946"&amp;gt;
  &amp;lt;arcgis-directions position="top-left" use-default-route-layer&amp;gt;&amp;lt;/arcgis-directions&amp;gt;
&amp;lt;/arcgis-map&amp;gt;
&amp;lt;script type="module"&amp;gt;
  const directionsElement = document.querySelector("arcgis-directions");
  directionsElement.addEventListener("arcgisPropertyChange", (e) =&amp;gt; {
    if (
      event.detail.name !== "state" ||
      directionsElement.state !== "ready"
    ) {
      // You only care about when the `state` of the component is "ready"
      return;
    }
    
    if (directionsElement.lastRoute) {
      console.log("New directions are set");
    }
  })
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="https://codepen.io/odoe/pen/Pwwpxao?editors=1001" target="_blank"&gt;https://codepen.io/odoe/pen/Pwwpxao?editors=1001&lt;/A&gt;&lt;/P&gt;&lt;P&gt;We can look at adding the `lastRoute` to trigger this change event as well.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2025 23:22:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-detect-lastroute-update-in-directions-web/m-p/1609094#M87030</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2025-04-24T23:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot detect lastroute update in Directions web component v4.32</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-detect-lastroute-update-in-directions-web/m-p/1609299#M87049</link>
      <description>&lt;P&gt;Thank you so much ReneRubalcava !&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 17:55:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cannot-detect-lastroute-update-in-directions-web/m-p/1609299#M87049</guid>
      <dc:creator>MarcStationsGPL</dc:creator>
      <dc:date>2025-04-25T17:55:53Z</dc:date>
    </item>
  </channel>
</rss>

