pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<small id='Vd9GD'></small><noframes id='Vd9GD'>

<legend id='Vd9GD'><style id='Vd9GD'><dir id='Vd9GD'><q id='Vd9GD'></q></dir></style></legend>

    <tfoot id='Vd9GD'></tfoot>

      • <bdo id='Vd9GD'></bdo><ul id='Vd9GD'></ul>

      1. <i id='Vd9GD'><tr id='Vd9GD'><dt id='Vd9GD'><q id='Vd9GD'><span id='Vd9GD'><b id='Vd9GD'><form id='Vd9GD'><ins id='Vd9GD'></ins><ul id='Vd9GD'></ul><sub id='Vd9GD'></sub></form><legend id='Vd9GD'></legend><bdo id='Vd9GD'><pre id='Vd9GD'><center id='Vd9GD'></center></pre></bdo></b><th id='Vd9GD'></th></span></q></dt></tr></i><div class="muis0yw" id='Vd9GD'><tfoot id='Vd9GD'></tfoot><dl id='Vd9GD'><fieldset id='Vd9GD'></fieldset></dl></div>

        html2canvas 捕獲除內(nèi)部畫布內(nèi)容之外的所有內(nèi)容

        html2canvas captures everything except the content of an inner canvas(html2canvas 捕獲除內(nèi)部畫布內(nèi)容之外的所有內(nèi)容)

        <small id='PKwWA'></small><noframes id='PKwWA'>

        <tfoot id='PKwWA'></tfoot>
          <tbody id='PKwWA'></tbody>
        1. <i id='PKwWA'><tr id='PKwWA'><dt id='PKwWA'><q id='PKwWA'><span id='PKwWA'><b id='PKwWA'><form id='PKwWA'><ins id='PKwWA'></ins><ul id='PKwWA'></ul><sub id='PKwWA'></sub></form><legend id='PKwWA'></legend><bdo id='PKwWA'><pre id='PKwWA'><center id='PKwWA'></center></pre></bdo></b><th id='PKwWA'></th></span></q></dt></tr></i><div class="ooe0e2u" id='PKwWA'><tfoot id='PKwWA'></tfoot><dl id='PKwWA'><fieldset id='PKwWA'></fieldset></dl></div>
          • <bdo id='PKwWA'></bdo><ul id='PKwWA'></ul>

                  <legend id='PKwWA'><style id='PKwWA'><dir id='PKwWA'><q id='PKwWA'></q></dir></style></legend>
                  本文介紹了html2canvas 捕獲除內(nèi)部畫布內(nèi)容之外的所有內(nèi)容的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問題描述

                  我有一張通過leaflet 渲染的地圖.

                  I've got a map rendered by means of leaflet.

                  我需要使用 html2canvas 對(duì)該地圖進(jìn)行截圖.

                  I need to make a screenshot of that map by using html2canvas.

                  要使用html2canvas,我需要提供一個(gè)要捕獲的DOM 元素(elementToCapture)和一個(gè)可選配置(??html2canvasConfiguration).

                  To make use of html2canvas, I need to provide a DOM element to capture (elementToCapture) and an optional configuration (html2canvasConfiguration).

                  var html2canvasConfiguration = {
                      useCORS: true,
                      width: map._size.x,
                      height: map._size.y,
                      backgroundColor: null,
                      logging: true,
                      imageTimeout: 0
                  };
                  
                  var elementToCapture = map._container.getElementsByClassName('leaflet-pane leaflet-map-pane')[0];
                  html2canvas(elementToCapture, html2canvasConfiguration).then(function (canvas) {
                      var link = document.createElement('a');
                      link.download = 'test.png';
                      link.href = canvas.toDataURL();
                      link.click();
                      link.remove();
                  })
                  

                  我通過 leaflet-pane leaflet-map-pane 類提取了一個(gè)元素,它基本上代表了整個(gè)地圖,包括控件(放大/縮小按鈕、比例等)、自定義標(biāo)記、工具提示、疊加層、彈出窗口.

                  I extract an element by the leaflet-pane leaflet-map-pane class, which basically represents the whole map including controls (zoom in/out buttons, scale, etc), custom markers, tooltips, overlays, popups.

                  整個(gè) DOM 看起來(lái)像

                  The entire DOM looks like

                  <div class="leaflet-pane leaflet-map-pane">
                      <div class="leaflet-pane leaflet-tile-pane">
                          <div class="leaflet-gl-layer mapboxgl-map">
                              <div class="mapboxgl-canvas-container">
                                  <canvas class="mapboxgl-canvas leaflet-image-layer leaflet-zoom-animated"></canvas>
                              </div>
                              <div class="mapboxgl-control-container"></div>
                          </div>
                      </div>
                      <div class="leaflet-pane leaflet-shadow-pane"></div>
                      <div class="leaflet-pane leaflet-overlay-pane"></div>
                      <div class="leaflet-pane leaflet-marker-pane"></div>
                      <div class="leaflet-pane leaflet-tooltip-pane"></div>
                      <div class="leaflet-pane leaflet-popup-pane"></div>
                  <div class="leaflet-control-container"></div>
                  

                  我遇到的問題是 leaflet-pane leaflet-tile-pane 元素(尤其是內(nèi)部 canvas 的內(nèi)容)沒有被 <捕獲代碼>html2canvas.簡(jiǎn)而言之,我在地圖上看到的所有內(nèi)容,但我看不到地圖本身.

                  The problem I've faced is the leaflet-pane leaflet-tile-pane element (particularly the content of the inner canvas) doesn't get captured by html2canvas. To put it simply, I see everything on the map, but I don't see the map itself.

                  更新 1:

                  我目前使用的版本是1.0.0-rc.1(最新的).

                  The version I am currently using is 1.0.0-rc.1 (the latest one).

                  更新 2:

                  畫布的本質(zhì)是webgl.可能是問題嗎?根據(jù) this,他們確實(shí)支持 webgl 畫布.

                  The nature of the canvas is webgl. Might it be the issue? According to this, they do support webgl canvases.

                  更新 3:

                  我嘗試以編程方式獲取畫布并在其上調(diào)用 toDataURL.即使使用 preserveDrawingBuffer hack,它也會(huì)導(dǎo)致屏幕截圖為空.

                  I tried to obtain the canvas programmatically and call toDataURL on it. It resulted in an empty screenshot, even with the preserveDrawingBuffer hack.

                  更新 4:

                  奇怪的是,它不僅僅捕捉某些畫布.我創(chuàng)建了一個(gè) 2d 畫布(通過將 preferCanvas 添加到地圖配置)并顯示出來(lái)了.

                  Oddly enough, it doesn't capture only certain canvases. I've created a 2d canvas (by adding preferCanvas to map configuration) and it got shown.

                  推薦答案

                  試試這個(gè),將它添加到頁(yè)面頂部,在任何其他腳本之前

                  Try this, add this to the top of your page, before any other scripts

                  <script>
                  HTMLCanvasElement.prototype.getContext = function(origFn) {
                    return function(type, attribs) {
                      attribs = attribs || {};
                      attribs.preserveDrawingBuffer = true;
                      return origFn.call(this, type, attribs);
                    };
                  }(HTMLCanvasElement.prototype.getContext);
                  </script>
                  

                  有幫助嗎?

                  這篇關(guān)于html2canvas 捕獲除內(nèi)部畫布內(nèi)容之外的所有內(nèi)容的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個(gè)多邊形點(diǎn)是否在傳單中的另一個(gè)內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標(biāo)記群集圖標(biāo)顏色,繼承其余默認(rèn) CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點(diǎn)擊傳單標(biāo)記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認(rèn)加載磁貼顏色?)
                  Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)

                  <small id='8RpUJ'></small><noframes id='8RpUJ'>

                  1. <i id='8RpUJ'><tr id='8RpUJ'><dt id='8RpUJ'><q id='8RpUJ'><span id='8RpUJ'><b id='8RpUJ'><form id='8RpUJ'><ins id='8RpUJ'></ins><ul id='8RpUJ'></ul><sub id='8RpUJ'></sub></form><legend id='8RpUJ'></legend><bdo id='8RpUJ'><pre id='8RpUJ'><center id='8RpUJ'></center></pre></bdo></b><th id='8RpUJ'></th></span></q></dt></tr></i><div class="mq2yiw2" id='8RpUJ'><tfoot id='8RpUJ'></tfoot><dl id='8RpUJ'><fieldset id='8RpUJ'></fieldset></dl></div>

                      1. <legend id='8RpUJ'><style id='8RpUJ'><dir id='8RpUJ'><q id='8RpUJ'></q></dir></style></legend>
                        • <bdo id='8RpUJ'></bdo><ul id='8RpUJ'></ul>
                              <tbody id='8RpUJ'></tbody>
                            <tfoot id='8RpUJ'></tfoot>

                          • 主站蜘蛛池模板: 台式核磁共振仪,玻璃软化点测定仪,旋转高温粘度计,测温锥和测温块-上海麟文仪器 | 陕西安玻璃自动感应门-自动重叠门-磁悬浮平开门厂家【捷申达门业】 | 焊缝跟踪系统_激光位移传感器_激光焊缝跟踪传感器-创想智控 | 海尔生物医疗四川代理商,海尔低温冰箱四川销售-成都壹科医疗器械有限公司 | 开平机_纵剪机厂家_开平机生产厂家|诚信互赢-泰安瑞烨精工机械制造有限公司 | 泰安办公家具-泰安派格办公用品有限公司 | 烟台条码打印机_烟台条码扫描器_烟台碳带_烟台数据采集终端_烟台斑马打印机-金鹏电子-金鹏电子 | 成都思迪机电技术研究所-四川成都思迪编码器| 量子管通环-自清洗过滤器-全自动反冲洗过滤器-北京罗伦过滤技术集团有限公司 | 智能电表|预付费ic卡水电表|nb智能无线远传载波电表-福建百悦信息科技有限公司 | 首页-浙江橙树网络技术有限公司| 亿立分板机_曲线_锯片式_走刀_在线式全自动_铣刀_在线V槽分板机-杭州亿协智能装备有限公司 | 超声波分散机-均质机-萃取仪-超声波涂料分散设备-杭州精浩 | 深圳市超时尚职业培训学校,培训:月嫂,育婴,养老,家政;化妆,美容,美发,美甲. | 气动绞车,山东气动绞车,气动绞车厂家-烟台博海石油机械有限公司 气动隔膜泵厂家-温州永嘉定远泵阀有限公司 | 水稻烘干机,小麦烘干机,大豆烘干机,玉米烘干机,粮食烘干机_巩义市锦华粮食烘干机械制造有限公司 水环真空泵厂家,2bv真空泵,2be真空泵-淄博真空设备厂 | 二氧化碳/活性炭投加系统,次氯酸钠发生器,紫外线消毒设备|广州新奥 | 微波萃取合成仪-电热消解器价格-北京安合美诚科学仪器有限公司 | 定制液氮罐_小型气相液氮罐_自增压液氮罐_班德液氮罐厂家 | 超声波_清洗机_超声波清洗机专业生产厂家-深圳市好顺超声设备有限公司 | 东莞市超赞电子科技有限公司 全系列直插/贴片铝电解电容,电解电容,电容器 | 浙江红酒库-冰雕库-气调库-茶叶库安装-医药疫苗冷库-食品物流恒温恒湿车间-杭州领顺实业有限公司 | 煤粉取样器-射油器-便携式等速飞灰取样器-连灵动 | 比亚迪叉车-比亚迪电动叉车堆垛车托盘车仓储叉车价格多少钱报价 磁力去毛刺机_去毛刺磁力抛光机_磁力光饰机_磁力滚抛机_精密金属零件去毛刺机厂家-冠古科技 | 无痕胶_可移胶_无痕双面胶带_可移无痕胶厂家-东莞凯峰 | LHH药品稳定性试验箱-BPS系列恒温恒湿箱-意大利超低温冰箱-上海一恒科学仪器有限公司 | 奥运星-汽车性能网评-提供个性化汽车资讯 | 垃圾压缩设备_垃圾处理设备_智能移动式垃圾压缩设备--山东明莱环保设备有限公司 | 西门子代理商_西门子变频器总代理-翰粤百科| COD分析仪|氨氮分析仪|总磷分析仪|总氮分析仪-圣湖Greatlake | 锂电混合机-新能源混合机-正极材料混料机-高镍,三元材料混料机-负极,包覆混合机-贝尔专业混合混料搅拌机械系统设备厂家 | 智能电表|预付费ic卡水电表|nb智能无线远传载波电表-福建百悦信息科技有限公司 | 巨野电机维修-水泵维修-巨野县飞宇机电维修有限公司 | 便携式XPDM露点仪-在线式防爆露点仪-增强型烟气分析仪-约克仪器 冰雕-冰雪世界-大型冰雕展制作公司-赛北冰雕官网 | 电主轴-高速精密电主轴-高速电机厂家-瑞德沃斯品牌有限公司 | 冷柜风机-冰柜电机-罩极电机-外转子风机-EC直流电机厂家-杭州金久电器有限公司 | 自动气象站_气象站监测设备_全自动气象站设备_雨量监测站-山东风途物联网 | 德国进口电锅炉_商用电热水器_壁挂炉_电采暖器_电热锅炉[德国宝] | 首页|专注深圳注册公司,代理记账报税,注册商标代理,工商变更,企业400电话等企业一站式服务-慧用心 | 磁棒电感生产厂家-电感器厂家-电感定制-贴片功率电感供应商-棒形电感生产厂家-苏州谷景电子有限公司 | 玻璃钢型材-玻璃钢风管-玻璃钢管道,生产厂家-[江苏欧升玻璃钢制造有限公司] |