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.
getScale()
getZoom()
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";
});
Solved! Go to Solution.
Ian,
In 4.x events are not used very much instead you watch properties, like the view stationary property using watchUtils.
https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#stationary
https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html
Ian,
In 4.x events are not used very much instead you watch properties, like the view stationary property using watchUtils.
https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#stationary
https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html
Robert,
Thanks you for the input: I did try the following:
// Watch for the Scale on the Extent Change
mapView.watch('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.