[英]Leaflet-Image() and Leaflet.print() not working
I'm trying to access a map webservice online. 我正在尝试在线访问地图网络服务。 I want to export a map as a png ou jpg image.
我想将地图导出为png ou jpg图像。
I managed to display an online map with OSM. 我设法通过OSM显示了在线地图。 I followed instructions here .
我按照这里的指示进行。 The next step is to save or export the map into an image.
下一步是将地图保存或导出到图像中。 I found this and this , and I tried both.
我找到了这个和这个 ,并且我都尝试了。
No need to say, it doesn't work. 无需多说,这是行不通的。 In fact I think the problem comes from me, I don't think I understood correctly how to use these functions.
实际上,我认为问题出在我身上,我认为我没有正确理解如何使用这些功能。
Regarding Leaflet-Image(), I tried the following code : 关于Leaflet-Image(),我尝试了以下代码:
leafletImage(map, function(err, canvas) {
// now you have canvas
// example thing to do with that canvas:
var img = document.createElement('img');
var dimensions = map.getSize();
console.log('dimensions :');
console.log(dimensions);
img.width = dimensions.x;
img.height = dimensions.y;
img.src = canvas.toDataURL();
document.getElementById('images').innerHTML = '';
document.getElementById('images').appendChild(img);});
An I got this error : 我收到了这个错误:
leaflet-image.js:87 Uncaught TypeError: layer._adjustTilePoint is not a function
The code seems strange to me. 该代码对我来说似乎很奇怪。 My goal is to export the map as an image, in the folder I wish.
我的目标是在所需的文件夹中将地图导出为图像。 But I don't give a filepath or a filename...
但是我不提供文件路径或文件名...
Regarding leaflet.print(), I tried this : 关于leaflet.print(),我尝试了以下方法:
var printProvider = L.print.provider({
method: 'GET',
outputFormat : '.png',
outputFilename: 'Desktop/carte',
autoLoad: true,
dpi: 90
});
var printControl = L.control.print({
provider: printProvider
});
map.addControl(printControl);
Honestly, I'm completely lost here. 老实说,我在这里完全迷路了。 So if anyone had an idea or could explain to me how this works, that would be a great help.
因此,如果有人有想法或可以向我解释这是如何工作的,那将是很大的帮助。
At the end, I managed to access the image using its online path (http//...). 最后,我设法使用其在线路径(http // ...)访问该图像。 Depending on the source, it may lead to an access problem, but it works fine with the online mapping service and the provided key.
取决于来源,它可能会导致访问问题,但是与联机地图服务和提供的密钥一起使用时效果很好。 I am not using leaflet at all.
我根本不使用传单。
Thanks for the help ! 谢谢您的帮助 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.