Hi there,
I am able to reproduce the issue you described. It appears that `view.updating` value changes several time during basemap swapping. So the `view.takeScreenshot()` is called several times and the images sometimes get returned out of order. I created an issue for this.
In meantime, please add a setTimeout before you call takeScreenshot and this will ensure you get the right image.
view.watch("updating", async (val) => {
if (!val) {
setTimeout(function(){
view.takeScreenshot().then(function(screenshot){
screenshotDiv.src = screenshot.dataUrl;
});
}, 500);
}
});
-Undral