elcaiaimar Posted December 13, 2014 Share Posted December 13, 2014 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 More sharing options...
justsomeguy Posted December 15, 2014 Share Posted December 15, 2014 What is the context for that code? Is it in another event handler or something? Link to comment Share on other sites More sharing options...
elcaiaimar Posted December 16, 2014 Author Share Posted December 16, 2014 I'm working with openlayers 3. I have a map with several JS buttons and this code is from one of them. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 16, 2014 Share Posted December 16, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now