【问题标题】:Adding a Marker to jVectorMap向 jVectorMap 添加标记
【发布时间】:2013-03-17 18:51:24
【问题描述】:

所以,

我已经设法使用 jVectorMap 插件显示自定义地图,并且我正在尝试添加自定义标记,但是当我按照此处的示例进行操作时:http://jvectormap.com/examples/mall/ 没有任何反应。我只是在代码中遗漏了一些简单的东西吗?

这是我在添加标记之前的代码:

 //@code_start
      $(function(){
        $('#usmxmap').vectorMap({
          map: 'map',
          regionsSelectable: false,
          markersSelectableOne: true,
          backgroundColor: '#cfdbdd',
          regionStyle: {
            initial: {
      fill: '#5e7073',
      "fill-opacity": 1,
      stroke: 'none',
      "stroke-width": 0,
      "stroke-opacity": 1
      },
      hover: {
      fill: 'black'
      },
      selected: {
      fill: 'yellow'
      },
      selectedHover: {
      }
      },
        });
      });
      //@code_end

产生的 JsFiddle: http://jsfiddle.net/73aze/5/

这是我必须添加的标记:

//@code_start
      $(function(){
        $('#usmxmap').vectorMap({
          map: 'map',
          regionsSelectable: false,
          markersSelectableOne: true,
          backgroundColor: '#cfdbdd',
          markers: [{
          coords: [60, 110],
          name: 'Escalator 1',
          style: {fill: 'yellow'}
          }],
          regionStyle: {
            initial: {
      fill: '#5e7073',
      "fill-opacity": 1,
      stroke: 'none',
      "stroke-width": 0,
      "stroke-opacity": 1
      },
      hover: {
      fill: 'black'
      },
      selected: {
      fill: 'yellow'
      },
      selectedHover: {
      }
      },
        });
      });
      //@code_end

正如您从 jsFiddle (http://jsfiddle.net/Z9u4T/3/) 中看到的那样,这只会导致地图消失,我无法确定我错过了什么。有什么想法吗?

马卡

【问题讨论】:

  • Uncaught TypeError: Cannot read property 'centralMeridian' of undefined - 这对你有什么意义吗?我之前没用过这个插件,但是控制台报错了。

标签: jquery jquery-plugins vector jvectormap


【解决方案1】:

}, }); }); //@code_end

必须

} }); }); //@code_end

【讨论】:

    【解决方案2】:

    你的jsfiddles 有点乱。 试试this jsfiddle

    这是你的modified second jsfiddle。从 github 导入 raw 显然是个问题。我在 jvectormap 的网页上链接到 jquery-jvectormap-1.2.2.min.js,现在它可以工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多