Comments (11)
Please provide your code, to check what is wrong.
But it should be as simple as:
L.Control.BrowserPrint.Utils.registerLayer( L.GridLayer.GoogleMutant, "L.GridLayer.GoogleMutant", function(layer, utils) { return L.gridLayer.googleMutant(layer.options); } );
from leaflet.browser.print.
My code is:
mc.print = L.control.browserPrint(
{title:mapName,
documentTitle:mapName
}
).addTo(map);
L.Control.BrowserPrint.Utils.registerLayer(
L.gridLayer.googleMutant,
"L.GridLayer.GoogleMutant",
function (layer,utils) {
return L.gridLayer.googleMutant(layer.options);
}
);
which looks right. No errors coming up in console but no google maps either.
from leaflet.browser.print.
Can you provide full standalone example to debug it?
from leaflet.browser.print.
Yes, that seems possible. I will see what I can do.
from leaflet.browser.print.
okay, here a minimal test html. Obviously, the location of leaflet.browser.print.min.js needs to change and you will need your own google api key. (my key is locked to our servers).
<title>Google print test</title> <script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key=[Insert your key]&libraries=places"></script> <script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==" crossorigin=""></script> <script src='https://unpkg.com/leaflet.gridlayer.googlemutant@latest/Leaflet.GoogleMutant.js'></script> <script src="leaflet.browser.print.min.js"></script> <style> #mapid {height:560px} </style> <script>var mymap = L.map('mapid').setView([51.505, -0.09], 13);
L.gridLayer.googleMutant({type:'roadmap'}).addTo(mymap);
L.control.browserPrint({
title:'Google print test',
documentTitle:'printTest'
}).addTo(mymap);
L.Control.BrowserPrint.Utils.registerLayer(
L.gridLayer.googleMutant,
"L.GridLayer.GoogleMutant",
function (layer,utils) {
return L.gridLayer.googleMutant(layer.options);
}
);
from leaflet.browser.print.
I found one problem with empty object layer initialization, it's fixed. Hope it will help.
If not, then sorry, I have no intention to activate billable google map api. But you can help me to fix this problem:
- create separate api key, limited to 'localhost' and a couple of hundreds request per day.
- send this api key to my private email in debug purpose.
- when problem is fixed - you will remore key from your organization credential manager.
Should be no problem for you.
Please let me know if fix works for you and/or if you are willing to provide an api key to debug this problem locally.
from leaflet.browser.print.
Ok, tried it but no joy. You could try this instead:
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?v=3.6&sensor=false"></script>
(It is the old style). This loads tiles with watermarks all over them into leaflet plus an alert. However, it might isolate the issue. I dont have access to my organisations credential manager for the api.
from leaflet.browser.print.
Okay, it was so stupid from my side :)
In register layer you have to use instance constructor and not a function.
Here is proper registration (as I wrote in first answer):
L.Control.BrowserPrint.Utils.registerLayer( L.GridLayer.GoogleMutant, "L.GridLayer.GoogleMutant", function (layer,utils) { return L.gridLayer.googleMutant(layer.options); } );
And you have used function as instance mapper.
Regards,
Igor
from leaflet.browser.print.
Hi, i'm having this problem when I'm using with domtoimage, have some idea?
here the example:
https://embed.plnkr.co/plunk/c60SyG3FA8HPAqUR
from leaflet.browser.print.
I find some workaround, adding encodeURI(), on dom-to-image directly replacing d.src=a with d.src=encodeURI(a)
from leaflet.browser.print.
or
window.print = function () {
let node = document.querySelector(".grid-print-container");
return domtoimage
.toPng(node, { filter: node => { return node.src = encodeURI(node.src); }})
.then(function (dataUrl) {
var link = document.createElement('a');
link.download = map.printControl.options.documentTitle || "exportedMap" + '.png';
link.href = dataUrl;
link.click();
});
};
from leaflet.browser.print.
Related Issues (20)
- How to add Custom Logo image and custom attribute text while printing HOT 2
- L.AwesomeMarkers issue HOT 9
- Printing polygons with custom fill patterns HOT 3
- Print dialogue does not open when fully zoomed in HOT 4
- Error in documentation
- resize button heigth HOT 1
- work with React + TypeScript HOT 1
- Add dynamic contents(add new page if contents are huge), circle not printing. HOT 1
- ImageOverlay dont work
- JS error when manualMode is true HOT 1
- Printing two Leaflet instances (One only visible in printing) HOT 1
- Text of Leaflet Geoman Textlayer is not displayed HOT 2
- Offset with leaflet map position HOT 1
- Legend disappear when print ends HOT 1
- When defining custom printFunction, document.querySelector('.grid-print-container') does not include the Leaflet layers, only the container HOT 1
- package.json missing a main key HOT 2
- [Geotiff] Geotiff file on print HOT 5
- Fitting an Image as Watermark on PrintPage HOT 2
- Map breaks into two pages in smaller screens HOT 6
- Esri Vector Tile Printing? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet.browser.print.