1

I try to export map in openlayers 3 with this example (Export Map Example) and it works. But when I export the map I get this picture :

enter image description here

However I want to get this picture with highlights and popups the way I see them in the browser :

enter image description here

Is there any way to do this?

1

You can't using only OpenLayers 3 (I would be happy to learn how if not).

The image you get in the demo is the one you get by exporting the map Canvas element in the DOM. Your pop-up is part of the DOM so outside the Canvas hence the exported image. Providing HTML element in the Canvas does not seem possible (https://stackoverflow.com/questions/12652769/rendering-html-elements-to-canvas)

The only way IMO to get everything is to use a server side script and rely on a headless browser like Phantom JS to take a screenshot (see a demo).

The issue you will get in all case is that you will have to change map width and height because your screen resolution is around 96dpi whereas for print, it's recommended to get 300dpi or more.

You can maybe look also on the MapFish Print component but I didn't try it since some time: I don't know nowadays it exact features.

An alternative at functional level could be to change your way of doing: just retrieve the image with the selected feature and provide this image plus the content in a separate box. It would be more like a report than a screenshot export.

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.