JavaScript 4.x - looking to have the map scale update on Extent Change

Jump to solution
04-04-2019 01:29 PM
Regular Contributor

Has anyone been successful getting the map scale to update in console.log when an extent change is performed (through zooming with the mouse event: "zoom-end")?

I am looking for a method in the 4.x API that is similar to the following methods using the 3.x API:

will update when "zoom-end" is completed.



I do have this working in the 3.x environment, but not having much luck using the 4.x API reference.

Here is a block of code I used for the 3.x API and it works well:

// Return Map Scale Results to Application - Calculation (/12) based on Feet NOT Meters
  map.on("zoom-end", function() {
  var returnZoomResult = document.getElementById("zoomToScaleResults");
  var scale = map.getScale()/12;
  var roundScale = Math.round(scale);
  returnZoomResult.innerHTML = roundScale + " feet";

0 Kudos
1 Solution

Accepted Solutions
MVP Esteemed Contributor
2 Replies
MVP Esteemed Contributor


  In 4.x events are not used very much instead you watch properties, like the view stationary property using watchUtils.

Regular Contributor


Thanks you for the input:  I did try the following:

// Watch for the Scale on the Extent Change'extent', function(){
   console.log("Watch for the current scale: ", mapView.scale);

This is what I am wanting .  Each time the extent changes, the scale refreshes.