Go to file
2014-06-06 10:04:19 +02:00
bin Merge 2012-06-28 13:58:04 -04:00
browser added rectangle as marker-type 2014-06-06 10:04:11 +02:00
build deleted compiler.jar 2012-07-18 17:23:52 +02:00
dist dist file 2014-02-25 09:53:20 +01:00
lib/carto backport from master to support unsigned types 2014-01-23 17:46:13 +01:00
test fixed renderer 2013-08-28 12:12:06 +02:00
.gitignore added frame offset 2013-08-28 11:52:18 +02:00
.npmignore Getting ignores right, tagging 0.4.4 2011-11-29 09:50:05 -05:00
.travis.yml Add Travis-CI chunk 2012-06-18 17:05:54 -04:00
CHANGELOG.md added rectangle as marker-type 2014-06-06 10:04:11 +02:00
LICENSE moved to apache license 2010-03-04 14:46:41 -05:00
makefile dist 2013-07-31 12:43:09 +02:00
Makefile improved makefile 2013-07-31 12:32:55 +02:00
package.json browser version working 2013-06-10 13:26:19 +02:00
README.md updated doc 2014-06-06 10:04:19 +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('canvas-2d', { 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(target, props, context)

return the evaluated style - target: 'canvas-2d' - 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