dimanche 26 janvier 2014

l'API Geochart de Google se charge trop lentement

Vous avez sûrement remarqué que l'API Google Geochart est très longue au chargement, si toutes vos zones géographiques sont colorées.
Cette API se charge de manière asynchrone, pays par pays.
Google propose une autre API, qui se nomme Geomap (basée sur du Flash), et qui se charge plus rapidement que Geochart.

Elle est disponible à l'adresse :
https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr

Voici un exemple de carte qui utilise l'API Geomap de Google :
http://temperatures-moyennes.fr/janvier.php



Et voici le code utilisé pour créer cette page :

  <script type='text/javascript' src='https://www.google.com/jsapi'></script>
  <script type='text/javascript'>
   google.load('visualization', '1', {'packages': ['geomap']});
   google.setOnLoadCallback(drawMap);

    function drawMap() {
      var data = google.visualization.arrayToDataTable([
        ['Country', 'Temperature'],
          ['Afghanistan', 4],
          ['South Africa', 21],
          ['Albania', 7],
          ['Algeria', 12],
          ['Germany', -1],
          ['Angola', 26],
          ['Saudi Arabia', 14],
          ['Argentina', 30],
          ['Armenia', -5.5],
          ['Australia', 22],
          ['Austria', -1],
          ['Azerbaijan', 3],
          ['Bahamas', 21],
          ['Bangladesh', 18],
          ['Belau', -7],
          ['Belgium', 3],
          ['Belize', 23],
          ['Benin', 27],
          ['Bhutan', 24],
          ['Belarus', -7],
          ['Burma', 24],
          ['Bolivia', 18],
          ['Bosnia and Herzegovina', -0.5],
          ['Botswana', 26],
          ['Brazil', 30],
          ['Brunei', -2],
          ['Bulgaria', -2],
          ['Burkina Faso', 25],
          ['Burundi', 23],
          ['Cambodia', 26],
          ['Cameroon', 24],
          ['Canada', -10],
          ['Cape Verde', 22],
          ['Chile', 21],
          ['China', -5],
          ['Cyprus', 10],
          ['Colombia', 14],
          ['Comoros', 27],
          ['CG', 26],
          ['Cook', 26],
          ['North Korea', 10.5],
          ['South Korea', 12],
          ['Costa Rica', 19],
          ['Ivory coast', 27],
          ['Croatia', 8],
          ['Cuba', 21],
          ['Denmark', 1],
          ['Djibouti', 25],
          ['Egypt', 12],
          ['united arab emirates', 19],
          ['ecuador', 14],
          ['eritrea', 14],
          ['Spain', 5],
          ['Estonia', -5],
          ['United states', 0],
          ['Ethiopia', 15],
          ['Falkland', 9],
          ['Faroe', 3],
          ['Fiji', 27],
          ['Finland', -6],
          ['France', 3],
          ['Gabon', 27],
          ['Gambia', 23],
          ['Georgia', 1],
          ['Ghana', 27],
          ['Gibraltar', 13],
          ['britain', 5],
          ['Greece', 9],
          ['Greenland', -9],
          ['Guadeloupe', 24],
          ['Guam', 26],
          ['Guatemala', 16],
          ['Guinea', 27],
          ['Guinea -Bissau', 25],
          ['equatorial Guinea', 25],
          ['Guyana', 26],
          ['French Guiana', 26],
          ['Haiti', 25],
          ['Hawai', 22],
          ['Holland', 2],
          ['Honduras', 19],
          ['Hungary', -1],
          ['cook islands', 26],
          ['falkland islands', 6],
          ['tonga island', 26],
          ['U.S. Virgin Islands', 26],
          ['India', 21],
          ['Indonesia', 25],
          ['Iran', 5],
          ['Iraq', 9],
          ['Ireland', 5],
          ['Iceland', 0],
          ['Israel', 14],
          ['Italy', 8],
          ['Jamaica', 26],
          ['Japan', 4],
          ['Jordan', 8],
          ['Kazakhstan', -16.5],
          ['Kenya', 18],
          ['Kyrgyzstan', -3.6],
          ['Kiribati', 28],
          ['XK', -2],
          ['Kuwait', 14],
          ['Laos', 22],
          ['Lesotho', 23],
          ['Latvia', -5],
          ['Lebanon', 13],
          ['Liberia', 26.5],
          ['Libya', 14],
          ['Liechtenstein', 0],
          ['Lithuania', -5.5],
          ['Luxembourg', 1],
          ['Macao', 15],
          ['Macedonia', 0],
          ['Madagascar', 21],
          ['Madeira', 16],
          ['Malaysia', 26],
          ['Malawi', 22],
          ['Mali', 25],
          ['Morocco', 11],
          ['Martinique', 24],
          ['Mauritania', 21],
          ['Mexico', 19],
          ['Micronesia', 27],
          ['Moldova', 9.5],
          ['Mongolia', -19],
          ['montenegro', 5.5],
          ['Mozambique', 26],
          ['Myanmar', 24],
          ['Namibia', 23],
          ['Nauru', 28],
          ['Nepal', 10],
          ['Nicaragua', 26],
          ['Niger', 24],
          ['Nigeria', 27],
          ['Norway', -5],
          ['new caledonia', 26],
          ['New Zealand', 20],
          ['Oman', 22],
          ['Uganda', 23],
          ['Uzbekistan', 0.9],
          ['Pakistan', 19],
          ['palau', 27],
          ['Panama', 27],
          ['Papua New Guinea', 28],
          ['Paraguay', 27],
          ['Netherlands', 2],
          ['Peru', 22],
          ['Philippines', 25],
          ['Poland', -2],
          ['French Polynesia', 30],
          ['Portugal', 11],
          ['puerto rico', 24],
          ['Qatar', 17],
          ['CF', 25],
          ['CD', 26],
          ['Dominican Republic', 24],
          ['Czech Republic', 7],
          ['reunion', 26],
          ['Romania', -3],
          ['united kingdom', 5],
          ['Russia', -11],
          ['Rwanda', 20.5],
          ['Western Sahara', 21],
          ['Solomon', 27],
          ['Salvador', 23],
          ['Western Samoa', 27],
          ['Sao Tome and Principe', 26],
          ['Senegal', 21],
          ['Serbia', 0],
          ['Seychelles', 27],
          ['Sierra Leone', 27],
          ['Singapore', 27],
          ['Slovakia', -1],
          ['Slovenia', -1],
          ['Somalia', 27],
          ['Sudan', 23],
          ['SS', 28],
          ['Sri Lanka', 27],
          ['sweden', -3],
          ['Switzerland', 0],
          ['Suriname', 26],
          ['SJ', -14.7],
          ['Swaziland', 26],
          ['Syria', 7],
          ['Tajikistan', 3],
          ['Tanzania', 24],
          ['Taiwan', 15],
          ['Chad', 23],
          ['Thailand', 26],
          ['Togo', 27],
          ['Tonga', 26],
          ['Tunisia', 11],
          ['Turkmenistan', 2.5],
          ['Turkey', 5],
          ['Tuvalu', 28],
          ['Ukraine', -6],
          ['Uruguay', 23],
          ['Venezuela', 15],
          ['Vietnam', 26],
          ['Yemen', 26],
          ['Yugoslavia', 0],
          ['Zambia', 22],
          ['Zimbabwe', 20],

      ]);


         var options = {};
        options['colors'] = [0xeeeeee, 0xf8f503, 0xd70909];
          options['dataMode'] = 'regions';
          options['width'] = '700px';
          options['height'] = '450px';
     
     
      var container = document.getElementById('map_canvas');
      var geomap = new google.visualization.GeoMap(container);
      geomap.draw(data, options);
  };
  </script>

Aucun commentaire:

Enregistrer un commentaire