Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export map in openLayers

Tags:

openlayers

I'm trying to export an 2.13.1 openLayers map into a canvas, but the methods to do so seem to have vanished.

The old methods would work like:

var exportMapControl = new OpenLayers.Control.ExportMap();
map.addControl(exportMapControl);

var canvas = OpenLayers.Util.getElement("exportedImage");
exportMapControl.trigger(canvas);   

Does anyone know how this works for 2.13.1?

Thanks in advance,

like image 724
Joao Avatar asked Mar 17 '26 22:03

Joao


1 Answers

The ExportMap control was actually never a part of the official OpenLayers distribution (you can confirm that by checking out the project on github and browsing history). The example above comes from a sandbox that seems to be a user-submitted enhancement proposal (demo here).

The source of this custom control is available HERE. Simply import it after loading OL 2.13.1 and it should be available as OpenLayers.Control.ExportMap again. Unless some other part of OL it depends on changed in the meantime it should work as it used to.

like image 70
kryger Avatar answered Mar 19 '26 13:03

kryger