英国地区在谷歌Geocharts [英] UK Regions in Google Geocharts

查看:72
本文介绍了英国地区在谷歌Geocharts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为我们的网站实施Geo Chart热图,但它们在英国显示区域方面有局限性,他们只能列出4个地区,英格兰,苏格兰,威尔士和北爱尔兰,但不会超过这个范围。任何人都可以帮助我知道我们是否可以列出英国的所有地区,以及我们是否可以向英国的这些地区展示城市,县以及普雷斯顿等。我们可以通过多于3个参数来显示鼠标悬停的更多数据。

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

var chart;
var data;
var options;

google.setOnLoadCallback(drawRegionsMap);

函数drawRegionsMap(){
data = google.visualization.arrayToDataTable([

['Region','Popularity','Total Votes'],

$ b ['England',8,6],
['Scotland',8,6],
['Wales',9,7],
['Northern Ireland',2,5],

['United Kingdom',2,4]

]);

var maxV = 5; //确保两端的比例相等。
var minV = maxV * -1;

options = {
colorAxis:{colors:['blue','white','red'],minValue:minV,maxValue:maxV},
};

chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
chart.draw(data,options);
google.visualization.events.addListener(图表,'regionClick',selectHandler);
};

函数selectHandler(e){
var selection = e ['region'];
//警报(选择);
options ['resolution'] ='省份';
options ['region'] =选择;
chart.draw(data,options);
document.getElementById('goback')。style.display ='block';
};

< / script>

正如你所看到的,只有3个参数,我们可以传递额外的参数吗?或者任何工具提示。



提前致谢

解决方案

简短回答:不,您不能展示比英格兰,威尔士,苏格兰和北爱尔兰更具体的部门。



Google地图目前没有更具体的地图,所以您无法使用geocharts对其进行映射。



如果您想显示城市,可以使用 marker mode 来显示它们。如果您确实想要显示英国所有ISO-3166-2区域您唯一的选择是在标记模式下为每个坐标创建坐标,然后将其编码为圆形而不是阴影区域。



就显示更多工具提示而言,你可以添加一个工具提示列来显示你的内心需求(注意:不允许回车):
$ b $ pre $函数drawVisualization() {
data = new google.visualization.DataTable();
data.addColumn('string','Region');
data.addColumn('数字','人气');
data.addColumn('数字','总票数');
data.addColumn({type:'string',role:'tooltip'},'ToolTip');
data.addRows([
['England',8,6,'This is England'],
['Scotland',8,6,'This is Scotland'],
['Wales',9,7,'This is Wales'],
['Northern Ireland',2,5,'这是北爱尔兰'],
['英国' ,2,4,'这是英国']
]);

var maxV = 5; //确保两端的比例相等。
var minV = maxV * -1;

options = {
colorAxis:{colors:['blue','white','red'],minValue:minV,maxValue:maxV},
};

chart = new google.visualization.GeoChart(document.getElementById('visualization'));
chart.draw(data,options);
google.visualization.events.addListener(图表,'regionClick',selectHandler);
}

函数selectHandler(e){
var selection = e ['region'];
//警报(选择);
options ['resolution'] ='省份';
options ['region'] =选择;
chart.draw(data,options);
//document.getElementById('goback').style.display='block';
};

未来, HTML工具提示也可能会受到支持,但即使在实验1.1版本中,它们目前也未启用geocharts。


We are implementing Geo Chart heat Map for our website, but they have limitations to display regions for UK, they can list only 4 Regions only, England, Scotland, Wales and Northern Ireland and Not more than that. Can anyone help me to know if we can list all regions for UK and also if we can show cities, counties under those regions in UK as well like Preston etc.

Also can we pass more then 3 parameters to show more data on mouse over.

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

     var chart; 
     var data;
     var options;   

     google.setOnLoadCallback(drawRegionsMap);

      function drawRegionsMap() {
        data = google.visualization.arrayToDataTable([

          ['Region', 'Popularity', 'Total Votes'],


          ['England', 8, 6],
          ['Scotland', 8, 6],
          ['Wales ', 9, 7],
          ['Northern Ireland', 2, 5],

          ['United Kingdom', 2, 4]

        ]);

        var maxV = 5;  // to ensure scale is equal on both ends.
        var minV = maxV*-1;

        options =   { 
        colorAxis: {colors: ['blue', 'white', 'red'], minValue: minV, maxValue: maxV},
            };

        chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
        chart.draw(data, options);
    google.visualization.events.addListener(chart, 'regionClick', selectHandler);
    };

function selectHandler(e) {
    var selection = e['region'];
    //alert(selection);
        options['resolution'] = 'provinces';
        options['region'] = selection;
            chart.draw(data, options);
            document.getElementById('goback').style.display='block';
    };

    </script>

As you can see, only 3 parameters, can we pass extra parameters? or any tool tip for it.

thanks in advance

解决方案

Short answer: no you cannot display any more specific divisions than England, Wales, Scotland, and Northern Ireland.

Google Maps does not have any more specific maps currently available, so you aren't going to be able to map it using geocharts.

If you want to show cities, you could use the marker mode to display them. If you do want to show all the ISO-3166-2 regions for the UK your only choice is to create coordinates in marker mode for each of them, and then code them in as circles, not shaded regions.

As far as showing more tooltips is concerned, you can add a ToolTip column to display whatever your heart desires (caveat: no carriage returns allowed):

function drawVisualization() {
  data = new google.visualization.DataTable();
  data.addColumn('string', 'Region');
  data.addColumn('number', 'Popularity');
  data.addColumn('number', 'Total Votes');
  data.addColumn({type: 'string', role: 'tooltip'}, 'ToolTip');
  data.addRows([
    ['England', 8, 6, 'This is England'],
    ['Scotland', 8, 6, 'This is Scotland'],
    ['Wales ', 9, 7, 'This is Wales'],
    ['Northern Ireland', 2, 5, 'This is Northern Ireland'],
    ['United Kingdom', 2, 4, 'This is the UK']
  ]);

  var maxV = 5;  // to ensure scale is equal on both ends.
  var minV = maxV*-1;

  options =   {
    colorAxis: {colors: ['blue', 'white', 'red'], minValue: minV, maxValue: maxV},
  };

  chart = new google.visualization.GeoChart(document.getElementById('visualization'));
  chart.draw(data, options);
  google.visualization.events.addListener(chart, 'regionClick', selectHandler);
}

function selectHandler(e) {
  var selection = e['region'];
  //alert(selection);
  options['resolution'] = 'provinces';
  options['region'] = selection;
  chart.draw(data, options);
  //document.getElementById('goback').style.display='block';
};

In the future, HTML ToolTips will also likely be supported, but even in the experimental 1.1 version, they aren't currently enabled for geocharts.

这篇关于英国地区在谷歌Geocharts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