Automatic Projection Tiles

Mercator tiles for the Albers equal-area conic projection over the middle viewport rectangle. Panning and zooming are supported.

What are Tiles?

Most modern Web maps use raster or vector tiles to allow zooming to very large scales while only loading a fraction of the whole map. The projection of choice for these tiles is the Mercator projection, and they are typically arranged in the form of a recursively subdivided quadtree.

It would be a shame to limit ourselves to a single map projection, when there are so many to choose from! But how do we figure out which tiles to retrieve?

How it Works

My initial attempts involved inverting the viewport polygon to figure out which tiles overlap with it. It worked, but slowed down with larger zoom levels.

Mike Bostock then pointed out that the tiles can be traversed recursively (in logarithmic time, since it’s a tree), using a custom geometry stream to detect if a tile is visible or not.

Starting with a single large tile covering most of the globe, this recursively rejects large swathes of the quadtree, and is very fast even at a zoom level of 18!