1

I am trying to follow this example to export map to canvas:

http://dev.openlayers.org/sandbox/camptocamp/canvas/openlayers/examples/exportMapCanvas.html

But, it is failing at this line (ExportMap.js): this.canvasContext.drawImage(layerCanvas, 0, 0, this.canvas.width, this.canvas.height);

None of the layers seem to have a canvas property (layer.canvas). Does anyone know how to put the canvas property on the layers?

Update #1 I noticed that the canvas property is always undefined:

if (layer.canvas !== null)
        {
            this.drawLayer(layer.canvas);    
        }

Also the layer.useCanvas is also undefined even though the layer has the value set to:

useCanvas: OpenLayers.Layer.Grid.ONECANVASPERLAYER

CODE:

// Setup tiled base layer
            baseLayer = new OpenLayers.Layer.WMS(
                "sf:layer01",
                "http://server01:8080/geoserver/sf/wms",
                {
                    "LAYERS": 'sf:layer01',
                    "STYLES": '',
                    TRANSPARENT: 'true',
                    format: 'image/png'
                },
                {
                    visibility: true,
                    buffer: 0,
                    displayOutsideMaxExtent: true,
                    isBaseLayer: true,
                    yx: { 'EPSG:4326': false },
                    useCanvas: OpenLayers.Layer.Grid.ONECANVASPERLAYER,
                    renderers: ["Canvas"]
                }
            );
  • which browser / version are you using? – tomfumb Apr 30 '15 at 16:30
  • I tried IE 9, Chrome Version 27.0.1500.0 and FireFox 37.0.2. Also I noticed the canvas property is always undefined: – Robert Smith Apr 30 '15 at 17:54
  • I tried IE 9, Chrome Version 27.0.1500.0 and FireFox 37.0.2. Also I noticed the useCanvas property is always undefined. – Robert Smith Apr 30 '15 at 18:00
2

I found out why its not working: ExportMap was never officially released in OpenLayers after camptocamp made the ExportMap changes.

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.