Go to file
2017-04-17 15:48:55 +02:00
bin Drop xml2js and thus mml2json. 2015-11-30 16:14:53 -08:00
build update to mapbox 0.0.11 master 2014-06-11 17:52:06 +02:00
dist Bumped version of underscore. 2016-05-30 16:06:04 +02:00
docs Re-generate 2014-09-25 12:24:01 -04:00
docs-generator Update less link 2015-11-30 13:56:53 -08:00
lib/carto Make the error flag more strict 2017-04-17 15:48:55 +02:00
man update to mapbox 0.0.11 master 2014-06-11 17:52:06 +02:00
test Merge branch 'master' into reference-errors 2017-02-01 12:25:57 +01:00
.gitignore Ignore idea based configurations 2016-07-20 13:08:41 +02:00
.npmignore Getting ignores right, tagging 0.4.4 2011-11-29 09:50:05 -05:00
.travis.yml Remove coverage run from travis configuration as it is failing 2014-12-05 13:06:53 +01:00
CHANGELOG.md call this branch v0.14.0 2014-09-25 18:17:48 -07:00
DEVELOPING.md update to mapbox 0.0.11 master 2014-06-11 17:52:06 +02:00
LICENSE moved to apache license 2010-03-04 14:46:41 -05:00
Makefile adds Makefile to produce uncompressed and minified dists 2015-01-19 14:29:11 +01:00
package.json Bumped version of underscore. 2016-05-30 16:06:04 +02:00
README.md Use build status from cartodb repo 2016-04-27 15:37:35 +02:00

CartoCSS

Build Status

Is as stylesheet renderer for javascript, It's an evolution of the Mapnik renderer from Mapbox. Please, see original Mapbox repo for more information and credits

Quick Start

// 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 })
    console.log(layerShader['marker-width']) // 1
    console.log(layerShader['marker-fill']) // #FF0000
}

API

RendererJS

render(cartocss)

CartoCSS

compiled cartocss object

getLayers

return the layers, an array of CartoCSS.Layer object

getDefault

return the default layer (CartoCSS.Layer), usually the Map layer

findLayer(where)

find a layer using where object.

shader.findLayer({ name: 'test' })

CartoCSS.Layer

getStyle(props, context)

return the evaluated style: - 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

Reference Documentation