Scale street labels depending on zoom level

This commit is contained in:
Markus Koch 2020-04-20 17:57:49 +02:00
parent be16cf2f6e
commit b9986f0b42

View File

@ -7,8 +7,8 @@ var streetLabelsRenderer = new L.StreetLabels({
return layer.geometry.type == "LineString"; return layer.geometry.type == "LineString";
}, },
fontStyle: { fontStyle: {
dynamicFontSize: false, dynamicFontSize: true,
fontSize: 10, fontSize: 11,
fontSizeUnit: "px", fontSizeUnit: "px",
lineWidth: 4.0, lineWidth: 4.0,
fillStyle: "black", fillStyle: "black",
@ -16,6 +16,15 @@ var streetLabelsRenderer = new L.StreetLabels({
}, },
}); });
streetLabelsRenderer._getDynamicFontSize = function () {
zoom = mymap.getZoom();
if (zoom <= 7)
return 11;
else
return 2**(zoom - 8) * 11;
}
// Projection fix from: https://gis.stackexchange.com/questions/200865/leaflet-crs-simple-custom-scale // Projection fix from: https://gis.stackexchange.com/questions/200865/leaflet-crs-simple-custom-scale
var factorx = 1 / 256 * 4; var factorx = 1 / 256 * 4;
var factory = factorx; var factory = factorx;