leaflet 加入下载导出图片功能

457 阅读1分钟

安装插件

`npm install leaflet-easyprint`

引入插件

import EasyPrint from 'leaflet-easyprint';
 export default { $L,EasyPrint
  };

对应页面使用

    var tiles =  await this.$utils.map.$L.tileLayer("http://t0.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=key", { noWrap: true }).addTo(this.map);
    
    this.$utils.map.$L.easyPrint({
      		tileLayer: tiles,
      		sizeModes: ['Current', 'A4Landscape', 'A4Portrait'],
      		filename: 'myMap',
      		exportOnly: true,
      		hideControlContainer: true
		}).addTo(this.map);