我正在尝试自定义此地图:http: //jsfiddle.net/allankiezel/FJrNN/
我不能做的是:
- 在鼠标悬停时显示每个状态的名称或缩写
- 将每个状态链接到一个单独的 URL(而不是在点击时将其变为绿色)
负责地图行为的 JS 代码:
var rsrGroups = [CA, OR, WA, NV, AZ, ID, UT, MT, WY, NM, CO, TX, NE, SD, ND, OK, KS, MN, IA, MO, AR, LA, WI, IL, MS, TN, KY, IN, AL, MI, FL, OH, GA, NC, VA, WV, SC, PA, MD, NJ, DE, VT, MA, CT, NH, ME, RI, NY, AK, HI];
for (var i = 0, len = rsrGroups.length; i <= len; i++) {
var el = rsrGroups[i];
el.mouseover(function() {
this.toFront();
this.attr({
cursor: 'pointer',
fill: '#990000',
stroke: '#fff',
'stroke-width': '2'
});
this.animate({
scale: '1.2'
}, 200);
});
el.mouseout(function() {
this.animate({
scale: '1.05'
}, 200);
this.attr({
fill: '#003366'
});
});
el.click(function() {
this.animate({
fill: 'green'
}, 200);
});
}