-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print Inconsistency - As you turn on more layers, some don't appear in the print out #640
Comments
Works fine for me (Firefox v87.0 64-bit) using the full demo on geomoose.org. Anything special on your client -side? |
Interestingly (for the most part), I've now only managed to replicate it from my work laptop (Windows). The only extension I can see is is Virtru Email Protection, which I wouldn't think would have an impact. For the most part it works fine from my Mac. I was able to replicate it by turning on the OpenStreetMap layer (the OpenStreetMap shows in the print, but the parcels do not), but I was able to turn on the ags railroads/runways (in addition to a bunch of other layers) without issues. |
Some more diagnostics: My office desktop computer (Windows, same browser settings and extensions as my work laptop) works perfectly. I can turn on all the ags layers and print them without issue, I can even turn on the OpenStreetMap layer and print it, which wasn't working on my Mac. |
I also have similar issues from my iPhone. |
I don't think that's related. I think that's just because the ags raster is above the rail and runway layers in the map-source (on a separate note it may be better to move the vector layers above the raster). The issue I was having was that layers wouldn't appear in the print out even though they were showing on the map. |
Ah right. Yes, that needs to be changed. |
This probably isn't it, but I have to ask: Did you wait long enough? I ask because the genesis of the print preview was we couldn't programmatically detect (reliably) when all the layers had actually rendered to the canvas. The idea was to slow the user down enough (and let them verify) that they were getting what they wanted before they clicked Print to generate the PDF from that canvas. |
I considered that, but that's not the case. |
Also, another simple way of replicating it for me (without turning on a bunch of layers), is just adding a sketch and nothing else. |
I think that the problem is the screen resolution (DPI): I tried to print a map on a Windows laptop too, which has a resolution of 1920*1200 for 15.6" (145DPI) and print doesn't work. If I downgrade the resolution to 1600*900 (117DPI), refresh the tab to start a new GM3 application, printing works |
Thanks for those diagnostics! My Windows laptop was at 1920x1080 (sketch didn't print). I downgraded it to 1600x900 and it worked. |
I found the fix ! With low resolution monitors, I only have 2 canvas : one blank and one with all layers rendered. So instead of return the first not blank canvas, you have to combine them to one as done in the exemple of OL: https://openlayers.org/en/latest/examples/export-map.html. The method getImage() {
// there are many opportunities for the map to
// disappear "out of order" and this makes sure all
// of the DOM elements required still exists.
const p = document.getElementById(this.state.mapId);
if(p) {
const canvas = p.getElementsByTagName('canvas');
if(canvas.length > 0) {
const mapCanvas = document.createElement('canvas');
mapCanvas.width = (this.props.width ? this.props.width : 600);
mapCanvas.height = (this.props.height ? this.props.height : 400);
const mapContext = mapCanvas.getContext('2d');
try {
for (let i = 0, ii = canvas.length; i < ii; i++) {
if (canvas[i].width > 0) {
const opacity = canvas[i].parentNode.style.opacity;
mapContext.globalAlpha = opacity === '' ? 1 : Number(opacity);
const transform = canvas[i].style.transform;
// Get the transform parameters from the style's transform matrix
const matrix = transform
.match(/^matrix\(([^\(]*)\)$/)[1]
.split(',')
.map(Number);
// Apply the transform to the export map context
CanvasRenderingContext2D.prototype.setTransform.apply(
mapContext,
matrix
);
mapContext.drawImage(canvas[i], 0, 0);
}
}
return mapCanvas.toDataURL('image/png');
} catch(error) {
return 'err';
}
}
}
return '';
} |
1. Fixes the canvas selector based on the OpenLayers demo code and tweaks from robinrullo. 2. Refactors and cleans up components for print. 3. Adds a progress bar which is handy for when big images are coming in over the pipe. refs: geomoose#640
1. Fixes the canvas selector based on the OpenLayers demo code and tweaks from robinrullo. 2. Refactors and cleans up components for print. 3. Adds a progress bar which is handy for when big images are coming in over the pipe. refs: geomoose#640
Using the demo as a test case, when I print with just the parcels layer I don't notice any issues.
When I turn on the AGS County Rail and County Runways, some layers fail to show up in the print out.
In this case the parcels appeared for a second in the print preview, and then disappeared.
The text was updated successfully, but these errors were encountered: