I'm trying to clear the user-selected region on click. But the selected region won't deselect.
You can toggle empty or not selected but if you have predefined some regions then I can't find a solution to deselect it. onRegionClick detects a click, but I have no idea how to deselect.
Here is my code:
$('#worldMap').vectorMap({
onRegionTipShow: function(event, label, code)
{
label.html(label.html()+' <img src="'+getFlagImgSrc(code)+'" height="12">');
},
onRegionClick: function(event, code) {
console.log(code);
},
regionsSelectable: true,
map: 'world_mill',
backgroundColor: "transparent",
zoomOnScroll: true,
regionStyle: {
selected: {
fill: '#999999'
},
initial: {
fill: '#e4e4e4',
"fill-opacity": 0.9,
stroke: 'none',
"stroke-width": 0,
"stroke-opacity": 0
}
},
series: {
regions: [{
values: mapData,
scale: ["#AAAAAA", "#999999"],
normalizeFunction: 'polynomial'
}]
});