Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQVMAP Country Coloring

I am using JQVMAP at here. When I have a country that has members I desire to change that country's color without mousing over it, as the map is displayed.

I am using the following sql to get the countries and the number of their members. My question is what do I do, once I have a country, to change that countries map color? All countries will have the same color.

$result=mysql_query("SELECT COUNT(profile3.organizations) total_org, LEFT(countryCODEconversions.Code, 2) FROM profile3, countryCODEconversions WHERE TRIM(MID(countryCODEconversions.Code, 4, 147)) = profile3.country GROUP by profile3.country"); //if(mysql_num_rows($result)>0){ $counter = ""; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach ($line as $value) { $counter += 1; $value = stripslashes($value); if ($counter == 1){$total = nl2br($value);} if ($counter == 2){ $counter = 0; $countryCode = strtolower($value); ?> gdpOrgData['<?=$countryCode?>']=("<?=$total?>"); <?

like image 241
James S. Null Avatar asked Sep 29 '22 22:09

James S. Null


1 Answers

Normaly, after loading the map you can set the color of countries that need a different color like this:

jQuery(document).ready(function() {
       jQuery('#vmap').vectorMap('set', 'colors', {lt: '#8c9622', 
                                                    sv: '#8c9622', 
                                                    yr: '#8c9622'});
});

You could use PHP to generate the list in this script. Just make sure to load it after the map is loaded. I hope this points you in the correct direction.

like image 59
Lexib0y Avatar answered Oct 07 '22 19:10

Lexib0y