Notes · · 1 min read
Map symbols in one image
All the icons on a vector map come from one picture and a small index that says where each one is.
A vector style loads its icons from a sprite: one image holding every symbol side by side, and a small JSON index giving each symbol's position, width and height in that image. The app downloads both once and cuts out symbols as it needs them.
High density screens get their own copy. Alongside the standard sprite, a second set at twice the size is published with @2x in its name, and the index records the pixel ratio of each. A phone with a dense screen picks the sharper one; without it, every icon would be drawn blurred.
Symbols can also be stored as distance fields, like map fonts. Those are single colour, but the style can recolour them, so one drawing of a site marker serves every status: the same shape, a different colour, and a cross added for a closed site.
We draw field symbols on a small grid and test them at the size they appear on a phone held at arm's length, outdoors. A symbol that needs a legend to be understood is replaced by one that does not, where we can.