Geochart - How to colorize two regions (different countries) on the same map.

323 views
Skip to first unread message

Oliv Gir

unread,
Jun 1, 2013, 6:11:07 AM6/1/13
to google-visua...@googlegroups.com
Hi
I really would like to colorize two regions (different countries) on the same Geochart map.
For instance, Canada | British Colombia and USA | Florida.
Here is my sample code :



 google.load('visualization', '1', {'packages': ['geochart']});
     google.setOnLoadCallback(drawRegionsMap);

      function drawRegionsMap() {
 var data = new google.visualization.DataTable();
data.addColumn('string', 'Country'); // Implicit domain label col.
data.addColumn('number', 'Value'); // Implicit series 1 data col.
data.addColumn({type:'string', role:'tooltip'}); // 

data.addRows([

[{v:"CA-BC",f:"CA-BC"},150,"some info"],
[{v:"US-FL",f:"US-FL"},350,"some info"],
 
]);
        

      var options = {

   displayMode: 'regions',
   resolution: 'provinces',

   // 021: Nothern America
   region: '021'       

  };



        var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
        chart.draw(data, options);
    };



 google tells me "Requested map does not exist" !!

asgallant

unread,
Jun 1, 2013, 12:21:55 PM6/1/13
to google-visua...@googlegroups.com
There is no province-level map of North America (or any of the other continent-level maps, I suspect), so you can't do what you want in one map.

Oliv Gir

unread,
Jun 1, 2013, 12:34:55 PM6/1/13
to google-visua...@googlegroups.com
Thanks asgallant !
Hope the google team will provide that soon.

I tried the displayMode: 'markers' which allows me to do what i want more or less, but the asynchronous rendering is very slow !
Does not look like a google component .. any idea why it is so slow ?

  google.load('visualization', '1', {'packages': ['geochart']});
     google.setOnLoadCallback(drawRegionsMap);

      function drawRegionsMap() {
 
 var data = new google.visualization.DataTable();
data.addColumn('string', 'Country'); // Implicit domain label col.
data.addColumn('number', 'Value'); // 1 ; 0 public hol / tooltip
data.addColumn('number', 'Value'); // Size of buble
data.addColumn({type:'string', role:'tooltip'}); // 

data.addRows([

[{v:"CA-AB",f:"Alberta"},0,5,"tooltip"],
[{v:"CA-BC",f:"British Columbia"},0,5,"tooltip"],
[{v:"CA-MB",f:"Manitoba"},0,5,"tooltip"],
[{v:"CA-NB",f:"New Brunswick"},0,5,"tooltip"],
[{v:"CA-NL",f:"Newfoundland and Labrador"},0,5,"tooltip"],
[{v:"CA-NT",f:"Northwest Territories"},0,5,"tooltip"],
[{v:"CA-NS",f:"Nova Scotia"},0,5,"tooltip"],
[{v:"CA-NU",f:"Nunavut"},0,5,"tooltip"],
[{v:"CA-ON",f:"Ontario"},0,5,"tooltip"],
[{v:"CA-PE",f:"Prince Edward Island"},0,5,"tooltip"],
[{v:"CA-QC",f:"Quebec"},0,5,"tooltip"],
[{v:"CA-SK",f:"Saskatchewan"},0,5,"tooltip"],
[{v:"CA-YT",f:"Yukon"},0,5,"tooltip"],
[{v:"US-AL",f:"Alabama"},0,5,"tooltip"],
[{v:"US-AK",f:"Alaska"},0,5,"tooltip"],
[{v:"US-AZ",f:"Arizona"},0,5,"tooltip"],
[{v:"US-AR",f:"Arkansas"},0,5,"tooltip"],
[{v:"US-CA",f:"California"},0,5,"tooltip"],
[{v:"US-CO",f:"Colorado"},0,5,"tooltip"],
[{v:"US-CT",f:"Connecticut"},0,5,"tooltip"],
[{v:"US-DE",f:"Delaware"},0,5,"tooltip"],
[{v:"US-DE",f:"District of Columbia"},0,5,"tooltip"],
[{v:"US-FL",f:"Florida"},0,5,"tooltip"],
[{v:"US-GA",f:"Georgia"},0,5,"tooltip"],
[{v:"US-HI",f:"Hawaii"},0,5,"tooltip"],
[{v:"US-ID",f:"Idaho"},0,5,"tooltip"],
[{v:"US-IL",f:"Illinois"},0,5,"tooltip"],
[{v:"US-IN",f:"Indiana"},0,5,"tooltip"],
[{v:"US-IA",f:"Iowa"},0,5,"tooltip"],
[{v:"US-KS",f:"Kansas"},0,5,"tooltip"],
[{v:"US-KY",f:"Kentucky"},0,5,"tooltip"],
[{v:"US-LA",f:"Louisiana"},0,5,"tooltip"],
[{v:"US-ME",f:"Maine"},0,5,"tooltip"],
[{v:"US-MD",f:"Maryland"},0,5,"tooltip"],
[{v:"US-MA",f:"Massachusetts"},0,5,"tooltip"],
[{v:"US-MI",f:"Michigan"},0,5,"tooltip"],
[{v:"US-MN",f:"Minnesota"},0,5,"tooltip"],
[{v:"US-MS",f:"Mississippi"},0,5,"tooltip"],
[{v:"US-MO",f:"Missouri"},0,5,"tooltip"],
[{v:"US-MT",f:"Montana"},0,5,"tooltip"],
[{v:"US-NE",f:"Nebraska"},0,5,"tooltip"],
[{v:"US-NV",f:"Nevada"},0,5,"tooltip"],
[{v:"US-NH",f:"New Hampshire"},0,5,"tooltip"],
[{v:"US-NJ",f:"New Jersey"},0,5,"tooltip"],
[{v:"US-NM",f:"New Mexico"},0,5,"tooltip"],
[{v:"US-NY",f:"New York"},0,5,"tooltip"],
[{v:"AU-ACT",f:"Australian Capital Territory"},0,5,"tooltip"],
[{v:"AU-NSW",f:"New South Wales"},0,5,"tooltip"],
[{v:"AU-NT",f:"Northern Territory"},0,5,"tooltip"],
[{v:"AU-QLD",f:"Queensland"},0,5,"tooltip"],
[{v:"AU-SA",f:"South Australia"},0,5,"tooltip"],
[{v:"AU-TAS",f:"Tasmania"},0,5,"tooltip"],
[{v:"AU-VIC",f:"Victoria"},0,5,"tooltip"],
[{v:"AU-WA",f:"Western Australia"},0,5,"tooltip"],
 

]);
        

     var options = {
legend: 'none',
        displayMode: 'markers',
   // 021: Nothern America
   region: 'world' ,      
      colorAxis: {
colors:['green', 'green'] },
sizeAxis: {minValue: 1, maxValue:10,minSize:1,  maxSize: 10}
  };


        var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
        chart.draw(data, options);
    };

asgallant

unread,
Jun 1, 2013, 12:46:46 PM6/1/13
to google-visua...@googlegroups.com
At a guess, I would say it is probably due to the geocoding service.  Geocoding a large batch of data or having a slow connection to the geocoding server can cause performance issues in the GeoCharts.
Reply all
Reply to author
Forward
0 new messages