【问题标题】:jvectormap markers label imagejvectormap 标记 标签 图像
【发布时间】:2013-12-07 03:11:27
【问题描述】:

有谁知道如何将两个不同的图像添加到两个不同的标记标签上?

$('#map').vectorMap({
    markerStyle: {
      initial: {
        fill: '#F8E23B',
        stroke: '#383f47'
      }
    },
    backgroundColor: '#383f47',
    markers: [
      {latLng: [46.90, 8.45], name: "Italy"},
      {latLng: [26.02, 50.55], name: 'Bahrain'},
    ],
    onMarkerLabelShow: function(event, label, code) {
     label.html("<img src=\"img/logo.png\"><br>"+ label.html());                
    }
});

这会在两个标记上显示相同的图像

【问题讨论】:

    标签: javascript jquery jvectormap


    【解决方案1】:

    您可以为悬停标记时可以检索的每个标记添加额外的属性image

    var markers = [
        { latLng: [46.90, 8.45], name: "Italy", image: 'italy.png' },
        { latLng: [26.02, 50.55], name: 'Bahrain', image: 'bahrain.png' },
    ];
    
    $('#map').vectorMap({
        markerStyle: {
          initial: {
            fill: '#F8E23B',
            stroke: '#383f47'
          }
        },
        backgroundColor: '#383f47',
        markers: markers,
        onMarkerLabelShow: function(event, label, index) {
         label.html('<img src="img/' + markers[index].image + '"><br />' + label.html());                
        }
    });
    

    【讨论】:

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