Print Mapbox/Leaflet Map

2020-07-26 11:26发布

问题:

I want to print a Mapbox Map, that has custom Pins on it. On Chrome or Safari, there is no problem, because I can just use the window.print command.

The problems I have with Firefox and IE when trying to print:

  • Pins show up in the wrong position
  • Pins completely disappear

What I also tried:

  • Html2Canvas: That did not work, I guess because the tiles have fixed layouts. The canvas you get back only shows the typical grey/white grid "behind" the map
  • Static MapBox API: I need the pins numbered higher than 9, and the Mapbox API only offers Pins from 0 to 9.

Do you have any good idea how to solve this problem? Is there a chance to use the static Mapbox API with custom pins?

回答1:

That CSS snippet did it:

.leaflet-container img { max-width:none!important; }