carto 0 travis-ci npm

hyperspeed CSS-like map styling

3 years after

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

Related Repositories

carto-css-map-styling

carto-css-map-styling

Notes, sketches, and frameworks inspired by fall 2011 map styling workshop held ...

Carto-sublime

Carto-sublime

Carto syntax highlighter and autocompletion for Sublime Text editor ...

carto-generator

carto-generator

C++ Parser for the Carto stylesheet language ...

openstreetmap-carto-german

openstreetmap-carto-german

"German" variant of openstreetmap-carto map style ...

mq-carto-style

mq-carto-style

MapQuest style in Carto. Alpha style; not ready for production use yet! ...


Top Contributors

tmcw kkaefer springmeyer yhahn javisantana rochoa fdansv samanpwbb stefanklug jamesfoster yohanboniface nobuti felixge kapouer gravitystorm tomhughes danzel ajashton sk1p dbergey dboze indutny onecrayon iwillig kekscom miccolis pnorman mojodna scw sjl

Releases

-   v0.9.5 zip tar
-   v0.9.4 zip tar
-   v0.9.3 zip tar
-   v0.9.2 zip tar
-   v0.9.1 zip tar
-   v0.9.0 zip tar
-   v0.8.1 zip tar
-   v0.8.0 zip tar
-   v0.7.1 zip tar
-   v0.7.0 zip tar
-   v0.6.0 zip tar
-   v0.5.0 zip tar
-   v0.4.10 zip tar
-   v0.4.9 zip tar
-   v0.4.8 zip tar
-   v0.4.7 zip tar
-   v0.4.6 zip tar
-   v0.4.5 zip tar
-   v0.4.4 zip tar
-   v0.4.3 zip tar
-   v0.4.2 zip tar
-   v0.4.1 zip tar
-   v0.4.0 zip tar
-   v0.3.0 zip tar
-   v0.2.4 zip tar
-   v0.2.3 zip tar
-   v0.2.2 zip tar
-   v0.2.1 zip tar
-   v0.2.0 zip tar
-   v0.1.15 zip tar