I'm having weird problems with datamaps updateCloropleth
function. I followed this example :
https://github.com/markmarkoh/datamaps/releases/tag/v0.2.2
Here is an example of my problem. When I do this:
map.updateChoropleth({
"AFG": colorx
});
The color updates. However, when I do this:
var countryx = "AFG";
map.updateChoropleth({
countryx: colorx
});
It doesn't work.
I've checked that countryx == "AFG"
returns true
, so it's definitely the same value. The variable colorx
can be passed fine, but passing the variable countryx
as a key seems to break the function.
Any ideas how or why this is happening?
You can try this:
var colorx = 100;
var countryx = "AFG";
var countryColor = {};
countryColor["AFG"] = colorx;
map.updateChoropleth(countryColor);
See this thread - basically your problem stems from the fact that these two statements are the same:
var obj = {"countryx": colorx}
var obj = {countryx: colorx}