Using Service Workers to provide offline capable maps: An experiment

This example shows a basic map that has an OpenStreetMap layer and on top of that a GeoJSON for countries. The resources we use in this example are raster tiles from openstreetmap.org and a local raw GeoJSON.

Once you open the example, a Service Worker is instantiated, that tries to cache all needed resources, so that the map should basically work the same, even if you are offline. In particular, we instruct capable browsers (e.g. Chrome >= v46) to cache worldwide osm tiles up to zoom level 6. All the other page resources are cached as well.

How to try this? Just open this example in a browser, wait some time, and then go offline. You should still be able to reload the page, go to some places where you have never been before and interact with the GeoJSON.

This is a work in progress and not more than a proof-of-concept, but nonetheless it looks promosing. If you have any questions, just contact us: info@terrestris.