如何将元素附加到svg文档?

时间:2013-07-19 12:17:50

标签: javascript html svg w3c

我已经从svg创建了一张世界地图。现在我希望用户能够选择一个我能够做的国家。但是当用户选择国家/地区时,我想在国家/地区显示一个圈子,其中包含一些消息。我无法做到这一点。请检查js小提琴链接

我面临的问题是我们使用<g><path>元素创建了世界地图。因此,如果我想在现有文档的顶部创建一个svgDocument,那么我必须在path元素的顶部创建一个圆圈,如果我错了,请纠正我。

当我尝试下面的代码时,我得到层次结构请求dom exception 3 。请指导我。

圈子创建代码段

 var svgDocument = document.getElementById(areaId);
        console.log(" svgDocument " + svgDocument);
        var svgNS = svgDocument.namespaceURI;
        var shape = document.createElementNS(svgNS, "circle");
        shape.setAttributeNS(null, "cx", 100);
        shape.setAttributeNS(null, "cy", 100);
        shape.setAttributeNS(null, "r",  50);
        shape.setAttributeNS(null, "fill", "green");
        svgDocument.appendChild(shape)

以下是svg的一部分,其中包含美国的坐标:

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg

   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns="http://www.w3.org/2000/svg"


   viewBox="0 0 2506.2067 1446.0625"
   version="1.0"
   height="400"
   width="800"
   id="worldMap"


   >

  <metadata
     id="metadata24111">
    <rdf:RDF>

    </rdf:RDF>
  </metadata>
  <defs
     id="defs1930" />

     <style>
.circle
{
   opacity:0;
   fill:#b9b9b9;
   fill-opacity:1;
   stroke:black;
   stroke-width:0.5;
   stroke-miterlimit:3.97446823;
   stroke-dasharray:none;
   stroke-opacity:1;
}

/*
 * Land
 */
.land
{
   fill: #b9b9b9;
   fill-opacity: 1;
   stroke:white;
   stroke-opacity: 1;
   stroke-width:0.5;
   stroke-miterlimit: 3.97446823;
   stroke-dasharray: none;
}

.coast
{
   stroke-width: 0.3;
}



.aq
{
   fill:#e6e6e6;
}


.lake
{
   fill:white;
   fill-opacity:1;
   stroke:white;
   stroke-opacity: 1;
   stroke-width:0.3;
   stroke-miterlimit: 3.97446823;
   stroke-dasharray: none;
}
</style>

    <g
     class="land coast us"
     id="us"
     style="fill:#b9b9b9;fill-opacity:1;stroke:#ffffff;stroke-width:0.30000001;stroke-miterlimit:3.97446823;stroke-opacity:1;stroke-dasharray:none"
     transform="translate(-94.32927,-61.75)" onmouseover="highlight(evt, this)" onmouseout="dehighlight(evt, this)" onclick="select(evt, this)">

