I am able to export TileMill project as mbtiles and rendering tiles on map using leaflet which is working fine. But if I export the project as SVG or PNG image the CartoCSS which I have written is not applying for the image. So how to export tilemill project as SVG image with CartoCSS applied to it.

This is the image in tileMilltile mill project

This is the exported png image.

Project exported as png image

  • would be helpful to see a photo of how the map renders in TileMill and how it renders exported as .svg and .png. Errors with export to .png is particularly surprising, as .mbtiles is essentially just a bunch of .png files. Haven't run into problems myself with print exports. – James Conkling Dec 14 '14 at 22:05
  • @JamesConkling Like u said.. Its surprising. I have updated problem with images. In mbtiles I have png images with CartoCss applied – shrinidhi kulkarni Dec 15 '14 at 6:52

At first glance, it appears that the only styles missing are the styles that rely on a zoom level. When exported in MBtiles, your "map" is seen in a map context where you have zoom levels, and as such, your styles are rightfully applied. However, when exporting a static map, by default there is no zoom level applied during rendering.

I've snooped a bit and found this issue on TileMill repository, which would correspond to your problem: https://github.com/mapbox/tilemill/issues/1819

Unfortunately, the fix (under the form of a static_zoom parameter in the command-line) doesn't seem to be in the last "official" release available of TileMill, but if you install it from the source on GitHub, it should be OK; something along the lines of ./index.js export help should tell you about this static_zoom parameter.

Of course, another solution would be to comment out the conditions the zoom, to always apply the styles you want, and export afterwards.

| improve this answer | |
  • Your last solution "comment out the conditions the zoom" works. About static_zoom do u mean it is possible to export as svg` with conditional CartoCSS at different zoom levels?? – shrinidhi kulkarni Dec 15 '14 at 12:37
  • I didn't test it, but it seems it is the case; according to the help, static_zoom "explicity sets the zoom level of the static map". Unfortunately since TileMill hasn't seen an official release in some time, you'd have to get a version from the last version of the code ( github.com/mapbox/tilemill#installation ) – benrict Dec 15 '14 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.