node-mapnik icon indicating copy to clipboard operation
node-mapnik copied to clipboard

bindings for manipulating styles?

Open RandomEtc opened this issue 12 years ago • 4 comments
trafficstars

Are there any plans to implement bindings for manipulating styles, symbolizers and filters? I'd love to take output from TileMill and e.g. tweak a filter on a layer and save out a sequence of animations.

Just wondering if this is a "bad idea, do it another way" thing or a "great! we just didn't get to it yet" thing. Assuming the latter I can help.

RandomEtc avatar Feb 14 '13 02:02 RandomEtc

I've not gotten around to this mainly since TileMill hasn't needed it yet. We've been enjoying (getting away with) the simplicity of dealing with styles as json objects (carto's internal representation) and then just handing off to mapnik in one big chunk of XML.

Do you have ideas on how you'd ideally like access to the underlying styles?

springmeyer avatar Feb 14 '13 03:02 springmeyer

Not yet!

Could/should I be generating carto styles and passing those to a mapnik.Map somehow?

RandomEtc avatar Feb 14 '13 03:02 RandomEtc

I could also generate the XML I guess?

RandomEtc avatar Feb 14 '13 03:02 RandomEtc

mapnik.Map.load/loadSync/fromString/fromStringSync all expect XML. It's not obvious, but you can call them multiple times and styles/layers will accumulate, while any map level properties will get overridden by the last map loaded. So a quick cheat could be to export the XML from TileMill, remove the few styles/layers that you want to change (keeping other constant stuff). Then construct the style bits you want to change on the fly as XML chunks wrapped in <Map> </Map> and load them after loading the main map.

springmeyer avatar Feb 14 '13 03:02 springmeyer