I have a view which uses a webmap instance. According to the documentation, MapView can leverage the when() function to indicate that the view is ready to be manipulated. But I'm getting a "view.when is not a function" error in browser console.
The code I'm using is:
var webmap = new WebMap({
portalItem: {
id: "<some long id>"
}
});
var view = new MapView({
map: webmap,
container: "esriMap"
});
view.when(function(){ // this line is throwing the error
}, function(error){
alert(error.message);
});
I'm using ESRI Javascript v4.5 API. What am I missing here?
Solved! Go to Solution.
Nisar,
The when was introduced in 4.6 not 4.5.
At 4.6, then()
is deprecated in favor of when(). The then()
method will still be honored at 4.6, but will throw warning messages in the browser developer console, to ease the process of updating apps to using when(). We made this change to allow the use of native ES6 promises within the context of the ArcGIS API for JavaScript.
Nisar,
The when was introduced in 4.6 not 4.5.
At 4.6, then()
is deprecated in favor of when(). The then()
method will still be honored at 4.6, but will throw warning messages in the browser developer console, to ease the process of updating apps to using when(). We made this change to allow the use of native ES6 promises within the context of the ArcGIS API for JavaScript.
Oh, my bad! Don't know how I missed the version number.