Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically change object property

I'm using jVectorMaps. I have a map object with a backgroundColor property:

map = new jvm.Map({
    container: $('#map'),
    map: "world_mill_en,
    backgroundColor: bgcolor

Let's say I declare a global bgcolor variable. Then, I change the value of that variable at some point:

function changeBGcolor() {
    bgcolor = "yellow";
}

The idea is that the jVectorMap background color changes when I change the value of the bgcolor variable. So far I was not able to do it.

How can it be done?

like image 790
codeWolf Avatar asked Oct 19 '22 12:10

codeWolf


1 Answers

You should use setBackgroundColor(). i.e.

var bgColor = "red";
var map = new jvm.Map({
  container: $('#map'),
  map: 'world_mill_en',
  backgroundColor: bgColor
});

bgColor = "yellow";

map.setBackgroundColor(bgColor);

See the documentation here for more information.

like image 162
Seer Avatar answered Oct 27 '22 10:10

Seer