title: Changing Region Colors in JVectorMap with a Button
body: <p>I'm new to jvectormap, but have found it to be awesome.</p>
  
  <p>I have created a map with the following characteristics. When the map loads, about 30 countries have colors applied, either Red, Yellow or Green, based on some score associated with that country (like the percentage of the population that are Duran Duran fans). The rest of the countries are just grey.  (There is some interactivity on the colored regions, like tooltips and clicks.)  When the map is first created, there is a line at the end:</p>
  
  <pre><code>map.series.regions[0].setValues(getColors(currentColor);
  </code></pre>
  
  <p>and currentColor had previously been defined:</p>
  
  <pre><code>var currentColor = "[ALL]";
  </code></pre>
  
  <p>so that all of the colors (red, yellow and green) are shown on the map, and that works.</p>
  
  <p>Beneath the map I want to provide buttons to show just the countries of a given color, like just the red ones.  When the Red button is clicked, just the red countries will be shown in red and the others shown in grey.  Each color would get its own button.</p>
  
  <p>This seems like it would be easy to do.  I have seen the technique used here:  <a href="http://jvectormap.com/examples/random-colors/" rel="nofollow">http://jvectormap.com/examples/random-colors/</a>, where you could click to randomly change the colors and everything else about the map (panning, zooming, etc.) remains intact.  The key part is:</p>
  
  <pre><code>map.series.regions[0].setValues(generateColors());
  </code></pre>
  
  <p>when you have a map constructor like:</p>
  
  <pre><code>map = new jvm.Map({
  </code></pre>
  
  <p>(If your map constructor is like this:  </p>
  
  <pre><code>$('#map').vectorMap({
  </code></pre>
  
  <p>then you would need to do something like this:</p>
  
  <pre><code>var mapObject = $('#map').vectorMap('get', 'mapObject');
  mapObject.series.regions[0].setValues(generateColors());
  </code></pre>
  
  <p>)</p>
  
  <p>I have tried to do exactly that, but with my own getColors(color) method:</p>
  
  <pre><code>map.series.regions[0].setValues(getColors(currentColor));
  </code></pre>
  
  <p>where I regenerate the array of map colors that is passed to setValues(), but there is no change to the map. I know that the array of map colors is correct, because my workaround has been to do the following when the button is pressed:</p>
  
  <p>(1) change the currentColor variable
  (2) empty out the map div container:  $("#map").empty()
  (3) redraw the map from scratch using the constructor and the call to map.series.regions[0].setValues(getColors(currentColor));</p>
  
  <p>The downside of this approach is that any panning or zooming is lost when the map is redrawn from scratch. Is there any step I am missing to get the map to update when I call:  map.series.regions[0].setValues()</p>
  
  <p>Here is a jsfiddle showing how it does not work, unless you redraw the map from scratch:  <a href="http://jsfiddle.net/msalamon/euqyfs7v/10/" rel="nofollow">http://jsfiddle.net/msalamon/euqyfs7v/10/</a></p>
  
  <p>In the jsfiddle, if you call "High Redraw" it shows just the Red countries, but only by redrawing.</p>