Jqvmap Select Region dynamically

321 Views Asked by At

I have a map with Jqvmap plugin, and if we want to select a region by its code, we do:

$('#vmap').vectorMap('set', 'colors', {us: '#ffffff'});
$('#vmap').vectorMap('set', 'colors', {fr: '#ffffff'});

...

But when this code comes from a variable, I do not know how to do:

$('#table td').click(function(){
    var dpt = $(this).text();
    $('#vmap').vectorMap('set', 'colors', {dpt: '#ffffff'});
});
1

There are 1 best solutions below

0
zanzibar On

I found a solution :

$('#table td').click(function(){
 var dpt = $(this).text();
 var color = {[dpt]:"#ffffff"};
 $('#vmap').vectorMap('set', 'colors', color);
});