修改jquery-maphilight.min.js源码添加click事件
源码中的修改
if(b.trigger === 'click') L(T);
if(O.trigger === 'click'){
F(Q).trigger("alwaysOn.maphilight").find("area[coords]").bind("click.maphilight", X);
}else if(O.trigger === 'mouse'){
F(Q).trigger("alwaysOn.maphilight").find("area[coords]").bind("mouseover.maphilight", X).bind("mouseout.maphilight",
function(Z) {
L(T)
});
}
F.fn.maphilight
U.before(T);
U.addClass("maphilighted")
return new Object({
hilightDom: function(dom){
if(O.trigger === 'click'){
F(dom).trigger('click.maphilight');
}else if(O.trigger === 'mouse'){
F(dom).trigger('mouseover.maphilight');
}
}
})
F.fn.maphilight.defaults = {
fill: true,
fillColor: "000000",
fillOpacity: 0.2,
stroke: true,
strokeColor: "ff0000",
strokeOpacity: 1,
strokeWidth: 1,
fade: true,
alwaysOn: false,
neverOn: false,
groupBy: false,
wrapClass: true,
trigger: 'mouse',
callback: function(e){}
}
由于使用的压缩版js,可能可读性较差(贴图)

HTML代码片段
<!--使用高版本jquery请调用jquery-migrate-1.2.1.min.js,低版本可不用-->
<script type="text/javascript" src="./js/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="./js/jquery-maphilight.min.js"></script>
<script>
$.fn.maphilight.defaults = {
fill: true,
fillColor: 'F7D315',
fillOpacity: 0.7,
stroke: true,
strokeColor: 'ff8b19',
strokeOpacity: 1,
strokeWidth: 3,
fade: true,
alwaysOn: false,
neverOn: false,
groupBy: false
}
var maphilight = $("#map_image").maphilight({
trigger: 'click',
callback: function(e){
console.log(this);
console.log(e);
$(".mapPath").hide();
$(this).next().show();
}
});
$('.city-navs a').click(function(){
var area_id = $(this).attr('area_id');
maphilight.hilightDom($('.mapBtn[area_id="'+area_id+'"]'));
})
</script>
图示(如下)
