Road names and route numbers past z16 keep the same spacing on the ground (symbol-spacing grows with the zoom), not one every few meters at z22
This commit is contained in:
1 parent
500acf9fd5
commit
5958ffd153
1 file changed
+15
-1
+15
-1
@@ -9,7 +9,21 @@
|
||||
// same patched style, so the two can't drift apart.
|
||||
|
||||
export function patchOnlineStyle(style) {
|
||||
return insertTrackOnlyLayer(protectedAreasAndTextures(parkTilesStyle(style)));
|
||||
return insertTrackOnlyLayer(protectedAreasAndTextures(roadLabelSpacing(parkTilesStyle(style))));
|
||||
}
|
||||
|
||||
// Road names and route numbers repeat every symbol-spacing *pixels*, so
|
||||
// zoomed in close (z22) a street got its name every few meters. Past
|
||||
// z16 the spacing grows with the zoom: the same distance on the ground
|
||||
// (~400 m here) at every zoom.
|
||||
const ROAD_LABEL_FIXED_ZOOM = 16;
|
||||
function roadLabelSpacing(style) {
|
||||
for (const layer of style.layers) {
|
||||
if (layer.type !== "symbol" || layer["source-layer"] !== "transportation_name") continue;
|
||||
const spacing = layer.layout?.["symbol-spacing"] ?? 250; // the style spec's default
|
||||
layer.layout = { ...layer.layout, "symbol-spacing": ["interpolate", ["exponential", 2], ["zoom"], ROAD_LABEL_FIXED_ZOOM, spacing, 22, spacing * 64] };
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
const PARK_TILES_PATCH = {
|
||||
|
||||
Reference in new issue
Block a user