I have an Arcgis Online map which use refreshInterval for automatic updates.
I need to intercept an event when the network goes offline or online, like it’s done in the Map Viewer with the orange triangle at the bottom left (when I put the Network to Offline with Chrome developer tools):
I tried to capture an error event on the map and on the layers, but it’s not working (with javascript api 4.16, in angular):
const webMap = new this._WebMap({
portalItem: {
id: arcgisOnlineMapId
}
});
this.mapView = new this._MapView({
container: this.mapViewEl.nativeElement,
map: webMap
});
await this.mapView.when();
this.mapView.on('error', (error) => {
console.error(`mapView error: ${error}`);
});
this.mapView.map.layers.on('error', (error) => {
console.error(`layers error: ${error}`);
});
How can I do that ?
Same question for an event when the network comes back.
Thanks !
This isn't really something you would check with the API. A more reliable way is to use the browsers native.onLine property and event listeners to manage this.