1

I have a loaded svg map, and then I create some paths that I want to be added inside a group of the loaded SVG, but I cant.

Here I load my map

var mapa = SVG('map').size('100%', '100%');

var mapLoad = new XMLHttpRequest();
mapLoad.open('GET', 'img/my_map.svg', true);
mapLoad.send();
mapLoad.onload = function(e) {
  mapa.svg(mapLoad.responseText);
}

Then I create some paths in the SVG

var plane = mapa.path('...');

And this is the actual result

That's the result I'm getting

What I want is to add all those paths inside the "#content" group

1 Answer 1

2

Your new mapa is an element within your markup, not the root element, so just use that element when you create new content.

var mapa = SVG('map').size('100%', '100%');

var mapLoad = new XMLHttpRequest();
mapLoad.open('GET', 'img/my_map.svg', true);
mapLoad.send();
mapLoad.onload = function(e) {
  mapa.svg(mapLoad.responseText);
  mapa = SVG.get('mapa');
  var plane = mapa.path('...');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.