我不是 jQuery 人,但在实现 jVectormap 时,我在地图最初加载时包含了一个 onRegionOver 函数。但是,它似乎只触发一次,即#content div 的内容正确显示一次,但在将光标移动到其他状态时仍然存在。我错过了什么?TIA。
<script>
$(function(){
$('.jvectormap').vectorMap({
map: 'us_en',
values: associateData,
scaleColors: ['#C8EEFF', '#0071A4'],
normalizeFunction: 'polynomial',
hoverOpacity: 0.7,
hoverColor: false,
onLabelShow: function(e, el, code){
el.html('<strong>'+el.html()+'</strong><br />'+associateData[code]);
},
onRegionOver: function(e, code){
$("#content").replaceWith(contentData[code]);
},
markers: [
{latLng: [43.30, -75.61], name: 'Dans Automotive, Taberg NY', r: 3, fill: 'yellow'},
{latLng: [41.16, -95.93], name: 'Yecks Auto Repair, Bellevue NE', r:3, fill: 'yellow'},
{latLng: [41.36, -81.85], name: 'Parkway Express, Berea OH', r:3, fill: 'yellow'},
{latLng: [41.31, -81.83], name: 'Strongsville Express, Strongsville OH', r:3, fill: 'yellow'},
{latLng: [41.34, -81.53], name: 'Nordonia Tire & Service, Northfield OH', r:3, fill: 'yellow'}
],
onMarkerLabelShow: function(event, label, index){
console.log('label-show', label, index);
},
onMarkerOver: function(event, index){
console.log('marker-over', index);
},
onMarkerOut: function(event, index){
console.log('marker-out', index);
},
onMarkerClick: function(event, index){
var url = "http://www.google.com";
$(location).attr('href',url);
}
});
})
</script>