question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading multiple SVG with svg-overlay

See original GitHub issue

Good Morning, I am using the svg-overlay.js component to load an SVG. My question is : If I need to load multiple SVG do I need to create multiple SVG overlays aswell or there is a cleaner way to achieve it? Thanks you so much for any guidelines. This is the code I am using to load one svg:

// LOAD SVG
var svgOverlay = viewer.svgOverlay();
var path = 'images/money.svg';
function loadSVG(path, callback) {
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function(e) {
    try {
      if (xhr.readyState == 4 && xhr.status == 200) {
        callback(xhr.responseXML.documentElement);
      }
    } catch (e) {
      console.log(e);
    }
  };
  //
  xhr.open('GET', path, true);
  xhr.overrideMimeType('text/xml');
  xhr.responseType = 'document';
  xhr.send();
}
loadSVG(path, function(data) {
  var g = data.getElementById('moneyG');
  svgOverlay.node().appendChild(g);
}); // END LOAD SVG

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Salitehkatcommented, Apr 16, 2020

And we appreciate it. 😉 From this chaos and sadness some things have to turn into positive things… Greetings from France.

0reactions
msalsberycommented, Mar 18, 2021

Closing this, feel free to re-open if there’s any issues!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading an external SVG file. · Issue #29 - GitHub
Hi, Is it possible to load in "rect" an external SVG file instead of an image? ... No matter how many tryouts ive...
Read more >
Multiple svg files overlay - Stack Overflow
There is no built-in functionality to have multiple overlaid SVGs. One way to achieve that (probably the easiest) is by using synchronised ...
Read more >
Fits image with svg overlay
Fits image with svg overlay ... setupControls(); // Load array representation of image webfits.loadImage('some-identifier', arr, width, ...
Read more >
Managing SVG Interaction With The Pointer Events Property
Let's take a look at how to shape the interactivity of SVG images — that is, control which parts of the document can...
Read more >
Building SVG Components with React.js and d3.js - pganalyze
Learn how to use SVG with React and d3, what SVG is, when to use it, handling, sizing, styling, layouting and interactivity in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found