jvectormap活动区域指定颜色

时间:2015-09-22 19:04:55

标签: jquery jvectormap

我有一个带有类似

的数组的地图
var stateHTML = {
    "US-VA": {"location": "Virginia"},
    "US-PA": {"location": "Pennsylvania"},
    "US-TN": {"location": "Tennessee"},
    "US-WV": {"location": "West Virginia"},
    "US-NV": {"location": "Nevada"},
    //"US-TX": {"location": "Texas"},
    "US-NH": {"location": "New Hampshire"},
    "US-NY": {"location": "New York"},
    "US-HI": {"location": "Hawaii"},
    "US-VT": {"location": "Vermont"},
    "US-NM": {"location": "New Mexico"},
    "US-NC": {"location": "North Carolina"},
    "US-ND": {"location": "North Dakota"},
    "US-NE": {"location": "Nebraska"},
    "US-LA": {"location": "Louisiana"},
    "US-SD": {"location": "South Dakota"},
    "US-DC": {"location": "District of Columbia"},
    "US-DE": {"location": "Delaware"},
    "US-FL": {"location": "Florida"},
    "US-CT": {"location": "Connecticut"},
    "US-WA": {"location": "Washington"},
    "US-KS": {"location": "Kansas"},
    "US-WI": {"location": "Wisconsin"},
    "US-OR": {"location": "Oregon"},
    "US-KY": {"location": "Kentucky"},
    "US-ME": {"location": "Maine"},
    "US-OH": {"location": "Ohio"},
    "US-OK": {"location": "Oklahoma"},
    "US-ID": {"location": "Idaho"},
    "US-WY": {"location": "Wyoming"},
    "US-UT": {"location": "Utah"},
    "US-IN": {"location": "Indiana"},
    "US-IL": {"location": "Illinois"},
    "US-AK": {"location": "Alaska"},
    "US-NJ": {"location": "New Jersey"},
    "US-CO": {"location": "Colorado"},
    "US-MD": {"location": "Maryland"},
    "US-MA": {"location": "Massachusetts"},
    "US-AL": {"location": "Alabama"},
    "US-MO": {"location": "Missouri"},
    "US-MN": {"location": "Minnesota"},
    "US-CA": {"location": "California"},
    "US-IA": {"location": "Iowa"},
    "US-MI": {"location": "Michigan"},
    "US-GA": {"location": "Georgia"},
    "US-AZ": {"location": "Arizona"},
    "US-MT": {"location": "Montana"},
    "US-MS": {"location": "Mississippi"},
    "US-SC": {"location": "South Carolina"},
    "US-RI": {"location": "Rhode Island"},
    "US-AR": {"location": "Arkansas"},
};

然后我使用该系列作为我的活动区域并使用特定颜色

series: {
        fill: '#0071A4',            
         regions: [{              
          fill: '#0071A4',
          attribute: 'fill',
          values: stateHTML
        }]
    }

我已经尝试了所有内容来阅读var stateHTML并使用系列中指定的颜色,但似乎没有任何效果。

这是一个工作小提琴,可以看到完整的代码

http://jsfiddle.net/abennington/ymgkkuzL/168/

非常感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

您的series声明不是100%正确,您应该像这样使用

series: {           
    regions: [{           
        scale: ['#0071A4'],
        values: activeRegions
    }]
}

您的activeRegions列表应该只包含区域代码和数值

var activeRegions = {
     'US-VA': 1,
     'US-PA': 1,
     'US-WY': 1
     // other regions
};

http://jsfiddle.net/8L3w0163/