Open scaddenp opened 5 years ago
Hi @scaddenp
Yeah CORS is the thing plaguing most of the issues in this repo.
In terms of font's probably the simplest solution is to download the fonts and host them as static assets as part of the site.
Cheers Rowan
I don't see how manual download would help. The font download is managed entirely by the google map api and terms of use do not allow local copies of the api. The bottom answer on https://stackoverflow.com/questions/13050215/google-maps-api-v3-printing-maps looks to be compatiable with method used (and the html2canvas.js looks to include CORS support so might help other issues).
From: Rowan Winsemius notifications@github.com Sent: Friday, October 5, 2018 7:36:05 AM To: rowanwins/leaflet-easyPrint Cc: Phil Scadden; Mention Subject: Re: [rowanwins/leaflet-easyPrint] Troubles with GoogleMutant (#89)
Hi @scaddenphttps://github.com/scaddenp
Yeah CORS is the thing plaguing most of the issues in this repo.
In terms of font's probably the simplest solution is to download the fonts and host them as static assets as part of the site.
Cheers Rowan
- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/rowanwins/leaflet-easyPrint/issues/89#issuecomment-427273660, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AANvERrK8uJnIpW69015kGF6Er2e_Eg0ks5uhwvlgaJpZM4XJaPa.
Notice: This email and any attachments are confidential and may not be used, published or redistributed without the prior written consent of the Institute of Geological and Nuclear Sciences Limited (GNS Science). If received in error please destroy and immediately notify GNS Science. Do not copy or disclose the contents.
I have the same problem, i tried download the fonts, but nothing happens, tried to force the stylesheet local to substitute the font from google, but without success. :(
I abandoned hope and went with leaflet.browser.print instead. Suboptimal but works.
Im getting this error on leaflet.browser.print too how you manage it?
well browser.print is effectively pretty much Ctrl-P on a your leaflet tab. Have your registered the layer. Are you sure you havent got residual code there? I have it activated from external button with: map.printControl.print(L.control.browserPrint.mode.auto());
And I register it with L.control.browserPrint({ title:'Print map', documentTitle:'' }).addTo(mc.map); L.Control.BrowserPrint.Utils.registerLayer( L.GridLayer.GoogleMutant, "L.GridLayer.GoogleMutant", function (layer,utils) { return L.gridLayer.googleMutant(layer.options); } ); L.Control.BrowserPrint.Utils.registerLayer( L.esri.ImageMapLayer, "L.esri.ImageMapLayer", function(layer, utils) { return L.esri.ImageMapLayer(layer.options); } ); I remember updating GoogleMutant around the time I worked with this but I have definitely not modified code for browserPrint.
I dont see any sign of you registering the googleMutant layer. it wont work unless you do (it only pre-registers a little no. of layer types). See the browserprint docs. I dont think is the appropriate place to browserprint.
i was trying like that
<script type="module">
var map;
//Mapa
var googleStreets = L.gridLayer.googleMutant({
maxZoom: 20,
type: 'roadmap',
});
map = L.map('mapid',{zoomControl : false}).setView(['-15.792253570362446',
'-59.63378906250001'], 3).addLayer(googleStreets);
//Escala do mapa
L.control.scale({position: 'bottomright'}).addTo(map);
L.control.browserPrint({
documentTitle: "printImage",
printModes: [
L.control.browserPrint.mode.auto("Download PNG")
]
}).addTo(map);
//pq nao aparece
window.map = map;
</script>
<script>
window.print = function () {
return domtoimage
.toPng(document.querySelector(".grid-print-container"))
.then(function (dataUrl) {
var link = document.createElement('a');
link.download = map.printControl.options.documentTitle || "exportedMap" + '.png';
link.href = dataUrl;
link.click();
});
};
</script>
Ok thank you :D
You must have this line: L.Control.BrowserPrint.Utils.registerLayer( L.GridLayer.GoogleMutant, "L.GridLayer.GoogleMutant", function (layer,utils) { return L.gridLayer.googleMutant(layer.options); } );
From: Brenokx notifications@github.com Sent: Wednesday, 17 June 2020 13:56 To: rowanwins/leaflet-easyPrint leaflet-easyPrint@noreply.github.com Cc: Phil Scadden P.Scadden@gns.cri.nz; Mention mention@noreply.github.com Subject: Re: [rowanwins/leaflet-easyPrint] Troubles with GoogleMutant (#89)
i was trying like that
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/rowanwins/leaflet-easyPrint/issues/89#issuecomment-645100440, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AABW6ELV6CPVPJM5O2PZD6LRXAPCLANCNFSM4FZFUPNA.
Notice: This email and any attachments are confidential and may not be used, published or redistributed without the prior written consent of the Institute of Geological and Nuclear Sciences Limited (GNS Science). If received in error please destroy and immediately notify GNS Science. Do not copy or disclose the contents.
If I am using GoogleMutant to provide googlemaps background, then printing fails, Get: "Error while reading CSS rules from http://fonts.googleapis.com/css?family=Roboto:300,400,500,700 SecurityError: Failed to read the 'cssRules' property from 'CSSStyleSheet': Cannot access rules"
followed by Print operation fails
Ideas? Or is printing from google just impossible.