Closed EfficiencyJunky closed 4 years ago
Turns out, I needed to use "cloneNode()" on each "trkpt" node I was adding to the original file.
Simply doing this caused the issue:
trkseg.appendChild(trkpts[j]);
Needed to CLONE the trkpts[j]
element before appending it. so changed the code to this:
// use the cloneNode() function to clone the node and set the "deep" parameter to true
// setting deep to true means it will do a full clone of the node AND its descendants (child nodes)
let trkpt = trkpts[j].cloneNode(deep = true);
// append the cloned node to the trkseg array
trkseg.appendChild(trkpt);
When combining GPX (XML) files together, only every other node from each subsequent file is being added for some reason.