You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
carto/README.md

84 lines
1.7 KiB

# CartoCSS
[![Build Status](https://travis-ci.org/CartoDB/carto.png?branch=master)](https://travis-ci.org/CartoDB/carto)
10 years ago
Is as stylesheet renderer for javascript, It's an evolution of the Mapnik renderer from Mapbox.
Please, see original [Mapbox repo](http://github.com/mapbox/carto) for more information and credits
## Quick Start
```javascript
// shader is a CartoCSS object
var cartocss = [
'#layer {',
' marker-width: [property]',
' marker-fill: red',
'}'
].join('')
var shader = new carto.RendererJS().render(cartocss);
var layers = shader.getLayers()
for (var i = 0; i < layers.length; ++i) {
var layer = layers[i];
console.log("layer name: ", layer.fullName())
console.log("- frames: ", layer.frames())
console.log("- attachment: ", layer.attachment())
var layerShader = layer.getStyle({ property: 1 }, { zoom: 10 })
10 years ago
console.log(layerShader['marker-width']) // 1
console.log(layerShader['marker-fill']) // #FF0000
}
10 years ago
```
10 years ago
# API
10 years ago
## RendererJS
13 years ago
10 years ago
### render(cartocss)
13 years ago
10 years ago
## CartoCSS
13 years ago
10 years ago
compiled cartocss object
13 years ago
10 years ago
### getLayers
13 years ago
10 years ago
return the layers, an array of ``CartoCSS.Layer`` object
10 years ago
### getDefault
13 years ago
10 years ago
return the default layer (``CartoCSS.Layer``), usually the Map layer
13 years ago
10 years ago
### findLayer(where)
13 years ago
10 years ago
find a layer using where object.
10 years ago
```
shader.findLayer({ name: 'test' })
```
10 years ago
## CartoCSS.Layer
13 years ago
### getStyle(props, context)
return the evaluated style:
10 years ago
- props: object containing properties needed to render the style. If the cartocss style uses
some variables they should be passed in this object
- context: rendering context variables like ``zoom`` or animation ``frame``
10 years ago
## Reference Documentation
10 years ago
* [mapbox.com/carto](http://mapbox.com/carto/)