Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export map with pixi overlay #74

Open
mitow7821 opened this issue Jan 25, 2022 · 3 comments
Open

Export map with pixi overlay #74

mitow7821 opened this issue Jan 25, 2022 · 3 comments

Comments

@mitow7821
Copy link

Hi, I'am trying to export leaflet map and all elements inside it.
I use 'domtoimage' library to get blob file.
Unfortunately pixi overlay is not included in my final blob image.

I've found this old issue (#19) which covers simillar export problem, with that difference I need full map image.
I set value of preserveDrawingBuffer to true. Used methods from issue above... and still nothing.
Every time I'am getting blank image :(

Is there any way to export map with its pixi overlay?

@manubb
Copy link
Owner

manubb commented Jan 25, 2022

Hi.
No precise idea of what is going on but aren't you in the situation described in https://github.com/tsayen/dom-to-image#things-to-watch-out-for ?

@mitow7821
Copy link
Author

We can ignore fact of using domtoimage library.
I tried exporting pixi overlay only, using vanilla js and pixi methods described in linked issue.
Please check sandbox from old issue (your last comment). In my case image is downloaded correctly only when overlay is updated. When I click download btn I get blank image.

@mitow7821
Copy link
Author

mitow7821 commented Mar 29, 2022

With this code I'm able to dowload pixi layer:

  downloadLayer() {
    loader.load(() => {
      const { utils } = this.pixiLayer;
      const container = utils.getContainer();
      const renderer = utils.getRenderer();
      renderer.render(container);

      const elem = window.document.createElement("a");
      elem.href = renderer.view.toDataURL();
      elem.download = "image.png";
      document.body.appendChild(elem);
      elem.click();
      document.body.removeChild(elem);
    });
  }  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants