Javascript 将SVG内联到jvectormap

Javascript 将SVG内联到jvectormap,javascript,jquery,svg,jvectormap,Javascript,Jquery,Svg,Jvectormap,我必须自定义一个地图,以便在矢量地图中使用它。所以我使用内联SVG来制作地图。地图显示得非常完美,但我无法使用jvectormap对其进行操作。我只是jvectormap的初学者,所以我的代码可能有点错误。如果你有任何想法,请回答 提前谢谢 下面是我的代码: <div id="pantsun" > <svg title="well" width="500" height="300" style="border: 1px solid #000;background-color:

我必须自定义一个地图,以便在矢量地图中使用它。所以我使用内联
SVG
来制作地图。地图显示得非常完美,但我无法使用jvectormap对其进行操作。我只是jvectormap的初学者,所以我的代码可能有点错误。如果你有任何想法,请回答

提前谢谢

下面是我的代码:

<div id="pantsun" >
<svg title="well" width="500" height="300" style="border: 1px solid #000;background-color: lightgreen;" >
  <rect x="200" y="0" width="30" height="300" style="fill:white;" />
  <rect x="0" y="50" width="500" height="30" style="fill:white;" />
  <rect x="0" y="150" width="500" height="30" style="fill:white;" />
  <rect x="10" y="18" width="30" height="30" style="fill:darkgrey;" />
  <rect x="45" y="18" width="30" height="30" style="fill:darkgrey;" />
  Sorry, your browser does not support inline SVG.
  </svg>
</div>

<script>

$(function(){
 $('#pantsun').vectorMap({
  map: 'well',
  backgroundColor: 'transparent',
  markers: [{
    coords: [0, 50],
    name: 'well 1',
    style: {fill: 'white'}
  },{
    coords: [0, 150],
    name: 'well 2',
    style: {fill: 'white'}
}}};

</script>

很抱歉,您的浏览器不支持内嵌SVG。
$(函数(){
$(“#pantsun”).vectorMap({
地图:'好',
背景色:“透明”,
标记:[{
坐标:[0,50],
名称:“井1”,
样式:{填充:“白色”}
},{
coords:[0150],
名称:“井2”,
样式:{填充:“白色”}
}}};

我想做的是在这个

中,你传递给vectorMap的对象和它里面的
标记
数组的格式错误,缺少括号和闭包。如果你组织代码缩进,这种事情很容易发现

文档和示例都不是很好。下面是我在测试代码时发现的(这发生在他们的一个示例文件中)

另外,在您的案例中,没有提到需要(
wellmap.js

未捕获错误:尝试使用未加载的映射:良好

这是我测试的代码,地图没有呈现任何有意义的东西,正如我用
mall map.js
测试的那样,但是没有出现js错误

<script src="assets/jquery-1.8.2.js"></script>
<script src="../jquery-jvectormap-1.2.2.min.js"></script>
<script src="../jquery-jvectormap.js"></script>
<script src="mall-map.js"></script>
<script>
$(function(){
    $('#pantsun').vectorMap({
        map: 'mall',
        backgroundColor: 'transparent',
        markers: [
            { coords: [0, 50], name: 'well 1', style: {fill: 'white'} },
            { coords: [0, 150], name: 'well 2', style: {fill: 'white'} }
        ] // <-- missing
    });  // <-- mal formed
});     // <-- mal formed
</script>

$(函数(){
$(“#pantsun”).vectorMap({
地图:“购物中心”,
背景色:“透明”,
标记:[
{coords:[0,50],名称:'well 1',样式:{fill:'white'},
{coords:[0150],名称:'well 2',样式:{fill:'white'}

]//传递给vectorMap的对象及其内部的
标记
数组格式错误,缺少括号和闭包。如果组织代码缩进,这种情况很容易发现

文档和示例都不是很好。下面是我在测试代码时发现的(这发生在他们的一个示例文件中)

另外,在您的案例中,没有提到需要(
wellmap.js

未捕获错误:尝试使用未加载的映射:良好

这是我测试的代码,地图没有呈现任何有意义的东西,正如我用
mall map.js
测试的那样,但是没有出现js错误

<script src="assets/jquery-1.8.2.js"></script>
<script src="../jquery-jvectormap-1.2.2.min.js"></script>
<script src="../jquery-jvectormap.js"></script>
<script src="mall-map.js"></script>
<script>
$(function(){
    $('#pantsun').vectorMap({
        map: 'mall',
        backgroundColor: 'transparent',
        markers: [
            { coords: [0, 50], name: 'well 1', style: {fill: 'white'} },
            { coords: [0, 150], name: 'well 2', style: {fill: 'white'} }
        ] // <-- missing
    });  // <-- mal formed
});     // <-- mal formed
</script>

$(函数(){
$(“#pantsun”).vectorMap({
地图:“购物中心”,
背景色:“透明”,
标记:[
{coords:[0,50],名称:'well 1',样式:{fill:'white'},
{coords:[0150],名称:'well 2',样式:{fill:'white'}

]//传递给vectorMap的对象及其内部的
标记
数组格式错误,缺少括号和闭包。如果组织代码缩进,这种情况很容易发现

文档和示例都不是很好。下面是我在测试代码时发现的(这发生在他们的一个示例文件中)

另外,在您的案例中,没有提到需要(
wellmap.js

未捕获错误:尝试使用未加载的映射:良好

这是我测试的代码,地图没有呈现任何有意义的东西,正如我用
mall map.js
测试的那样,但是没有出现js错误

<script src="assets/jquery-1.8.2.js"></script>
<script src="../jquery-jvectormap-1.2.2.min.js"></script>
<script src="../jquery-jvectormap.js"></script>
<script src="mall-map.js"></script>
<script>
$(function(){
    $('#pantsun').vectorMap({
        map: 'mall',
        backgroundColor: 'transparent',
        markers: [
            { coords: [0, 50], name: 'well 1', style: {fill: 'white'} },
            { coords: [0, 150], name: 'well 2', style: {fill: 'white'} }
        ] // <-- missing
    });  // <-- mal formed
});     // <-- mal formed
</script>

$(函数(){
$(“#pantsun”).vectorMap({
地图:“购物中心”,
背景色:“透明”,
标记:[
{coords:[0,50],名称:'well 1',样式:{fill:'white'},
{coords:[0150],名称:'well 2',样式:{fill:'white'}

]//传递给vectorMap的对象及其内部的
标记
数组格式错误,缺少括号和闭包。如果组织代码缩进,这种情况很容易发现

文档和示例都不是很好。下面是我在测试代码时发现的(这发生在他们的一个示例文件中)

另外,在您的案例中,没有提到需要(
wellmap.js

未捕获错误:尝试使用未加载的映射:良好

这是我测试的代码,地图没有呈现任何有意义的东西,正如我用
mall map.js
测试的那样,但是没有出现js错误

<script src="assets/jquery-1.8.2.js"></script>
<script src="../jquery-jvectormap-1.2.2.min.js"></script>
<script src="../jquery-jvectormap.js"></script>
<script src="mall-map.js"></script>
<script>
$(function(){
    $('#pantsun').vectorMap({
        map: 'mall',
        backgroundColor: 'transparent',
        markers: [
            { coords: [0, 50], name: 'well 1', style: {fill: 'white'} },
            { coords: [0, 150], name: 'well 2', style: {fill: 'white'} }
        ] // <-- missing
    });  // <-- mal formed
});     // <-- mal formed
</script>

$(函数(){
$(“#pantsun”).vectorMap({
地图:“购物中心”,
背景色:“透明”,
标记:[
{coords:[0,50],名称:'well 1',样式:{fill:'white'},
{coords:[0150],名称:'well 2',样式:{fill:'white'}
] //