Jump to content

export png


elcaiaimar

Recommended Posts

Hello,

 

I have a button which exports a map in png format. Everything is ok: I click it and save the image. However, if after do this, I pass my mouse over the button (without click), the map works very slowly, sometimes even the map and firefox is blocked. Here my code:

 

if ('download' in button) {

button.addEventListener('click', function() {

map.once('postcompose', function(event) {

var canvas = event.context.canvas;

button.href = canvas.toDataURL('image/png');

button.download = 'mapa.png';

});

map.renderSync();

}, false);

} else {

var info = document.getElementById('no-download');

/**

* display error message

*/

info.style.display = '';

}

I think that the problem would be solved if the function finished after click the button and save the image. I' ve noticed that when I click on the button for first time, my pointer looks normal but after this first time, when I pass over the button, the pointer becomes as if it was a url.

How could I solve this?

Thank you very much!

Link to comment
Share on other sites

That doesn't really help much, I don't see anything in that code necessarily that would cause what you're describing, but it might be caused by how you're using that code. That code defines an event handler, for example, so if you have that code running in another event handler then you'll get duplicate events.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...