Are Map Tiles an Obsolete Technology?
In a March 2023 episode of MapScaping, we discussed Protomaps, a serverless system for creating and serving tiled web maps. But what is a tiled web map, and why would you use it?
Map tiles are a technique for displaying dynamic maps. In contrast to a print or image map displayed at a single size, tiles are one huge map sliced into squares, like how a rectangular brownie is cut into bite-size pieces.
Around the year 2000, map services on the web like MapQuest were made of single images. The map position and scale could be changed with webpage navigation, but lacked fluid panning and zooming gestures. Google Maps was one of the first web applications to offer a seamless “slippy” map, made possible with dynamic web technologies like AJAX. These slippy maps divide the map view into thousands or millions of individual tiles, for a few technical and aesthetic reasons.
Consider a single map view centered around San Francisco. At small scale, it includes the coastline of the continental United States; the underlying database feature for that coastline might extend along the entire state of California, the US national boundary, or even the entire continent of North America. If loading the map demanded a full version – every single vertex – of this feature, it could download hundreds of megabytes of data! Even the fastest WiFi connection would take 10+ seconds to load this.
Properly prepared map tiles clip lines and polygons to the square extents of each tile. Every tile contains a limited amount of points, even if the view is adjacent to complex geometry like a continental coastline. Automated clipping of complex geometry, polygons in particular, requires advanced algorithms like JTS Overlay which makes map tiling computationally expensive. Slippy map systems cache pre-clipped tiles to guarantee each map view loads in the shortest time and with the least amount of data transfer, of no more than a few hundred kilobytes.
Map tiles are not only 2D; they’re a “pyramid” of zoom levels, with each level being double the size of the previous. One parent tile contains 4 child tiles. The number of tiles on each zoom level is a rapidly increasing sequence: 1 on zoom 0, 4 on 1, 16, 64, 256, 1024, 4096, 16384, 65536… A general purpose basemap could have 15 zoom levels, which sums to over 200 million tiles!
It’s important to notice the that parent tiles must not contain 100% of the data among all sub-tiles. If each sub-tile was a reasonable size of 300 kilobytes, the parent would be over a megabyte; the parent tile a level above would be over 4 megabytes, and the next 16; making each preceding zoom level more and more massive.
Creating efficient map tiles at all zoom levels implies what cartographers call generalization: the refinement of map feature display for different scales. It’s similar to the concept of Dynamic LOD (level of detail) in computer graphics. For vector tiles, each parent tile undergoes simplification with algorithms like Douglas-Peucker to remove unnecessary detail. Features are removed depending on the visual design intent of the map via tools like tippecanoe: small geometries may be dropped in favor of more visually impactful lines and polygons. For raster imagery, pixel-based downsampling reduces the size of image tiles.
Self-contained tiles and generalization can result in tiles of a few hundred kilobytes for any area, even the whole world. This makes them great for interactive applications, where the user might pan the map with their thumb, zoom in, or start a “fly to” animation for markers on the map. This results in the user experience consumers expect in 2023, similar to built-in smartphone apps from Google and Apple.
All the aforementioned processing steps means tiles are unsuited for many typical use cases. If a dataset of 10 million buildings in Europe is processed in a compact tile at zoom level 0, that tile could contain only a few thousand features, meaning a majority of the dataset is “missing”. Tiling for user experience display comes at the expense of accuracy: a program to count the number of buildings cannot get the right result from a generalized tile. Furthermore, features at tile edges might be duplicated into neighboring tiles, meaning even high-zoom tiles are inappropriate for analytical tasks.
Map tiles are both an essential technology and overused technology. They are not a general-purpose storage format; they are a read-optimized and imprecise view over datasets that would otherwise be inefficient to transfer.
Map tiles make sense if your dataset exceeds what can be downloaded in one shot. If you have a vector dataset of less than a megabyte, GeoJSON might be a better fit. Making data into tiles is never free; it is a “lossy” process that reduces precision of your dataset.
However, map tiles are the only way to create a seamless, smooth and multi-scale user experience for large planet-scale geo-data. Even as devices become more powerful, the detail and volume of geo data grows commensurately. The boundless supply of rich data, combined with the demand for smooth, instant-loading maps, means tiling will always remain an essential part of the digital mapmaker’s toolkit.
If you enjoyed this article, fere are a few podcasts you might find interesting