Displaying a tile when disconnected

Is it possible to determine whether or not Cesium has an internet connection and based on that use a SingleTileImageProvider to display one or more tiles when disconnected? I’ve been playing with this but haven’t gotten it to work. I’ve tried a few cuts at this but none seem to work even approximately. e.g.:

var viewer = new Cesium.Viewer(‘cesiumContainer’);
var layers = viewer.scene.imageryLayers;
layers.addImageryProvider(new Cesium.SingleTileImageryProvider({
url : tileUrl,
rectangle : tileArea
}));

``

This displays both the default globe and the single tile when connected, but if disconnected it displays neither, just the globe outline. On the other hand:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {
imageryProvider: new Cesium.SingleTileImageryProvider({
url : tileUrl,
rectangle : tileArea
})
});

``

flat out doesn’t work, neither displaying the tile when connected nor displaying even the globe outline when disconnected.

Thank you.

–Dale

The second one is going to outright fail because you’re overriding the default imagery providers, which fails a bit more gracefully when there is no internet connection.

This stack overflow article http://stackoverflow.com/questions/2384167/check-if-internet-connection-exists-with-javascript may help you.

You can delay the Cesium Initialization until after you’ve determined the state of your internet connection.

Mike,

Makes sense. I figured this largely was about me not knowing what I was doing. :wink: The question would be, though, even if I performed some kind of connection testing, how would I initialize Cesium to use a small set of tiles at that point? Or is it simply not possible?

–Dale