Select to view content in your preferred language

Detecting Zoom Start and end, and pan in 4.x

165
1
05-15-2024 02:12 PM
DanielScholes
New Contributor II

I am migrating an older web interface to the newer java api 4.x. In the older interface I could make calls, such as these to detect when the map was zoomed in, out, or panned.

dojo.connect(map, "onZoomStart", showLoadingSpinner);
dojo.connect(map, "onPanStart", showLoadingSpinner);

I can do something similar with the following code, but it is not as granular and a bit difficult to detect when different parts of the interface have been updated, including when the process is complete. For example if the sketch is active, I believe it trips the updating. Are there any better suggestions of detecting these actions?

const handle = reactiveUtils.when(
() => view.updating,
() => {
console.log('updating');
console.log(view.updating);
showLoadingSpinner();
},
{ once: false }
);

 

Thanks for your time!

Dan

0 Kudos
1 Reply
JamesIng
New Contributor III

If your methods are navigating via the goTo() method, you could watch the 'animating' property

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#animation

From the example:
reactiveUtils.watch(
  () => view.animation,
  (response) => {
    if(response?.state === "running"){
      console.log("Animation in progress");
    } else{
     console.log("No animation");
    }
  }
);
James from www.landkind.com
0 Kudos