Skip to content
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

Not working with https://github.com/Igor-Vladyka/leaflet.browser.print #278

Open
ramblerswebs opened this issue Nov 27, 2018 · 1 comment
Labels

Comments

@ramblerswebs
Copy link

I have version 3.0.3 working fine but I am trying to get a map print option working.
I have added https://github.com/Igor-Vladyka/leaflet.browser.print as a print option.
This is working fine with OSM and the topo version of the maps.
I am using Bing maps, aerial and OS options.
They work fine until I try and print them. It appears to fail in leaflet.js where leaflet is trying to replace subdomain and quadkey in the map tile url
I am using leaflet 1.3.1 and the errors appear in line 178 in the function template(str, data) where the variable value is undefined.

I am not sure how to proceed or what diagnostic information I can provide.

@ramblerswebs
Copy link
Author

I have made progress on this and got it working but with a fix.
Firstly I was not registering BingLayer with the print software, my fault..
Once I had done that I found that the BingLayer did not know what url to use to access the tiles. I hence ended up with this additional code.

if (ramblersMap.options.bing) {
L.Control.BrowserPrint.Utils.registerLayer(
L.BingLayer,
"L.BingLayer",
function (layer) {
bing = L.bingLayer(layer.key, layer.options);
bing._url = ramblersMap.currentLayer._url;
return bing;
}
);
}
}
ramblersMap.map.on('baselayerchange', function (e) {
ramblersMap.currentLayer=e.layer;
//alert('Changed to ' + e.name);
});

I had to add the line bing._url = ramblersMap.currentLayer._url; to set the url correctly. When the print software calls this function the BingLayer does not seem to be initialized correctly. I don't know if this is the Print software's fault or BingLayer. The fix above works fine. It is taking the url from the current tilelayer and using that. (Not sure why the Print software sets up another tileLayer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants