This is the documentation of version 0.62.3. Go to the latest version, 1.0.0-rc.5.

Editing style layers

For what the Styling module's knobs do not cover, styling.layers edits the loaded style's layers directly. It is the advanced, version-coupled tier: prefer a knob or setMapColors wherever one covers the intent.

The advanced tier: styling.layers

styling.layers.query(...) selects style layers by the base-map group taxonomy, layer type, source layer or id fragment — every constraint given must hold, so the others narrow a group — and edits their paint, layout, filter or visibility directly:

styling.layers.query({ group: 'roadLabels' }).setPaint({ 'text-color': '#93c5fd' });
styling.layers.query({ metadataGroups: ['water'], layerTypes: ['fill'] }).setPaint({ 'fill-opacity': 0.6 });
styling.layers.query({ idIncludes: ['railway'] }).setVisible(false);
styling.layers.query({ group: 'trafficFlow', layerTypes: ['line'] }).setPaint({ 'line-opacity': 0.6 });
styling.layers.query({ group: 'roadLabels' }).reset();

A group is either a base-map group, the same names BaseMapModule takes, or the layers of another style-owned module: pois, trafficFlow, trafficIncidents and hillshade. One query covers every style layer, whichever module shows or hides it.

Only the style's own layers

styling.layers and the knobs reach the layers the loaded style declares, nothing added on top of it. The layers a data-owned module adds take their overrides through that module's own layers configuration, merged over its defaults and kept across style switches:

Module Its layers entries
Places main, micro, selected, the cluster layers, and its connections' and entry points' own
Routing the route lines, waypoints, sections and their labels, by group (mainLines, sections, …)
Geometries, Reachable ranges fill, line, label, lineLabel
Traffic incident details the incident lines, from focusHalo to innerPattern, and the three markers
Traffic area analytics heatmap, each grid's fill, outline, extrusion and highlight, and the region

The layers you add through map.mapLibreMap are yours to style.

The two reach together: below, one switch fades the traffic flow, POIs and road labels through styling.layers groups, and brings a city's incidents and boundary forward through their modules' layers configs.

What an edit keeps

How durable is it?

This is the version-coupled tier, framed the way Map Maker frames raw layer editing: layer ids, property expressions and even which layers exist belong to the style version the map loads. A query that matches nothing warns once and does nothing.

map.mapLibreMap remains available below all of this (which to use when), though setPaintProperty on a style layer there is not re-applied after a style switch.

Related guides and examples

Related guides

Related examples