spatialillusions / milsymbol

Military Symbols in JavaScript
www.spatialillusions.com/milsymbol
MIT License
544 stars 133 forks source link

Using OffscreenCanvas #233

Closed yevhenii-username closed 4 years ago

yevhenii-username commented 4 years ago

Did you tried use OffscreenCanvas for asCanvas method. In my case I have 200 objects and when I prerare symbol for renderin in ArcGis i use milSym.asCanvas().toDataURL(). For this operation i spend 2-3 second, If move creating canvas to web worker it can spend time.

Thank you

yevhenii-username commented 4 years ago

Problem was solved. When we were use milsymbol for rendering symbols with cyrillic amplifiers, lib throw exception on this method.

Symbol.prototype.toDataURL = function() { return "data:image/svg+xml;base64," + window.btoa(this.asSVG()); };

First we tried use ms.asCanvas().toDataURL(). Problem was solved, but in biggest data was perfomance problems, After recerch problem I solved it replacing

return "data:image/svg+xml;base64," + window.btoa(this.asSVG()); to return "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(this.asSVG())))