0

I'm using the official Carto library to parse CartoCSS:

cartocss = "#views { line-color: #7B00B4; line-width: 1; line-opacity: 0.7; line-dasharray: 4,2; }";

shader = new carto.RendererJS().render(cartocss),
style = shader.layers[0].getStyle({ property: 1 }, { zoom: 10 });

console.log({shader, style});

Here's a fiddle: http://jsfiddle.net/mz5xj67p/2/

The issue is the the value of dasharray. Although the style object has the correct value (4, 2) but when I try to retrieve it using getStyle method it just returns 4.

enter image description here

What am i missing?

eozzy
  • 66,048
  • 104
  • 272
  • 428
  • I am not able to replicate your issue, [this is a working example](https://bl.ocks.org/ramiroaznar/dbccbbb35d2c0fcc62a4b2894f565263). What do you need those `render` methods? – ramiroaznar Jul 19 '18 at 08:42
  • @ramiroaznar Cause I'm using Mapbox GL and not leaflet. – eozzy Jul 19 '18 at 16:49
  • If you are using Mapbox GL, you should use [CARTO VL](https://carto.com/developers/carto-vl/) instead of CARTO.js. – ramiroaznar Jul 20 '18 at 07:46
  • @ramiroaznar Oh! So all I have from the client js a a link to their viz.json and I'm able to extract tje SQL and CartoCSS from it to generate the styles. Can I do the same with CartoVL? From the examples, it looks like I still need to have the CartoCSS to create the styling object? Could you please provide an example? Thanks!! – eozzy Jul 20 '18 at 14:55

0 Answers0