jvectormap markers label image

javascript, jquery, jvectormap

Solution

You can add an extra property `image` for each marker that you can retrieve when hovering a marker.

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

Problem

does anyone know how to add two different images to two different marker's labels? ``` $('#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()); } }); ``` this displays the same image on both markers

Original source