这是否完成了您正在尝试做的事情?
http://jsfiddle.net/qFHyF/
这个答案建立在我在这里发布的一个问题的答案之上:
jvectormap region colors
JavaScript
(function() {
var myCustomColorsOne = {
'AU-SA': '#4E7387',
'AU-WA': '#333333',
'AU-VIC': '#89AFBF',
'AU-TAS': '#817F8E',
'AU-QLD': '#344B5E',
'AU-NSW': '#344B5E',
'AU-ACT': '#344B5E',
'AU-NT': '#344B5E'
};
var myCustomColorsTwo = {
'AU-SA': '#803300',
'AU-WA': '#993D00',
'AU-VIC': '#B24700',
'AU-TAS': '#CC5200',
'AU-QLD': '#E65C00',
'AU-NSW': '#FF7519',
'AU-ACT': '#FF8533',
'AU-NT': '#FFB280'
};
var myCustomColorsThree = {
'AU-SA': '#B8E186',
'AU-WA': '#B8E186',
'AU-VIC': '#B8E186',
'AU-TAS': '#B8E186',
'AU-QLD': '#B8E186',
'AU-NSW': '#B8E186',
'AU-ACT': '#B8E186',
'AU-NT': '#B8E186'
};
mapOne = new jvm.WorldMap({
map: 'au_merc_en',
container: $('#ausieOne'),
backgroundColor: '#EFF7FF',
series: {
regions: [{
attribute: 'fill'}]
}
});
mapTwo = new jvm.WorldMap({
map: 'au_merc_en',
container: $('#ausieTwo'),
backgroundColor: '#EFF7FF',
colors: '#3377CC',
regionStyle: {
initial: {
fill: '#B8E186'
}
},
series: {
regions: [{
attribute: 'fill'}]
}
});
mapOne.series.regions[0].setValues(myCustomColorsOne);
$("#color-changer").click(function() {
var $that = $(this);
if ($that.hasClass("green")) {
$that.removeClass("green");
mapTwo.series.regions[0].setValues(myCustomColorsTwo);
} else {
$that.addClass("green");
mapTwo.series.regions[0].setValues(myCustomColorsThree);
}
return false;
});
})();
HTML
<a href="#" id="color-changer" class="green">Change colors of Map Two</a>
<p>Map One</p>
<div style="width: 354px; height: 300px" id="ausieOne" data-projection="mill" data-name="au_mill_en"></div>
<p>Map Two</p>
<div style="width: 354px; height: 300px" id="ausieTwo" data-projection="mill" data-name="au_mill_en"></div>