3
votes

I'm building a mapping application using the Leaflet API http://leafletjs.com/.

I would like to use phantomjs to generate static screenshots of maps.

As an example, attempting to render this page:

http://leafletjs.com/examples/geojson-example.html

using

phantomjs examples/rasterize.js http://leafletjs.com/examples/geojson-example.html test.png

results in an image that's missing the SVG overlay. I have tried this using the prebuilt binaries under Windows 7 and Fedora Core 15. In addition, I compiled it from source under Fedora Core 15. All builds on both platforms yielded the same behavior.

Has anyone had success rendering Leaflet maps to PNG using phantomjs?

thanks.

1
Have you tried incrementing the timeout in the rasterize.js script on line 29 from 200 to something a bit higher?flup
Yea, I thought about timeout issues as well In one test, I actually modified rasterize.js to include the waitFor example and caused it to wait for a flag that I would only set after all vector shapes had been drawn. I verified it with console.log messages. All no no avail. (Good thinking though.)Yermo Lamers

1 Answers

1
votes

I just ran into the same issue and increasing the timeout (at least to 5000) didn't make SVG overlays appear in the PDF.

It's probably this issue: https://github.com/ariya/phantomjs/issues/11171

Switching to Leaflet master branch fixed the problem for me.