Нема описа

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var Renderer = (function () {
  4. function Renderer() {
  5. }
  6. Renderer.prototype.rasterize = function (target, markerImage, done) {
  7. var canvas = document.createElement('canvas');
  8. canvas.width = markerImage.width.baseVal.value;
  9. canvas.height = markerImage.height.baseVal.value;
  10. var data = markerImage.outerHTML;
  11. var ctx = canvas.getContext('2d');
  12. if (!ctx) {
  13. throw new Error('Invalid ctx');
  14. }
  15. ctx.drawImage(target, 0, 0, canvas.width, canvas.height);
  16. var DOMURL = window.URL;
  17. var img = new Image(canvas.width, canvas.height);
  18. img.setAttribute('crossOrigin', 'anonymous');
  19. var blob = new Blob([data], { type: 'image/svg+xml' });
  20. var url = DOMURL.createObjectURL(blob);
  21. img.onload = function () {
  22. ctx.drawImage(img, 0, 0);
  23. DOMURL.revokeObjectURL(url);
  24. done(canvas.toDataURL('image/png'));
  25. };
  26. img.src = url;
  27. };
  28. return Renderer;
  29. }());
  30. exports.Renderer = Renderer;