35 KiB
Carto documentation
The following is a list of properties provided in CartoCSS that you can apply to map elements.
All elements
image-filters functions
Default Value: none (no filters)
A list of image filters.
comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current layer on top of other layers)
Composite operation. This defines how this layer should behave relative to layers atop or below it.
opacity float
Default Value: 1 (no separate buffer will be used and no alpha will be applied to the style after rendering)
An alpha value for the style (which means an alpha applied to all features in separate buffer and then composited back to main buffer)
map
background-color color
Default Value: none (transparent)
Map Background color
background-image uri
Default Value: (transparent)
An image that is repeated below all features on a map as a background.
srs string
Default Value: +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs (The proj4 literal of EPSG:4326 is assumed to be the Map's spatial reference and all data from layers within this map will be plotted using this coordinate system. If any layers do not declare an srs value then they will be assumed to be in the same srs as the Map and not transformations will be needed to plot them in the Map's coordinate space)
Map spatial reference (proj4 string)
buffer-size float
Default Value: 0 (No buffer will be used)
Extra tolerance around the map (in pixels) used to ensure labels crossing tile boundaries are equally rendered in each tile (e.g. cut in each tile). Not intended to be used in combination with "avoid-edges".
base string
Default Value: (This base path defaults to an empty string meaning that any relative paths to files referenced in styles or layers will be interpreted relative to the application process.)
Any relative paths used to reference files will be understood as relative to this directory path if the map is loaded from an in memory object rather than from the filesystem. If the map is loaded from the filesystem and this option is not provided it will be set to the directory of the stylesheet.
font-directory uri
Default Value: none (No map-specific fonts will be registered)
Path to a directory which holds fonts which should be registered when the Map is loaded (in addition to any fonts that may be automatically registered).
polygon
polygon-fill color
Default Value: rgba(128,128,128,1) (gray and fully opaque (alpha = 1), same as rgb(128,128,128))
Fill color to assign to a polygon
polygon-opacity float
Default Value: 1 (opaque)
The opacity of the polygon
polygon-gamma float
Default Value: 1 (fully antialiased) Range: 0-1 Level of antialiasing of polygon edges
polygon-gamma-method keyword
power``linear``none``threshold``multiply
Default Value: power (pow(x,gamma) is used to calculate pixel gamma, which produces slightly smoother line and polygon antialiasing than the 'linear' method, while other methods are usually only used to disable AA)
An Antigrain Geometry specific rendering hint to control the quality of antialiasing. Under the hood in Mapnik this method is used in combination with the 'gamma' value (which defaults to 1). The methods are in the AGG source at https://github.com/mapnik/mapnik/blob/master/deps/agg/include/agg_gamma_functions.h
polygon-clip boolean
Default Value: true (geometry will be clipped to map bounds before rendering)
geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts.
polygon-smooth float
Default Value: 0 (no smoothing) Range: 0-1 Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries.
polygon-geometry-transform functions
Default Value: none (geometry will not be transformed)
Allows transformation functions to be applied to the geometry.
polygon-comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current symbolizer on top of other symbolizer)
Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.
line
line-color color
Default Value: rgba(0,0,0,1) (black and fully opaque (alpha = 1), same as rgb(0,0,0))
The color of a drawn line
line-width float
Default Value: 1
The width of a line in pixels
line-opacity float
Default Value: 1 (opaque)
The opacity of a line
line-join keyword
miter``round``bevel
Default Value: miter
The behavior of lines when joining
line-cap keyword
butt``round``square
Default Value: butt
The display of line endings
line-gamma float
Default Value: 1 (fully antialiased) Range: 0-1 Level of antialiasing of stroke line
line-gamma-method keyword
power``linear``none``threshold``multiply
Default Value: power (pow(x,gamma) is used to calculate pixel gamma, which produces slightly smoother line and polygon antialiasing than the 'linear' method, while other methods are usually only used to disable AA)
An Antigrain Geometry specific rendering hint to control the quality of antialiasing. Under the hood in Mapnik this method is used in combination with the 'gamma' value (which defaults to 1). The methods are in the AGG source at https://github.com/mapnik/mapnik/blob/master/deps/agg/include/agg_gamma_functions.h
line-dasharray numbers
Default Value: none (solid line)
A pair of length values [a,b], where (a) is the dash length and (b) is the gap length respectively. More than two values are supported for more complex patterns.
line-dash-offset numbers
Default Value: none (solid line)
valid parameter but not currently used in renderers (only exists for experimental svg support in Mapnik which is not yet enabled)
line-miterlimit float
Default Value: 4 (Will auto-convert miters to bevel line joins when theta is less than 29 degrees as per the SVG spec: 'miterLength / stroke-width = 1 / sin ( theta / 2 )')
The limit on the ratio of the miter length to the stroke-width. Used to automatically convert miter joins to bevel joins for sharp angles to avoid the miter extending beyond the thickness of the stroking path. Normally will not need to be set, but a larger value can sometimes help avoid jaggy artifacts.
line-clip boolean
Default Value: true (geometry will be clipped to map bounds before rendering)
geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts.
line-smooth float
Default Value: 0 (no smoothing) Range: 0-1 Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries.
line-offset float
Default Value: 0 (no offset)
Offsets a line a number of pixels parallel to its actual path. Postive values move the line left, negative values move it right (relative to the directionality of the line).
line-rasterizer keyword
full``fast
Default Value: full
Exposes an alternate AGG rendering method that sacrifices some accuracy for speed.
line-geometry-transform functions
Default Value: none (geometry will not be transformed)
Allows transformation functions to be applied to the geometry.
line-comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current symbolizer on top of other symbolizer)
Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.
markers
marker-file uri
Default Value: (An ellipse or circle, if width equals height)
An SVG file that this marker shows at each placement. If no file is given, the marker will show an ellipse.
marker-opacity float
Default Value: 1 (The stroke-opacity and fill-opacity will be used)
The overall opacity of the marker, if set, overrides both the opacity of both the fill and stroke
marker-fill-opacity float
Default Value: 1 (opaque)
The fill opacity of the marker
marker-line-color color
Default Value: black
The color of the stroke around a marker shape.
marker-line-width float
Default Value: undefined
The width of the stroke around a marker shape, in pixels. This is positioned on the boundary, so high values can cover the area itself.
marker-line-opacity float
Default Value: 1 (opaque)
The opacity of a line
marker-placement keyword
point``line``interior
Default Value: point (Place markers at the center point (centroid) of the geometry)
Attempt to place markers on a point, in the center of a polygon, or if markers-placement:line, then multiple times along a line. 'interior' placement can be used to ensure that points placed on polygons are forced to be inside the polygon interior
marker-multi-policy keyword
each``whole``largest
Default Value: each (If a feature contains multiple geometries and the placement type is either point or interior then a marker will be rendered for each)
A special setting to allow the user to control rendering behavior for 'multi-geometries' (when a feature contains multiple geometries). This setting does not apply to markers placed along lines. The 'each' policy is default and means all geometries will get a marker. The 'whole' policy means that the aggregate centroid between all geometries will be used. The 'largest' policy means that only the largest (by bounding box areas) feature will get a rendered marker (this is how text labeling behaves by default).
marker-type keyword
arrow``ellipse
Default Value: ellipse
The default marker-type. If a SVG file is not given as the marker-file parameter, the renderer provides either an arrow or an ellipse (a circle if height is equal to width)
marker-width expression
Default Value: 10
The width of the marker, if using one of the default types.
marker-height expression
Default Value: 10
The height of the marker, if using one of the default types.
marker-fill color
Default Value: blue
The color of the area of the marker.
marker-allow-overlap boolean
Default Value: false (Do not allow makers to overlap with each other - overlapping markers will not be shown.)
Control whether overlapping markers are shown or hidden.
marker-ignore-placement boolean
Default Value: false (do not store the bbox of this geometry in the collision detector cache)
value to control whether the placement of the feature will prevent the placement of other features
marker-spacing float
Default Value: 100
Space between repeated labels
marker-max-error float
Default Value: 0.2
The maximum difference between actual marker placement and the marker-spacing parameter. Setting a high value can allow the renderer to try to resolve placement conflicts with other symbolizers.
marker-transform functions
Default Value: (No transformation)
SVG transformation definition
marker-clip boolean
Default Value: true (geometry will be clipped to map bounds before rendering)
geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts.
marker-smooth float
Default Value: 0 (no smoothing) Range: 0-1 Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries.
marker-geometry-transform functions
Default Value: none (geometry will not be transformed)
Allows transformation functions to be applied to the geometry.
marker-comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current symbolizer on top of other symbolizer)
Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.
shield
shield-name expression
Default Value: undefined
Value to use for a shield"s text label. Data columns are specified using brackets like [column_name]
shield-file uri
Default Value: none
Image file to render behind the shield text
shield-face-name string
Default Value:
Font name and style to use for the shield text
shield-unlock-image boolean
Default Value: false (text alignment relative to the shield image uses the center of the image as the anchor for text positioning.)
This parameter should be set to true if you are trying to position text beside rather than on top of the shield image
shield-size float
Default Value: undefined
The size of the shield text in pixels
shield-fill color
Default Value: undefined
The color of the shield text
shield-placement keyword
point``line``vertex``interior
Default Value: point
How this shield should be placed. Point placement attempts to place it on top of points, line places along lines multiple times per feature, vertex places on the vertexes of polygons, and interior attempts to place inside of polygons.
shield-avoid-edges boolean
Default Value: false
Tell positioning algorithm to avoid labeling near intersection edges.
shield-allow-overlap boolean
Default Value: false (Do not allow shields to overlap with other map elements already placed.)
Control whether overlapping shields are shown or hidden.
shield-min-distance float
Default Value: 0
Minimum distance to the next shield symbol, not necessarily the same shield.
shield-spacing float
Default Value: 0
The spacing between repeated occurrences of the same shield on a line
shield-min-padding float
Default Value: 0
Determines the minimum amount of padding that a shield gets relative to other shields
shield-wrap-width unsigned
Default Value: 0
Length of a chunk of text in characters before wrapping text
shield-wrap-before boolean
Default Value: false
Wrap text before wrap-width is reached. If false, wrapped lines will be a bit longer than wrap-width.
shield-wrap-character string
Default Value:
Use this character instead of a space to wrap long names.
shield-halo-fill color
Default Value: #FFFFFF (white)
Specifies the color of the halo around the text.
shield-halo-radius float
Default Value: 0 (no halo)
Specify the radius of the halo in pixels
shield-character-spacing unsigned
Default Value: 0
Horizontal spacing between characters (in pixels). Currently works for point placement only, not line placement.
shield-line-spacing unsigned
Default Value: undefined
Vertical spacing between lines of multiline labels (in pixels)
shield-text-dx float
Default Value: 0
Displace text within shield by fixed amount, in pixels, +/- along the X axis. A positive value will shift the text right
shield-text-dy float
Default Value: 0
Displace text within shield by fixed amount, in pixels, +/- along the Y axis. A positive value will shift the text down
shield-dx float
Default Value: 0
Displace shield by fixed amount, in pixels, +/- along the X axis. A positive value will shift the text right
shield-dy float
Default Value: 0
Displace shield by fixed amount, in pixels, +/- along the Y axis. A positive value will shift the text down
shield-opacity float
Default Value: 1
(Default 1.0) - opacity of the image used for the shield
shield-text-opacity float
Default Value: 1
(Default 1.0) - opacity of the text placed on top of the shield
shield-horizontal-alignment keyword
left``middle``right``auto
Default Value: auto
The shield's horizontal alignment from its centerpoint
shield-vertical-alignment keyword
top``middle``bottom``auto
Default Value: middle
The shield's vertical alignment from its centerpoint
shield-text-transform keyword
none``uppercase``lowercase``capitalize
Default Value: none
Transform the case of the characters
shield-justify-alignment keyword
left``center``right``auto
Default Value: auto
Define how text in a shield's label is justified
shield-clip boolean
Default Value: true (geometry will be clipped to map bounds before rendering)
geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts.
shield-comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current symbolizer on top of other symbolizer)
Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.
line-pattern
line-pattern-file uri
Default Value: none
An image file to be repeated and warped along a line
line-pattern-clip boolean
Default Value: true (geometry will be clipped to map bounds before rendering)
geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts.
line-pattern-smooth float
Default Value: 0 (no smoothing) Range: 0-1 Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries.
line-pattern-geometry-transform functions
Default Value: none (geometry will not be transformed)
Allows transformation functions to be applied to the geometry.
line-pattern-comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current symbolizer on top of other symbolizer)
Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.
polygon-pattern
polygon-pattern-file uri
Default Value: none
Image to use as a repeated pattern fill within a polygon
polygon-pattern-alignment keyword
local``global
Default Value: local
Specify whether to align pattern fills to the layer or to the map.
polygon-pattern-gamma float
Default Value: 1 (fully antialiased) Range: 0-1 Level of antialiasing of polygon pattern edges
polygon-pattern-opacity float
Default Value: 1 (The image is rendered without modifications)
(Default 1.0) - Apply an opacity level to the image used for the pattern
polygon-pattern-clip boolean
Default Value: true (geometry will be clipped to map bounds before rendering)
geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts.
polygon-pattern-smooth float
Default Value: 0 (no smoothing) Range: 0-1 Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries.
polygon-pattern-geometry-transform functions
Default Value: none (geometry will not be transformed)
Allows transformation functions to be applied to the geometry.
polygon-pattern-comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current symbolizer on top of other symbolizer)
Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.
raster
raster-opacity float
Default Value: 1 (opaque)
The opacity of the raster symbolizer on top of other symbolizers.
raster-filter-factor float
Default Value: -1 (Allow the datasource to choose appropriate downscaling.)
This is used by the Raster or Gdal datasources to pre-downscale images using overviews. Higher numbers can sometimes cause much better scaled image output, at the cost of speed.
raster-scaling keyword
near``fast``bilinear``bilinear8``bicubic``spline16``spline36``hanning``hamming``hermite``kaiser``quadric``catrom``gaussian``bessel``mitchell``sinc``lanczos``blackman
Default Value: near
The scaling algorithm used to making different resolution versions of this raster layer. Bilinear is a good compromise between speed and accuracy, while lanczos gives the highest quality.
raster-mesh-size unsigned
Default Value: 16 (Reprojection mesh will be 1/16 of the resolution of the source image)
A reduced resolution mesh is used for raster reprojection, and the total image size is divided by the mesh-size to determine the quality of that mesh. Values for mesh-size larger than the default will result in faster reprojection but might lead to distortion.
raster-comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current symbolizer on top of other symbolizer)
Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.
point
point-file uri
Default Value: none
Image file to represent a point
point-allow-overlap boolean
Default Value: false (Do not allow points to overlap with each other - overlapping markers will not be shown.)
Control whether overlapping points are shown or hidden.
point-ignore-placement boolean
Default Value: false (do not store the bbox of this geometry in the collision detector cache)
value to control whether the placement of the feature will prevent the placement of other features
point-opacity float
Default Value: 1 (Fully opaque)
A value from 0 to 1 to control the opacity of the point
point-placement keyword
centroid``interior
Default Value: centroid
How this point should be placed. Centroid calculates the geometric center of a polygon, which can be outside of it, while interior always places inside of a polygon.
point-transform functions
Default Value: (No transformation)
SVG transformation definition
point-comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current symbolizer on top of other symbolizer)
Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.
text
text-name expression
Default Value:
Value to use for a text label. Data columns are specified using brackets like [column_name]
text-face-name string
Default Value: undefined
Font name and style to render a label in
text-size float
Default Value: 10
Text size in pixels
text-ratio unsigned
Default Value: 0
Define the amount of text (of the total) present on successive lines when wrapping occurs
text-wrap-width unsigned
Default Value: 0
Length of a chunk of text in characters before wrapping text
text-wrap-before boolean
Default Value: false
Wrap text before wrap-width is reached. If false, wrapped lines will be a bit longer than wrap-width.
text-wrap-character string
Default Value:
Use this character instead of a space to wrap long text.
text-spacing unsigned
Default Value: undefined
Distance between repeated text labels on a line (aka. label-spacing)
text-character-spacing float
Default Value: 0
Horizontal spacing adjustment between characters in pixels
text-line-spacing unsigned
Default Value: 0
Vertical spacing adjustment between lines in pixels
text-label-position-tolerance unsigned
Default Value: 0
Allows the label to be displaced from its ideal position by a number of pixels (only works with placement:line)
text-max-char-angle-delta float
Default Value: 22.5
The maximum angle change, in degrees, allowed between adjacent characters in a label. This value internally is converted to radians to the default is 22.5*math.pi/180.0. The higher the value the fewer labels will be placed around around sharp corners.
text-fill color
Default Value: #000000
Specifies the color for the text
text-opacity float
Default Value: 1 (Fully opaque)
A number from 0 to 1 specifying the opacity for the text
text-halo-fill color
Default Value: #FFFFFF (white)
Specifies the color of the halo around the text.
text-halo-radius float
Default Value: 0 (no halo)
Specify the radius of the halo in pixels
text-dx float
Default Value: 0
Displace text by fixed amount, in pixels, +/- along the X axis. A positive value will shift the text right
text-dy float
Default Value: 0
Displace text by fixed amount, in pixels, +/- along the Y axis. A positive value will shift the text down
text-vertical-alignment keyword
top``middle``bottom``auto
Default Value: auto (Default affected by value of dy; "bottom" for dy>0, "top" for dy<0.)
Position of label relative to point position.
text-avoid-edges boolean
Default Value: false
Tell positioning algorithm to avoid labeling near intersection edges.
text-min-distance float
Default Value: undefined
Minimum permitted distance to the next text symbolizer.
text-min-padding float
Default Value: undefined
Determines the minimum amount of padding that a text symbolizer gets relative to other text
text-min-path-length float
Default Value: 0 (place labels on all paths)
Place labels only on paths longer than this value.
text-allow-overlap boolean
Default Value: false (Do not allow text to overlap with other text - overlapping markers will not be shown.)
Control whether overlapping text is shown or hidden.
text-orientation expression
Default Value: undefined
Rotate the text.
text-placement keyword
point``line``vertex``interior
Default Value: point
Control the style of placement of a point versus the geometry it is attached to.
text-placement-type keyword
dummy``simple
Default Value: dummy
Re-position and/or re-size text to avoid overlaps. "simple" for basic algorithm (using text-placements string,) "dummy" to turn this feature off.
text-placements string
Default Value:
If "placement-type" is set to "simple", use this "POSITIONS,[SIZES]" string. An example is text-placements: "E,NE,SE,W,NW,SW";
text-transform keyword
none``uppercase``lowercase``capitalize
Default Value: none
Transform the case of the characters
text-horizontal-alignment keyword
left``middle``right``auto
Default Value: auto
The text's horizontal alignment from its centerpoint
text-align keyword
left``right``center``auto
Default Value: auto
(Auto alignment means that text will be centered by default except when using the placement-type
parameter - in that case either right or left justification will be used automatically depending on where the text could be fit given the text-placements
directives)
Define how text is justified
text-clip boolean
Default Value: true (geometry will be clipped to map bounds before rendering)
geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts.
text-comp-op keyword
clear``src``dst``src-over``dst-over``src-in``dst-in``src-out``dst-out``src-atop``dst-atop``xor``plus``minus``multiply``screen``overlay``darken``lighten``color-dodge``color-burn``hard-light``soft-light``difference``exclusion``contrast``invert``invert-rgb``grain-merge``grain-extract``hue``saturation``color``value
Default Value: src-over (add the current symbolizer on top of other symbolizer)
Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.
building
building-fill color
Default Value: #FFFFFF
The color of the buildings walls.
building-fill-opacity float
Default Value: 1
The opacity of the building as a whole, including all walls.
building-height expression
Default Value: 0
The height of the building in pixels.
Values
Below is a list of values and an explanation of any expression that can be applied to properties in CartCSS.
Color
CartoCSS accepts a variety of syntaxes for colors - HTML-style hex values, rgb, rgba, hsl, and hsla. It also supports the predefined HTML colors names, like yellow
and blue
.
#line {
line-color: #ff0;
line-color: #ffff00;
line-color: rgb(255, 255, 0);
line-color: rgba(255, 255, 0, 1);
line-color: hsl(100, 50%, 50%);
line-color: hsla(100, 50%, 50%, 1);
line-color: yellow;
}
Especially of note is the support for hsl, which can be easier to reason about than rgb(). Carto also includes several color functions borrowed from less:
// lighten and darken colors
lighten(#ace, 10%);
darken(#ace, 10%);
// saturate and desaturate
saturate(#550000, 10%);
desaturate(#00ff00, 10%);
// increase or decrease the opacity of a color
fadein(#fafafa, 10%);
fadeout(#fefefe, 14%);
// spin rotates a color around the color wheel by degrees
spin(#ff00ff, 10);
// mix generates a color in between two other colors.
mix(#fff, #000, 50%);
These functions all take arguments which can be color variables, literal colors, or the results of other functions operating on colors.
Float
Float is a fancy way of saying 'number'. In CartoCSS, you specify just a number - unlike CSS, there are no units, but everything is specified in pixels.
#line {
line-width: 2;
}
It's also possible to do simple math with number values:
#line {
line-width: 4 / 2; // division
line-width: 4 + 2; // addition
line-width: 4 - 2; // subtraction
line-width: 4 * 2; // multiplication
line-width: 4 % 2; // modulus
}
URI
URI is a fancy way of saying URL. When an argument is a URI, you use the same kind of url('place.png')
notation that you would with HTML. Quotes around the URL aren't required, but are highly recommended. URIs can be paths to places on your computer, or on the internet.
#markers {
marker-file: url('marker.png');
}
String
A string is basically just text. In the case of CartoCSS, you're going to put it in quotes. Strings can be anything, though pay attention to the cases of text-name
and shield-name
- they actually will refer to features, which you refer to by putting them in brackets, as seen in the example below.
#labels {
text-name: "[MY_FIELD]";
}
Boolean
Boolean means yes or no, so it accepts the values true
or false
.
#markers {
marker-allow-overlap:true;
}
Expressions
Expressions are statements that can include fields, numbers, and other types in a really flexible way. You have run into expressions before, in the realm of 'fields', where you'd specify "[FIELD]"
, but expressions allow you to drop the quotes and also do quick addition, division, multiplication, and concatenation from within Carto syntax.
#buildings {
building-height: [HEIGHT_FIELD] * 10;
}
Numbers
Numbers are comma-separated lists of one or more number in a specific order. They're used in line dash arrays, in which the numbers specify intervals of line, break, and line again.
#disputedboundary {
line-dasharray: 1, 4, 2;
}
Percentages
In Carto, the percentage symbol, %
universally means value/100
. It's meant to be used with ratio-related properties, like opacity rules.
You should not use percentages as widths, heights, or other properties - unlike CSS, percentages are not relative to cascaded classes or page size, they're, as stated, simply the value divided by one hundred.
#world {
// this syntax
polygon-opacity: 50%;
// is equivalent to
polygon-opacity: 0.5;
}
Functions
Functions are comma-separated lists of one or more functions. For instance, transforms use the functions
type to allow for transforms within Carto, which are optionally chainable.
#point {
point-transform: scale(2, 2);
}