3

First of all thanks for your help. I'm using html2canvas to get an image of my app web and share it in social networks. In the app there is a leaflet map with a canvas layer but the result image is incomplete. I put option L_PREFER_CANVAS = true; to force canvas in leaflet map. I also have used leaflet image plugin but it only return the base map and I need legend too.

Thanks so much.

Result of html2canvas

In js

 html2canvas(document.body, {
      allowTaint : false,
      logging : true,
      taintTest: false,
      useCORS: true,
      onrendered: function(canvas) {
        // canvas is the final rendered <canvas> element
        dataURL = canvas.toDataURL("image/png");  
        console.info(dataURL);          
        window.open(dataURL);
      }
    });   

Log

log html2canvas

CMM
  • 311
  • 3
  • 9
  • Is your legend inside the same map div? – Andy Mar 18 '15 at 20:27
  • The legend is created an independent div after this is added into map with this code and then is inside in map div `var legend = L.control({position: 'bottomright'}); legend.onAdd = function (map) { var div = L.DomUtil.create('div', 'legend'); div.innerHTML = document.getElementById('legendMap').innerHTML; return div; }; legend.addTo(map);` – CMM Mar 19 '15 at 23:11
  • Which version of html2canvas are you using? I was using the 5.0 and getting some issues with leaflet – Andy Mar 20 '15 at 18:15
  • I used 0.41 but not working for me, I think that my problem is proxy. I dont know what is your purpose but maybe you can use [link](https://github.com/mapbox/leaflet-image) I haven't used it yet. Where are you save image map? – CMM Mar 22 '15 at 21:52
  • I'm just appeding it into a div :) Since I want the user to save the picture, I've created an URL using the canvas :D – Andy Mar 27 '15 at 13:47
  • Amm ok, I 've found this [Save map](https://github.com/tegansnyder/Leaflet-Save-Map-to-PNG) maybe I could help you. What is your problem with html2canvas? – CMM Mar 29 '15 at 21:41
  • Nice. I'll take a look on this library. The issue starts when I drag the map... I get a canvas with the dragged map and some tileLayers are missing (from OSM, for example). But I see them there on the map... I found out that if I use another htmltocanvas version it doesn't happen... but I still get some images where the layers seem not to be in the right spot :o – Andy Apr 08 '15 at 19:14

0 Answers0