VLT
VLT

Reputation: 195

Javascript + JQuery Vector Maps

Being very (very) new to JavaScript, I am stuck with the following problem when using JQuery VectorMaps:

When I am highlightening a country with this syntax, everything works perfectly:

jQuery('#vmap').vectorMap('set', 'colors', {  'us': '#1caf9a' });

However when I put exactly 'us' into a variable, say country_name like this :

jQuery('#vmap').vectorMap('set', 'colors', {  country_name : '#1caf9a' });

it doesn't work - I don't understand why? when putting alert(country_name) it gives exactly 'us'.

Also country_name cannot be auto-completed in this situation, because of the presence of :

Could anyone please help me ?

Thanks.

Upvotes: 0

Views: 398

Answers (1)

VLT
VLT

Reputation: 195

Actually found the solution ! I am very silly.

Since it is a key-value pair I have to do the following:

var keyval = {}
keyval[country_name] = '#1caf9a' 

and then

jQuery('#vmap').vectorMap('set', 'colors',  keyval);

Upvotes: 1

Related Questions