Geographic Information Systems Asked on January 30, 2021
Followig the query here:
QGIS2web Export open layers map as PDF, PNG or JPEG
I would like to be able to export my map in the PNG format.
Unfortunately the code from here:
https://www.kreidefossilien.de/webgis/dokumentation/beispiele/export-als-png-hoehere-aufloesung
doesn’t work
I embedded this code into the file, which has been uploaded here:
https://jsfiddle.net/x6wgz12v/
The console throws:
Uncaught ReferenceError: $ is not defined
where an answer is here:
https://stackoverflow.com/questions/2925130/jquery-equivalent-of-getting-the-context-of-a-canvas
but it doesn’t match my code
var canvas = $('canvas').get(0);
The PNG export button doesn’t work at all
I’ve changed the var canvas to
var canvas = document.getElementById(‘canvas’);
https://competa.com/html5-canvas-the-basics
and now the console shows another problem:
qgis2web.js:871 Uncaught TypeError: Cannot read property ‘width’ of null
indicating the canvas size function:
function setDPI(canvas, dpi) {
var scaleFactor = dpi / 96;
canvas.width = Math.ceil(canvas.width * scaleFactor);
canvas.height = Math.ceil(canvas.height * scaleFactor);
var ctx=canvas.getContext("2d");
ctx.scale(scaleFactor, scaleFactor);
}
where an answer is here:
https://stackoverflow.com/questions/16509020/uncaught-typeerror-cannot-read-property-width-of-null
but doesn’t match my situation.
The final question is how to get the Openlayers maps generated in QGIS2web plugin downloadable as a PNG format?
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP