Map styling playground

Restyle the map from panels built off the knob catalogues of each module drawing it: sizes, the label typeface, road markings, hillshade, POI and traffic colours, map presets, and whole layer groups

View on GitHub
SDK 1.0.0

Every control restyles the map live: sizes, the label typeface, road markings, base-map groups, hillshade, and POI, traffic and map colours.

  • The panel is generated from the knob catalogues of the modules that draw the map: stylingFoundationsKnobCatalogue for the foundations (sizes, typeface, map colours, projection, sky, light and 3D building corners), and the look knobs of BaseMapModule (road markings), POIsModule, the traffic modules and TerrainModule (hillshade). Each control starts from getKnob and sets its value with setKnob, so no layer or paint property is yours to find.
  • The Labels section sets the map’s typeface, from ten open-source families or the style’s own serif and italic faces. A route, museums and a district follow it, until you give each a typeface of its own. The route’s curves over Twin Peaks keep their rose on every theme.
  • The View light section sets the light on the 3D buildings, and the 3D buildings section how round their corners are. To see them, turn on buildings3D among the layer groups, zoom in past 15 and tilt the map with a right-drag.
  • Each section folds away, so open only the ones you’re tuning.
  • Map presets come from mapPresetCatalogue, and applyMapPreset sets each one across those modules.
  • Whole layer groups (water, railways, 3D buildings, road shields…) are BaseMapModule’s, so their toggles come from baseMapKnobCatalogue, through the same control builder.
  • The knobs survive a setStyle, and so do the layer edits made through styling.layers.query. A reset keeps those edits because they are not settings. A query’s group names base-map layers or another module’s, here the traffic flow lines.
  • The motorway names edit derives its halo from the one beneath it, so it keeps the label halo map colour you pick. The major roads edit adds a clause to the style’s own filter instead of replacing it.

Related examples