<path
       class="land us"
       d="m 329.55,462.56 c -0.36,-1.75 -4.19,-3.26 -4.85,-5.24 -0.74,-2.24 0.35,-4.25 -0.9,-6.53 -0.49,-0.89 -3.7,-2.85 -3.79,-3.49 -0.23,-1.8 -0.19,-3.4 1.53,-4.21 -0.74,0.44 -0.89,0.36 -0.45,-0.25 0.24,-0.51 0.54,-1.1 0.18,-1.83 -0.61,-1.23 0.6,-2.04 0.42,-3.18 -0.15,-0.87 -1.58,-2.15 -1.4,-2.81 0.29,-1.1 -0.62,-1.42 -1.29,-2.67 -0.47,-0.88 -0.15,-1.57 -0.05,-2.27 0.12,-0.86 -0.66,-1.64 -0.84,-2.53 -0.21,-1 0.13,-1.87 0.48,-2.64 0.14,-0.32 0.91,-2.14 1.15,-1.07 -0.12,-0.51 0.32,-0.47 0.78,-0.59 0.3,-0.09 0.21,-1.32 -0.54,-0.25 0.17,-0.9 0.09,-2.37 1.63,-2.42 -1.48,0.36 -0.71,-0.84 -0.64,-1.32 0.1,-0.71 0.29,-1.38 0.46,-2.06 0.26,-1.02 -0.03,-2.3 0.53,-3.19 0.82,-1.3 0.85,-3.5 0.74,-5.21 -0.04,-0.63 -0.41,-2.2 0.9,-2.04 -1.29,-1.03 -0.97,-2.4 -0.79,-3.08 0.23,-0.88 -0.63,-2.28 0.94,-2.35 1.17,-0.05 4.31,0.82 4.71,0.14 -0.45,0.23 -1.81,-0.38 -2.51,-0.59 -1.35,-0.42 -1.68,-0.18 -2.59,-0.05 -1.36,0.2 -1.51,-2.11 -1.56,-2.47 0.17,0.47 0.32,0.94 0.44,1.39 1.17,-0.24 -0.42,-2.79 1.73,-2.18 -0.82,-0.36 -1.53,-0.49 -2.12,-0.4 -1.02,-1.52 0.59,-1.5 1.77,-1.85 -0.65,0.04 -1.5,-0.25 -2.27,-0.66 -0.07,0.2 -0.1,0.42 -0.09,0.66 -1,-2.16 -0.89,-4.35 -3.05,-6.66 -1.03,-1.11 -2.37,-4.59 -0.74,-4.3 2.6,0.47 5.02,1.47 7.62,1.79 1.56,0.19 4.9,-0.09 5.87,1.04 -0.28,-0.52 -0.08,-0.89 0.47,-0.99 0.06,0.51 0.88,1.16 1.14,1.71 0.31,0.65 -0.96,1.4 -1.3,1.79 0.56,-1.52 -0.8,-0.09 -0.99,0.11 -0.62,0.63 -1.01,1.38 -1.5,2.07 1.29,0.57 1.77,0.06 2.23,-0.26 -0.46,0.12 -0.87,0.27 -1.24,0.46 -0.84,-1 0.14,-1.59 0.84,-1.89 1.23,-0.53 1.59,-1.4 2.46,-2.14 1.35,1.03 -1.27,1.73 -0.79,2.84 1,-0.71 1.5,1.79 0.22,1.92 0.06,-0.22 0.12,-0.44 0.18,-0.66 -0.98,0.1 -0.85,0.94 -1.01,1.52 -0.53,-0.56 -0.54,-1.04 -0.21,-1.33 -0.94,0.34 -0.9,1.36 -2.07,1.53 0.93,-0.21 1.06,-0.06 0.39,0.46 0.38,-0.56 0.69,-0.45 0.93,0.33 -0.29,-0.73 0.17,-1.09 1.38,-0.7 0.77,0.25 1.15,-0.66 1.37,-0.87 0.79,-0.8 2.43,-1.28 1.16,-3.06 -0.93,-1.3 1.79,-2.07 0.59,-3.06 -1,-0.83 -0.43,-1.51 -1.56,-2.43 -0.86,-0.69 -1.21,0.19 -1.58,-0.99 2.6,0.8 1.28,-1.12 1.58,-1.92 -1.13,0.15 -2,-1.17 -1.87,-1.65 0.24,-0.86 3.98,-0.33 5.3,-0.33 5.33,0 10.67,0 16.01,0 10.45,0 20.9,0 31.35,0 21.14,0 42.27,0 63.4,0 21.22,0 42.44,0 63.66,0 10.2,0 20.39,0 30.59,0 1.26,0 0.8,-1.11 0.75,-1.93 -0.03,-0.69 1.27,-1.42 2.34,-0.23 1.23,1.39 -0.03,4.01 2.74,4.46 0.83,0.14 4.44,0.12 5.05,1.04 0.65,1 3.53,-0.28 4.07,-0.49 1.18,-0.49 3.51,0.53 5.09,0.79 -0.07,0.53 0.51,0.89 1.26,0.92 -0.13,0.28 0.64,1.48 1.21,1.23 0.24,-0.11 -0.18,-0.69 0.21,-0.7 0.93,-0.01 1.78,0.48 2.75,0.88 0.78,0.33 1.23,0.11 1.52,0.67 0.19,0.37 0.66,0.51 1.07,0.54 2.37,0.17 3.47,-1.21 5.63,-1.23 -0.05,1.28 2.6,1.02 3.34,0.97 0.7,-0.05 1.52,-0.16 2.39,0.22 1.71,0.76 2.3,0.31 3.85,0.6 -3.98,1.19 -8.22,2.35 -11.39,4.25 -1.32,0.78 -2.3,1.81 -3.58,2.62 -1.43,0.91 -3.38,1.45 -4.41,2.65 2.85,1.96 8.04,-1.26 10.01,-1.39 0.34,0.91 -0.2,1.99 -0.88,2.44 0.62,0.13 1.25,-0.45 1.74,-0.21 0.88,0.41 0.79,0.52 1.76,0.52 1.68,0 2.82,-0.86 3.99,-1.39 1.37,-0.63 3.5,-0.24 4.78,-0.91 1.67,-0.88 3.45,-1.56 4.91,-2.63 0.06,0.66 0.95,1.11 1.48,1.71 0.55,0.64 -0.02,1.15 0.17,1.72 0.23,-0.27 2.55,-2.09 1.46,-0.53 1.31,-1.33 3.7,-0.17 5.78,1.44 1.94,1.52 2.72,0.92 4.75,1.44 2.82,0.72 3.98,-1.07 5.91,-1.52 1.16,-0.27 2.64,-0.04 3.94,-0.12 1.62,-0.1 3.05,-0.45 4.61,-0.64 -0.1,0.71 -0.23,1.42 0.05,2.25 1.77,0.3 3.14,0.17 4.53,0 1.25,-0.15 2.11,1.99 1.14,2.18 1.08,0.06 1.77,1.02 2.68,1.52 -0.84,1.19 -4.5,-0.68 -5.78,0.16 -0.05,0.03 -0.56,1.02 -0.52,1.02 -1.02,0.05 -1.77,-1.18 -2.9,-1.48 -3.32,-0.89 -4.02,0.77 -6.81,0.66 -2.96,-0.13 -2.86,2.05 -5.07,2.62 -0.06,-0.81 0.66,-1.24 0.98,-1.86 -1.59,0.23 -1.79,1.11 -3.16,1.46 -0.2,-0.51 -0.24,-0.98 -0.12,-1.39 -2.28,0.85 -2.9,3.72 -4.28,5.23 -0.35,0.38 -0.2,1.01 -0.56,1.38 -0.41,0.42 -1.36,0.38 -1.81,0.8 -0.69,0.63 -1.57,1.69 -1.18,2.79 1.8,-0.32 2.27,-3.04 4.87,-2.32 0.94,0.26 -0.66,2.24 -0.8,2.51 -0.45,0.89 -0.28,2.09 -0.88,2.89 -1.22,1.64 -1.02,3.62 -2.06,5.35 -0.54,0.88 -0.8,2.02 -0.56,3.19 0.22,1.09 1.09,2.22 0.68,3.16 -0.66,1.54 0.4,5.01 2.15,6.93 1.46,1.59 3.74,0.62 4.7,0.18 2.22,-1 3.42,-2.73 4.36,-4.6 0.51,-1.01 0.9,-2.07 0.94,-3.28 0.04,-1.03 -1.25,-3.47 -0.27,-4.02 -2.6,-1.02 -1.85,-2.9 -1.49,-3.99 0.24,-0.71 -0.3,-1.44 -0.27,-2.18 0.04,-0.77 1.21,-1.36 1.56,-2.01 0.41,-0.74 0.3,-1.47 0.31,-2.35 0.02,-0.79 0.89,-0.85 1.37,-1.34 0.61,-0.61 0.47,-0.99 1.6,-1.21 1.32,-0.26 1.28,-1.52 2.39,-1.95 -0.33,0.89 0.1,2.11 -0.52,2.89 0.49,-0.24 0.81,-0.59 0.97,-1.04 0.18,0.54 0.04,1.03 -0.31,1.37 1.38,-0.58 1.33,-1.94 1.34,-3.2 0.02,-1.56 2.46,-0.95 3.57,-1.68 -2.8,-0.35 -0.44,-2.77 0.6,-2.95 0.64,-0.1 2.65,0.68 3.47,0.97 1.93,0.69 3.68,1.55 5.63,2.11 1.61,0.46 3.1,1.98 2.14,2.47 -0.92,0.48 0.29,1.95 0.51,2.8 0.26,1.04 0.15,2.79 -0.99,3.14 -1.25,0.38 -1.01,1.6 -2.09,2.1 -1.03,0.47 -2.39,1.02 -1.98,2.32 0.53,1.68 2.6,0.36 3.1,0.22 1.02,-0.29 3.39,-4.08 5.57,-2.48 1.69,1.23 1.74,4.3 2.24,5.59 0.64,1.69 1.45,5.64 -1.19,5.81 0.53,-0.79 -1.01,-1.22 -1.32,-0.55 -0.26,0.58 -0.11,1.37 -0.55,1.86 -0.47,0.52 -1.22,0.82 -1.7,1.33 -0.51,0.55 -0.58,1.3 -1.12,1.83 -0.4,0.4 -2.53,1.88 -0.65,2.36 0.68,0.18 1.36,0.28 2.04,0.48 0.33,0.14 0.62,0.32 0.89,0.54 0.52,0.25 1.24,0 1.87,0.24 -0.74,0.15 -1.61,0.14 -2.21,0.46 1.01,0.39 1.53,-0.17 2.41,-0.06 0.59,0.07 1.25,0.3 1.81,0.31 1.85,0.05 3.21,-0.63 5.11,-0.59 1.84,0.05 2.82,-1.29 4.06,-1.91 1.43,-0.71 3.28,-1.11 4.95,-1.6 3.46,-1.01 6.89,-2.21 9.56,-4.01 1.13,-0.77 2.44,-1.48 3.46,-2.33 0.59,-0.49 0.44,-2.49 -1.18,-2.53 0.72,-1.57 1.6,-1.93 4.06,-2.22 1.33,-0.15 2.89,-0.15 4.38,0.04 1.19,0.16 2.55,1.19 3.56,0.96 1.29,-0.3 2.67,-0.12 4.05,-0.26 1.51,-0.15 2.44,-0.99 3.67,-1.46 0.93,-0.36 2.26,-0.34 2.13,-1.46 -0.14,-1.15 0.39,-1.94 1.18,-2.65 -0.53,0.24 -1.5,0.44 -1.12,-0.52 -0.68,0.52 -1.03,0.12 -0.82,-0.35 0.22,-0.49 0.92,-0.76 1.46,-0.99 1.64,-0.71 2.7,-1.69 3.94,-2.73 1.34,-1.13 3.01,-2.61 5.19,-2.95 2.81,-0.45 6.24,-0.07 9.28,-0.12 4.52,-0.07 8.95,-0.16 13.59,0.03 0.89,0.03 3.55,0.35 3.81,-0.38 0.21,-0.6 0.33,-1.36 0.94,-1.73 0.69,-0.42 1.93,-0.19 2.68,-0.67 0.25,0.22 0.49,0.44 0.74,0.66 0.82,-0.35 0.03,-1.16 1.23,-1.05 -0.27,-0.03 1.76,-2.56 2,-2.74 0.99,-0.75 1.63,-0.96 1.33,-2.26 -0.23,-1.03 0.61,-2 1.33,-2.54 0.88,-0.66 0.37,-1.8 0.81,-2.65 0.62,-1.19 1.96,-2.03 2.93,-3 0.83,-0.82 3.1,-4.81 4.3,-1.59 0.64,1.72 4.62,-0.09 5.19,-0.22 3.35,-0.83 4.55,2.96 4.55,4.6 0,1.47 0.17,2.98 0.24,4.47 0.04,0.78 -0.62,2.99 0.42,3.81 1.11,0.86 2.14,0.02 2.08,1.31 -0.04,0.91 -0.37,1.85 0.92,2.78 0.4,-0.55 1.2,-0.32 1.76,0.4 0.66,0.85 -0.28,1.09 -0.09,1.84 0.84,-0.61 1.1,0.09 0.83,0.54 -0.3,0.48 -1.15,0.63 -1.82,0.75 -0.82,0.14 -1.51,0.25 -2.11,0.66 -0.42,0.29 -1.91,1.5 -1.83,0.01 -0.65,0.2 -0.86,0.91 -1.68,0.91 -0.62,0 -0.07,0.96 -0.72,1.11 -0.18,-0.4 -0.62,-1.47 -1.42,-1.3 -0.9,0.19 -0.95,1.4 -1.66,0.13 0.23,0.58 -0.04,0.51 -0.57,0.49 -0.62,-0.03 -0.03,1.21 0.07,1.46 -1.58,-0.67 -1.8,-1.52 -2.03,-2.61 0.03,0.76 -1.01,0.86 -1.4,1.37 -0.44,0.59 -0.41,1.41 -0.8,2.03 -0.9,1.44 -2.64,0.7 -3.37,2.28 -0.37,-0.42 -0.54,-0.51 -0.52,-0.98 -0.18,0.2 -0.36,0.4 -0.54,0.59 -0.23,-1.67 -0.93,0.15 -0.85,0.59 -0.26,-0.72 -0.47,-1.45 0.01,-1.96 -0.41,0.18 -0.66,0.46 -0.75,0.85 0.76,-0.17 0.46,1.68 0.15,1.95 -0.16,-0.28 -0.34,-0.56 -0.53,-0.84 -0.28,0.26 -1.16,1.2 -0.3,-0.14 -0.68,1.5 -0.5,0.16 -0.44,-0.26 -0.67,0.47 -2.27,0.92 -1.91,1.92 0.11,0.29 -1.09,1.56 -1.4,1.75 -1.18,0.75 -4.92,4.55 -1.82,6.06 -0.6,0.37 -3.23,1.31 -2.66,2.28 0.26,0.46 1.61,0.62 2.1,1.03 1.22,1.03 0.62,2.29 2.46,3.32 1.54,0.87 3.46,0.02 3.17,-1.22 -0.96,0 -0.5,-0.79 -1.67,-1.3 1.65,-0.06 2.29,1.97 2.08,2.74 -0.24,0.91 -4.14,1.49 -5.4,1.37 0.03,-0.47 0.1,-0.92 0.19,-1.37 -1.34,0.71 -2.63,1.72 -4.4,1.83 0.04,-0.69 -0.1,-1.46 0.4,-1.96 -0.64,0.32 -1.13,1.19 -1.82,0 -0.78,1.48 -0.26,2.84 -2.7,3.18 -0.49,0.07 -4.49,0.63 -4.78,-0.18 0.35,0.86 -1.21,0.86 -1.92,0.85 -1.55,-0.01 -2.35,0 -3.6,0.49 -2.5,0.98 -4.99,1.79 -6.8,3.36 0.65,-1.28 1.23,-2.51 0.17,-4.24 -0.36,1.43 1.57,4.15 -0.77,4.81 -1.82,0.52 -1.37,1.85 0.92,2.04 0.39,1.7 -0.29,3.19 -0.78,4.62 0.09,-0.43 0.19,-0.86 0.27,-1.29 -1.74,-0.04 -0.67,3.92 -2.68,3.78 -0.64,-0.04 -1.4,2.09 -1.67,2.45 -0.6,0.83 -1.44,1.92 -2.86,1.99 0.03,-0.41 0.9,-1.44 0.01,-1.85 -1.48,-0.69 -2.32,-0.73 -3.63,-1.9 -2.36,-2.1 1.41,-2.78 2.32,-3.7 -1.65,0.67 -4.6,1.69 -2.77,3.94 1.06,1.31 0.97,2.61 2.16,3.98 0.96,1.1 0.98,1.91 0.25,2.31 1.24,0.2 1.04,1.11 0.77,1.62 0.24,-1.48 -0.24,-0.14 -0.26,0.18 -0.04,0.52 -0.83,0.88 -1.16,1.23 -0.89,0.96 -1.35,2 -1.96,3.12 -0.55,1 -1.56,1.74 -2.08,2.72 -0.3,0.58 -0.29,2.16 -1.39,2.13 -0.94,-1.45 0.06,-2.97 0.73,-3.95 0.33,-0.5 1.06,-2.15 1.68,-2.26 -0.71,-0.21 -1.28,-0.14 -1.71,0.2 -0.03,-0.63 1.48,-1.88 -0.49,-1.88 0.21,-0.42 0.33,-0.87 0.33,-1.36 -0.37,1.07 -1.46,-0.52 -1.1,0.97 -0.28,-0.35 -1.68,-0.98 -1.69,-1.33 -0.03,-0.64 0.99,-0.97 0.05,-1.71 0.55,0.01 1.11,0.11 1.68,0.32 -0.36,-0.54 -1.56,-1.66 -2.27,-1.23 0.03,-0.91 0.86,-0.3 1.43,-0.66 0.96,-0.62 -1.08,-1.03 -1.59,-0.57 -0.03,-1.06 1.87,-0.67 1.68,-1.87 -0.18,0.18 -0.37,0.35 -0.58,0.51 -1.34,-1.76 1.59,-2.24 2.97,-2.39 -0.33,-0.17 -0.66,-0.34 -0.98,-0.52 0.51,-0.24 0.87,-0.58 1.08,-1.04 -0.42,0.28 -0.87,0.54 -1.33,0.78 0.16,-0.23 0.3,-0.46 0.43,-0.71 -0.85,-0.08 -1.09,0.31 -1.28,0.82 -0.14,0.35 -1.25,1.43 -0.8,0.09 -0.33,0.26 -0.51,0.61 -0.53,1.03 -0.78,-1.23 -1.66,0.2 -1.33,0.78 -0.33,-0.1 -0.65,-0.21 -0.98,-0.33 0.3,0.5 0.73,0.93 1.27,1.3 -0.95,0.08 -0.78,0.21 0.05,0.71 -2.66,-1.14 0.18,4.62 -0.17,5.18 -1.4,-0.65 -1.98,-1.6 -1.95,-2.65 -0.03,0.86 -0.01,1.62 1.06,2.4 0.83,0.61 1.98,1.52 1.26,2.19 -0.69,-1 -3.51,-1.02 -3.49,-2.2 -0.43,-0.06 -0.45,0.15 -0.05,0.65 -0.64,-0.25 -1.24,-0.67 -1.62,-1.17 -0.9,0.95 -1.97,-0.27 -1.22,-1.12 0.58,-0.66 2.25,-1.3 1.12,-2.5 0.53,1.23 -2.92,3.5 -1.72,4.19 0.73,0.42 1.44,-0.12 2.15,0.53 1.18,1.09 1.3,0.78 2.81,1.09 0.61,0.12 1.4,1.15 2.02,1.49 1.05,0.57 1.05,0.89 0.57,1.58 -1.27,1.83 -3.57,-0.96 -4.81,-2.28 0.4,1.21 2.26,3.03 3.73,3.62 1.81,0.73 1.9,1.82 -0.1,1.56 0.21,0.23 0.4,0.47 0.59,0.71 -0.96,0.58 -2.09,-0.8 -2.92,-1.36 1.29,1.23 5.09,3.07 2.58,3.88 -1.85,-2.32 -3.59,-2.13 -6.37,-2.91 0.43,0.44 2.15,0.54 2.93,0.93 1.09,0.52 3.43,1.83 2.76,2.83 0.32,-0.44 0.96,-0.4 1.57,0.06 -0.53,-1.04 0.89,-0.7 1.67,-0.53 0.99,0.22 1.01,0.82 1.29,1.55 0.36,0.96 0.61,1.9 0.88,2.86 0.34,1.23 1.69,2.56 1.69,3.76 -0.47,-1.04 -0.93,-2.13 -1.67,-3.14 -0.71,-0.97 -0.17,-1.99 -1.39,-2.88 0.07,0.35 0.16,1.04 -0.55,0.39 0.46,1.26 1.97,2.58 1.7,3.82 -0.12,-0.51 -0.45,-0.96 -0.98,-1.36 -0.04,0.69 -0.62,0.78 -1.39,0.19 0.23,0.23 0.45,0.47 0.65,0.71 -0.47,0.32 -1.04,0.26 -1.68,-0.19 1.27,1.31 -0.67,0.3 -1.29,0.06 0.31,0.21 0.59,0.42 0.87,0.65 -0.7,0.16 -1.06,0.88 -2.05,0.45 -1.06,-0.45 -1.05,-1.46 -0.78,-2 -0.29,0.29 -0.54,2.39 0.26,2.74 0.72,0.31 1.26,-0.4 1.93,-0.22 0.55,0.15 2.67,-0.54 2.92,0.38 0.16,0.63 0.09,1.54 -0.23,2.02 0.62,-0.2 0.7,-0.68 0.67,-1.22 -0.04,-0.72 0.97,-0.52 1.33,-0.98 0.95,1 0.12,1.71 0.31,2.65 -1.32,-0.66 -1.47,0.85 -1.85,1.35 -0.68,0.93 -2.82,0.4 -4.13,-0.19 0.07,-0.22 0.17,-0.44 0.29,-0.64 -0.56,0.12 -0.83,0.48 -0.45,1.03 -1.16,-0.42 -2.34,-0.31 -3.48,-0.9 0.74,0.49 4.99,1.74 3.6,2.26 -0.53,0.2 0.11,0.85 -0.32,1.18 -0.95,0.73 -1.65,0.65 -3.16,-0.14 0.44,0.9 1.26,1.22 2.22,1.11 0.64,-0.07 2.49,-0.84 2.46,-0.01 0.29,-0.16 0.61,-0.29 0.94,-0.39 -0.22,0.57 -0.71,1.29 -1.32,1.61 -0.34,0.18 -2.7,0.03 -1.97,0.52 -1.26,-0.17 -2.97,-0.32 -3.66,0.35 -0.47,0.47 -1.5,1.26 -1.52,-0.09 -0.3,0.29 -0.11,0.82 -0.12,1.2 -0.01,0.42 -1.01,0.58 -1.34,0.77 -1.48,0.8 -2.02,2.2 -2.58,3.58 0,-0.43 -0.09,-0.86 -0.26,-1.29 0.12,2.5 -2.88,1.69 -5.09,2.3 -2.51,0.7 -3.58,2.77 -4.64,4.6 -0.56,-0.47 -0.54,-0.98 -0.11,-1.29 -0.76,0.43 0.39,1.82 -0.57,2 -0.52,0.09 -0.19,0.41 -0.45,0.68 -0.47,0.48 -0.81,-0.01 -1.29,0.29 -0.5,0.31 -2.32,3.18 -3.25,1.42 0.8,1.45 -0.56,1.65 -1.55,2.17 -0.63,0.33 -1.11,0.65 -2.02,0.52 -0.39,-0.06 -2.65,0 -0.62,0.27 -2.17,0.39 1.69,0.15 -0.44,0.97 1.78,-0.15 -0.84,1.14 -1.04,-0.39 0.37,1.75 -0.91,-0.26 -1.12,-0.64 0.21,0.57 0.63,1.12 0.84,1.69 0.24,0.72 -1.2,1.81 -0.57,0.5 -0.7,1.54 -0.65,2.1 -2.62,2.65 0.17,0.21 0.34,0.43 0.51,0.64 -0.39,0.26 -0.88,0.3 -1.46,0.13 0.05,0.24 0.15,0.48 0.3,0.71 0.26,-0.07 0.51,-0.16 0.75,-0.26 0.07,0.8 -0.73,1.14 -1.6,1.1 1.08,0.44 1.01,1.63 0.11,1.03 0.59,1.06 -0.21,0.64 -1.21,0.45 0.63,0.17 1.18,0.47 1.65,0.91 -0.51,0.59 -1.4,0.51 -1.49,1.41 -0.06,0.65 -0.75,2.27 0.08,2.91 0.34,0.22 0.38,0.42 0.14,0.6 -0.6,0.43 -0.04,0.57 0.33,1.28 0.7,1.37 0.82,2.98 1.2,4.38 0.72,3 2.34,6.04 4.2,8.85 0.92,1.38 0.88,1.68 0.74,2.99 -0.13,1.3 0.66,2.48 1.12,3.77 -0.94,-1.33 -1.55,-2.75 -1.22,-4.11 0.37,-1.55 -1.33,-1.19 -1.71,-2.47 0.57,2.36 1.47,4.62 2.74,6.89 0.7,1.23 2.3,3.77 1.51,4.92 2.37,-0.3 1.46,8.67 1.19,9.65 -0.44,1.6 -0.8,4.95 -2.39,5.83 -0.52,0.29 -0.58,-0.96 -1.11,-0.04 -0.38,0.66 -1.35,0.01 -2.01,0.24 -1.11,0.38 -3.03,-0.12 -2.04,-1.36 0.35,0.46 0.9,0.82 1.49,0.97 0.14,-0.71 -1.41,-1.42 -1.86,-1.95 -1,-1.16 -0.78,-2.43 -2.53,-3.24 -1.04,-0.48 -2,-0.55 -2.38,-1.65 -0.36,-1.09 0.06,-2.61 -1.6,-3.23 0.83,-0.26 1.08,-1.05 1.72,-1.48 -0.72,0.2 -1,0.99 -1.7,1.24 -0.59,0.21 -0.66,-2.85 -0.35,-3.24 -0.44,0.3 -0.94,0.28 -1.5,-0.07 1.33,1.06 -0.31,1.29 -1.19,0 -0.81,-1.18 -0.69,-3.22 -2.32,-4 1.15,-0.06 2.84,-2.4 1.92,-3.41 -0.22,0.14 -0.43,0.29 -0.64,0.45 -0.07,-0.56 -0.58,-1 -1.19,-1.23 -0.25,0.46 -0.17,0.84 0.46,1.17 0.57,0.3 -0.26,1.27 -0.41,1.48 -0.47,-0.49 -0.93,-1.12 -0.52,0 -1.6,-2.64 0.79,-5.14 0.9,-7.57 0.03,-0.87 -0.17,-1.65 -0.58,-2.53 -0.72,-1.49 -1.28,-1.02 -2.58,-1.9 -1.88,-1.28 -2.87,-3.14 -4.16,-4.74 -0.63,-0.78 -1.87,-1.63 -2.93,-1.91 -1.55,-0.4 -2.06,0.84 -3.44,0.71 0.5,0.99 -0.61,0.76 -1.43,1.26 -0.32,0.2 -1.74,1.14 -1.76,0.29 -0.89,0.69 -2.22,0.9 -3.52,0.9 0.56,-0.87 -0.37,-2.01 -1.54,-2.45 0.52,0.06 0.36,-0.18 -0.47,-0.71 1.25,0.68 1.29,-0.17 0.25,-0.25 -1.55,-0.14 -0.79,-1.05 0,-1.23 -0.72,0.02 -1.44,0.05 -2.16,0.06 0.28,0.22 0.55,0.43 0.82,0.65 -1.36,0.32 -4.3,-1.14 -5.75,-1.68 0.18,0.02 2.87,0.33 2.55,-0.08 -0.32,-0.4 -1.26,-0.66 -1.71,-0.74 -0.82,-0.14 -1.35,0.44 -1.95,0.66 -1.01,0.38 -2.64,0.38 -3.86,0.35 0.67,-0.06 1.26,-0.23 1.78,-0.51 -0.7,-0.18 -1.1,-0.61 -0.83,-1.1 -0.26,0.37 -0.48,0.75 -0.65,1.16 -0.16,-1.78 -0.87,-0.09 -1.15,0.29 -0.43,0.56 -1.07,0.85 -2,0.81 0.52,-0.12 1.72,-0.71 0.65,-1.35 -0.12,1.46 -2.13,2.25 -3.99,1.67 1.85,0.54 -0.16,-2.98 -0.69,-3.68 -0.14,0.76 -0.35,1.61 -0.62,2.32 -0.2,0.53 -1.39,0.22 -1.9,0.51 -0.28,0.16 -1.92,0.2 -1.83,-0.02 -0.34,0.82 -1.6,-0.54 -2.21,-0.29 0.35,0.09 -1.84,0.53 -2.32,0.58 -1.21,0.12 -1.15,0.73 -2.23,1.09 -1.93,0.63 -3.38,-1.5 -5.3,-1.47 -0.68,0.01 -2.38,1.69 -1.04,2.23 0.89,0.36 2.18,0.31 2.87,0.05 0.56,-0.22 1.98,-0.1 2.3,-0.41 -0.16,0.29 -1.58,0.89 -1.22,1.35 0.83,1.17 1.22,0.51 1.7,-0.08 0.55,-0.77 2.09,0.23 1.72,1.09 -0.32,0.73 -2.18,0.13 -1.54,1.38 -1.1,-0.32 -1.05,0.3 -0.62,0.97 0.69,1.09 1.64,1.19 2.88,1.49 0.6,0.14 1.01,0.83 1.53,1.21 0.52,0.39 -0.78,1.05 -0.61,1.55 -1.06,-1.02 -1.64,-0.02 -2.2,0.46 0.29,-0.49 0.58,-0.99 0.71,-1.55 -0.73,-0.08 -0.62,-0.41 -1,-0.78 -0.24,-0.23 -2.15,-0.77 -2.48,-0.77 0.37,-0.83 -2.82,-2.04 -3.1,-1.78 -0.16,0.15 0.84,1.11 0.86,1.45 0.07,1 -0.06,1.89 -1.25,2.14 -0.28,-0.94 -0.18,-1.22 -1.42,-1.42 -1.99,-0.33 -0.83,0.9 -2.11,1.15 -2.02,0.39 -4.87,-1.73 -4.13,-3.48 -0.28,0.79 -1.55,0.43 -2.25,-0.05 -0.45,-0.32 -0.85,-0.78 -0.8,-1.23 -0.79,-0.11 -2.06,0.45 -1.38,-0.65 -0.93,0.01 -2.98,0.77 -1.73,1.87 -1.48,-0.21 -2.55,0.41 -4.17,0.07 -1.9,-0.4 -3.71,-1.34 -5.61,-1.81 0.65,-0.62 0.85,-1.21 0.09,-2.13 -0.06,0.68 0.25,2.33 -0.69,2.53 -0.88,0.19 -2.57,0.37 -3.56,-0.01 0.3,-0.58 1.08,-1.01 0.76,-1.81 -0.9,0.45 -1.64,1.38 -0.52,2.39 -2.68,0.31 -5.3,1.09 -7.17,2.51 0.46,-0.74 1.42,-1.23 2.34,-1.55 -0.83,-0.13 -1.56,0.07 -2.25,0.26 0.36,-0.56 0.74,-1.23 0.26,-2 -0.63,0.13 -0.58,0.68 -1.09,0.9 -0.49,0.22 -0.78,-0.66 -1.16,-0.12 -0.33,0.46 0.71,2.2 1.49,2.38 -0.99,1.1 -2.23,1.83 -3.14,3 -1.25,1.6 -4.51,1.3 -5.55,2.81 0.46,-0.13 0.92,-0.26 1.38,-0.39 -1.05,0.58 -2.18,1.11 -3.39,1.49 0.46,-0.48 1.2,-0.7 1.6,-1.23 -0.48,0.12 -0.94,0.27 -1.37,0.45 0.98,-0.61 -1.51,-0.45 -1.97,-1.16 0.25,0.45 0.23,0.83 -0.05,1.16 -0.29,-1.92 -2.42,1.13 0.29,1.03 -0.71,0.76 -2.03,1.1 -3.02,-0.13 0.39,1.07 -1.07,3.4 -1.15,2 -0.26,1.02 -1.95,-0.03 -2.06,1.16 0.66,0.15 1.15,0.03 1.46,-0.38 0.27,1.99 -2.1,1.64 -3.66,2.06 0.3,0.04 0.61,0.06 0.91,0.07 -0.11,0.48 0.41,0.8 0.69,1.21 0.35,0.5 -0.45,1.58 -0.62,1.96 -0.45,1.01 -2.04,1.07 -2.99,-0.08 0.49,0.47 0.59,0.92 0.32,1.36 0.78,0.15 1.61,0.29 2.21,-0.07 -0.01,0.71 -0.09,1.89 -0.8,2.24 -0.6,0.3 0.47,1.8 0.6,2.28 0.41,1.43 0.25,4.39 1.87,5.55 0.21,-0.19 0.4,-0.38 0.58,-0.58 0.39,0.68 -1.34,1.33 -1.86,1.39 -1.02,0.13 -2.15,-1.46 -3.37,-1.46 -0.99,0 -2.26,0.23 -3.3,-0.25 -1.2,-0.57 -2.79,-1.86 -4.2,-2.03 -2.45,-0.3 -2.79,-1.69 -3.64,-3.6 -0.58,-1.29 -1.3,-2.39 -1.55,-3.72 -0.1,-0.57 0.06,-1.1 -0.11,-1.67 -0.23,-0.84 -1.59,-1.13 -2.22,-1.81 -0.97,-1.05 -1.38,-2.28 -2.52,-3.26 -1.12,-0.96 -1.72,-1.99 -2.32,-3.16 -0.57,-1.12 -0.77,-2.25 -1.41,-3.36 -0.31,-0.55 -0.84,-0.97 -1.17,-1.5 -0.41,-0.64 -1.52,-1.05 -1.76,-1.63 -0.44,-1.09 -2.34,-1.44 -2.81,-2.59 -0.05,-0.13 -2.5,-0.4 -2.73,-0.43 -2.55,-0.31 -5.1,-0.39 -6.96,0.73 -2.02,1.22 -1.55,4.27 -3.78,5.45 -0.99,0.53 -2.81,-0.72 -3.84,-1.23 -0.92,-0.46 -1.88,-0.84 -2.8,-1.31 -0.7,-0.36 -1.55,-1.35 -2.26,-1.56 -1.51,-0.44 -2.36,-2.27 -2.64,-3.37 -0.25,-0.74 -0.07,-1.32 -0.51,-2.08 -0.4,-0.68 -0.93,-1.31 -1.14,-2.01 -0.39,-1.31 -1.88,-1.8 -3.2,-2.43 -1.84,-0.89 -3.63,-2.81 -5.07,-4.11 -1.2,-1.07 -2.15,-0.86 -3.15,-2.32 -1.12,-1.64 -3.78,-1.13 -5.18,-1.13 -2.26,0 -4.5,0.08 -6.81,-0.04 -2.55,-0.12 -2.26,0.96 -2.43,2.57 -0.22,2.04 -5.67,0.95 -7.71,0.95 -4.16,0 -8.29,0.34 -12.5,0.17 -1.97,-0.08 -4.16,-1.13 -6.18,-1.77 -2.78,-0.88 -5.58,-1.58 -8.36,-2.42 -5.25,-1.6 -10.5,-3.33 -15.75,-5.07 -0.01,-0.66 0.48,-1.07 0.71,-1.62 -6.29,0.17 -12.28,0.89 -18.36,1.42 -0.77,-1.51 -0.83,-2.93 -1.49,-4.43 -0.81,-1.83 -2.64,-2.53 -4.45,-3.83 -1.85,-1.33 -1.5,-0.56 -3.22,-1.03 -1.17,-0.32 -0.01,-2.6 -2.93,-2.52 -1.79,0.06 -2.7,-0.38 -4.23,-1.65 -1.62,-1.34 -3.58,-1.11 -5.31,-1.4 -1.13,-0.19 -4.19,0.35 -4.62,-1.44 -0.27,-1.12 0.66,-2.16 0.11,-3.31 -0.59,-1.11 -2.17,-0.92 -2.01,-2.16 0.1,-0.78 -1.62,-1.72 -2.64,-2.33 -1,-0.59 -1.38,-1.36 -1.89,-2.16 -0.75,-1.16 -3.27,-2.31 -3.51,-3.36 -0.38,-1.64 -0.13,-1.63 0.57,-2.74 0.81,-1.31 -0.77,-1.62 -2.47,-2.36 -2.52,-1.1 -1.53,-2.14 -2.68,-3.51 -0.68,-0.81 -0.66,-2.63 0.41,-2.68 0.26,0.44 -0.04,0.87 0.31,1.3 0.43,0.53 1.49,0.96 2.11,1.36 -0.39,-1.76 -2.81,-3.74 -0.82,-4.67 -3.52,-2.04 -0.9,1.86 -2.48,1.61 -1.02,-0.17 -3.34,-2.27 -3.64,-1.09 0.21,-0.52 -0.03,-2.13 1.36,-0.71 -0.4,-0.6 -0.83,-1.22 -1.62,-1.69"
       id="path3804"

       style="fill:#b9b9b9;fill-opacity:1;stroke:#ffffff;stroke-width:0.5;stroke-miterlimit:3.97446823;stroke-opacity:1;stroke-dasharray:none" />

       </g></svg>

1 个答案:

答案 0 :(得分:0)

您可能希望将圆圈不是附加到文档本身,而是附加到文档元素(或更具体的地方,例如您通过id获取的某个元素)。

替换:

svgDocument.appendChild(shape)

使用:

svgDocument.documentElement.appendChild(shape)