<?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: How to detect Map's Zoom In / Out? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-detect-map-s-zoom-in-out/m-p/1050737#M72707</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You do not need to set up the watchUtils whenever you click or use mouse wheel on the viewDiv. You can set your logic to watch the zoom property as soon as the view is initialized and you set this only once.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following logic will be very chatty. Your onZoomChange will trigger many times until the view is zoomed into its final level.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;context.esriModules.watchUtils.watch(context.view, "zoom", onZoomChange);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to run the code when the view is done zooming then you can do the following. Instead of watching view's&amp;nbsp;&lt;EM&gt;zoom&lt;/EM&gt; property, watch the view's &lt;EM&gt;updating&lt;/EM&gt; property. The &lt;EM&gt;view.updating&lt;/EM&gt; will become &lt;EM&gt;true&lt;/EM&gt; while user is zooming in or out. Then its value will change to &lt;EM&gt;false&lt;/EM&gt; once the zoom ends. Now you can get the view's new zoom level and run your logic.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; const view = new MapView({
  container: "viewDiv",
  map: map,
  zoom: 4,
  center: [15, 65] // longitude, latitude
});

// Watch view's updating event
watchUtils.watch(view, "updating", onZoomChange);
function onZoomChange(newValue, oldValue, propertyName, target) {
 if (!view.updating){
  // View just finished updating. Get the new zoom value from the view
    console.log("view.stationary", view.stationary, "view.updating", view.updating, view.zoom)
 }
}&lt;/LI-CODE&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>Fri, 23 Apr 2021 15:55:35 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2021-04-23T15:55:35Z</dc:date>
    <item>
      <title>How to detect Map's Zoom In / Out?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-detect-map-s-zoom-in-out/m-p/1050007#M72692</link>
      <description>&lt;P&gt;In my App, I need a function to detect map's zoom in/out.&amp;nbsp; Referring to&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript/detect-change-in-zoom-when-complete/m-p/540607" target="_blank"&gt;https://community.esri.com/t5/arcgis-api-for-javascript/detect-change-in-zoom-when-complete/m-p/540607&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I added the following code in the script:&lt;/P&gt;&lt;P&gt;$('#viewDiv').mousedown(function() {&lt;BR /&gt;context._mapClick(context);&lt;BR /&gt;});&lt;BR /&gt;$("#viewDiv").on('wheel', function() {&lt;BR /&gt;context._mapClick(context);&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;_mapClick: function (context) {&lt;BR /&gt;&amp;nbsp; debugger;&lt;BR /&gt;&amp;nbsp; context.esriModules.watchUtils.watch(context.view, "zoom", onZoomChange);&lt;/P&gt;&lt;P&gt;&amp;nbsp; function onZoomChange(newValue, oldValue, propertyName, target) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;debugger;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if (!target.updating &amp;amp;&amp;amp; oldValue &amp;gt; newValue) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;contx.crimeTable.clearSelection();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;BR /&gt;},&lt;/P&gt;&lt;P&gt;In Chrome's debugging, the&amp;nbsp;_mapClick: function () does fire, but after&amp;nbsp; &amp;nbsp;debugging;&amp;nbsp; the&amp;nbsp;function onZoomChange() is not implemented.&amp;nbsp; &amp;nbsp;What's wrong in my coding?&amp;nbsp; Thanks if you can help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 11:37:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-detect-map-s-zoom-in-out/m-p/1050007#M72692</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2021-04-22T11:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to detect Map's Zoom In / Out?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-detect-map-s-zoom-in-out/m-p/1050737#M72707</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You do not need to set up the watchUtils whenever you click or use mouse wheel on the viewDiv. You can set your logic to watch the zoom property as soon as the view is initialized and you set this only once.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following logic will be very chatty. Your onZoomChange will trigger many times until the view is zoomed into its final level.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;context.esriModules.watchUtils.watch(context.view, "zoom", onZoomChange);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to run the code when the view is done zooming then you can do the following. Instead of watching view's&amp;nbsp;&lt;EM&gt;zoom&lt;/EM&gt; property, watch the view's &lt;EM&gt;updating&lt;/EM&gt; property. The &lt;EM&gt;view.updating&lt;/EM&gt; will become &lt;EM&gt;true&lt;/EM&gt; while user is zooming in or out. Then its value will change to &lt;EM&gt;false&lt;/EM&gt; once the zoom ends. Now you can get the view's new zoom level and run your logic.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; const view = new MapView({
  container: "viewDiv",
  map: map,
  zoom: 4,
  center: [15, 65] // longitude, latitude
});

// Watch view's updating event
watchUtils.watch(view, "updating", onZoomChange);
function onZoomChange(newValue, oldValue, propertyName, target) {
 if (!view.updating){
  // View just finished updating. Get the new zoom value from the view
    console.log("view.stationary", view.stationary, "view.updating", view.updating, view.zoom)
 }
}&lt;/LI-CODE&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>Fri, 23 Apr 2021 15:55:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-detect-map-s-zoom-in-out/m-p/1050737#M72707</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-04-23T15:55:35Z</dc:date>
    </item>
  </channel>
</rss>

