Export map in png/jpeg format

74 views
Skip to first unread message
Assigned to lorenzo...@geosolutionsgroup.com by me

Klaiver Costa

unread,
Aug 2, 2021, 6:22:37 PM8/2/21
to mapstore-developers
Hey guys, I have a problem, I would like to customize the MapExport plugin to export the map in image format (PNG/JPEG) but I'm not able to do that, do you have any idea how I can solve this? My attempt to solve this was by including the png and jpeg formats as the default export formats in the MapExport.jsx file and the following line in mapexport.js in the PersistMap constant "png: (state) => Rx.Observable.of([JSON .stringify(saveMap(state)), 'map.png', 'image/png']), " an image download is done but it comes empty, since thanks for your help.

Lorenzo Natali

unread,
Aug 25, 2021, 6:02:26 AM8/25/21
to mapstore-developers
Hi,
to export in png  you should produce the PNG itself. Using JSON.stringify only converts the map object (that is the configuration object of the map) in a string. 
Implement it is not trivial (or at least, not in all the cases. you may have some encounter some cross origin issues). If you are on your custom project, using openlayers and you don't have cross origin issues, you can try to get the image from canvas of the map (it will get a sort of a screenshot of the current map). 
There is an old "snapshot" plugin that provides this functionality, but is not maintained by us for a long time. 
Reply all
Reply to author
Forward
0 new messages