簡體   English   中英

jvectormap標記標簽圖像

[英]jvectormap markers label image

有誰知道如何將兩個不同的圖像添加到兩個不同的標記的標簽?

$('#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());                
    }
});

這會在兩個標記上顯示相同的圖像

您可以為懸停標記時可以檢索的每個標記添加額外的屬性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());                
    }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM