mapbox / carto

fast CSS-like map stylesheets
https://cartocss.readthedocs.io/
Apache License 2.0
652 stars 129 forks source link

Use zoom level as variable for rendering #451

Closed csytsma closed 7 years ago

csytsma commented 7 years ago

Instead of having to manage rendering duplicate zoom levels (say in Tilemill), with the only difference a change in the number for a width or size, it would be great if the rendering zoom level could be referenced as a variable, and then use a multiplier to determine desired value.

For example, say we wanted: [zoom=15] { text-size: 18; } [zoom=16] { text-size: 19; }

Could instead be written, assuming that zoom_level would have a value of either 15 or 16: { text-size: [zoom_level] * 1.2; }

This would greatly collapse the repeated code used to render zoom levels and allow a simple reuse, and much easier to maintain.

Thanks, Cory

nebulon42 commented 7 years ago

See also https://github.com/mapbox/carto/blob/master/docs/latest.md#mapnik-render-time-variables

csytsma commented 7 years ago

@nebulon42, thanks for post. Do you know if that's the existing functionality that already allows you to use variables in Tilemill? I'm looking for the value of the variable to be set at render time, instead of explicitly setting it in the cartoCSS.

nebulon42 commented 7 years ago

AFAIK this is not yet implemented in Tilemill, but I have implemented it in Kosmtik: https://github.com/kosmtik/kosmtik (latest master should work, release pending)

nebulon42 commented 7 years ago

Actually a duplicate of #269.