1
2
3
4
5
6
7
8
9
// Use reactiveUtils to check when the view scale changes.// view.stationary is included so that a message is only shown// when the view is not moving.reactiveUtils.watch(
() => [view.stationary, view.scale], ([stationary, scale]) => {
if (stationary) {
console.log(`View Scale changed to: ${scale}`);
}
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Use reactiveUtils to check when the extent changes.// view.stationary is included so that a message is only shown// when the view is not moving.let oldExtent = view.extent;
reactiveUtils.watch(
() => [view.stationary, view.extent],
([stationary, extent], [wasStationary]) => {
if (stationary) {
console.log(`Current Extent: ${extent}`);
console.log(`Previous Extent: ${oldExtent}`);
} elseif (wasStationary) {
oldExtent = extent;
}
}
);
Use dark colors for code blocks
1
2
3
4
5
6
// Use reactiveUtils to check when a Collection has changedreactiveUtils.watch(
() => view.map.allLayers.every((layer) => layer.visible),
(allVisible) => {
console.log(`All layers are visible = ${allVisible}`)
});