jvectormap标记标签图像 [英] jvectormap markers label image
本文介绍了jvectormap标记标签图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人知道如何将两个不同的图像添加到两个不同的标记标签?
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
推荐答案
您可以为悬停标记时可以检索的每个标记添加额外的属性图像
。
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());
}
});
这篇关于jvectormap标记标签图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文