谷歌地理广告使可点击的国家和改变所选国家的颜色

时间:2018-04-04 04:30:32

标签: google-maps google-visualization google-geocoding-api

我正在使用Google的geochart为我的网站,但我希望这些国家/地区可以点击。当我点击一个国家/地区时,它的颜色会被更改并在选择其他国家时保持选中状态。

我需要像下面的网址一样制作geochart:

HTML

 google.charts.load('current', {
    'packages':['geochart'],
    // Note: you will need to get a mapsApiKey for your project.
    // See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings
    'mapsApiKey': 'AIzaSyD-9tSrke72PouQMnMX-a7eZSW0jkFMBWY'
  });
  google.charts.setOnLoadCallback(drawRegionsMap);

  function drawRegionsMap() {
    var data = google.visualization.arrayToDataTable([
      ['Country', 'Popularity'],
      ['Germany', 200],
      ['United States', 300],
      ['Brazil', 400],
      ['Canada', 500],
      ['France', 600],
      ['RU', 700],
      ['India', 700]
    ]);

    var options = {};

    var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));

    chart.draw(data, options);
  }

JS

import java.util.Arrays;

for (int i = 0; i < myDouble.length; ++i) 
    Arrays.sort(myDouble[i]);

JS FIDDLE

Selecting countries on a map

0 个答案:

没有答案