我正在使用插件Leaflet浏览器打印并遇到问题,当我点击打印时,我想在打印中显示比例,但我根本无法做到。即使您完全按照示例 ( https://github.com/Igor-Vladyka/leaflet.browser.print ) 中所示进行配置,它也不会出现。
我的代码很基本:
// PRINT
ctlPrint = L.browserPrint({
closePopupsOnPrint: false,
printModesNames: {Portrait:"Retrato", Landscape:"Paisagem", Auto:"Auto", Custom:"Selecione a área"}
}).addTo(map);
map.on("browser-print-start", function(e){
L.control.scale({
position: 'topleft',
imperial: false,
maxWidth: 200
}).addTo(e.printMap);
});
就这样!根据代码,比例尺应该显示在顶部和左侧,并且在打印之前的预览中它实际上显示了比例尺,但是当打印时没有。来人帮帮我?谢谢!我的代码在这里:https://github.com/eltonsantos/mapasFortaleza/blob/master/js/script.js
最佳答案
尝试使用“浏览器预打印”事件。
当“browser-print-start”事件被触发时,覆盖层尚未创建。
查看_print函数
https://github.com/Igor-Vladyka/leaflet.browser.print/blob/master/src/leaflet.browser.print.js
关于javascript - 传单浏览器打印插件在打印时不显示比例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47653070/