Search code examples
svgopenstreetmapserver-sideopenlayers-3

Save Openstreetmap, Openlayers output as .png or .svg, server-side


I'm currently building a web application with Openlayers that draws routes en points of interest on a map. This map needs to be saved to a file on the server (.png of .svg), so it can be embedded in a .pdf file. The route and POI information is available as KML file. What is the easiest way to do this?


Solution

  • You have several options:

    • Directly export your OpenLayers map to a PNG or even a PDF on the client-side (see these two examples: png export and pdf export).
    • Use wkhtmltopdf to export a HTML page containing an OpenLayers map to a PDF (on the server-side).
    • Use MapFish Print 3 which is a print server to generate PDF reports containing maps. You would create a report template and configuration and then send a print request containing the geo-data that you want to print (e.g. tile layers or GeoJSON data).