更改Google地图GeoChart的中心 [英] Change center of Google Map GeoChart

查看:91
本文介绍了更改Google地图GeoChart的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与海洋科学家合作,他们从海岸带取样。我想改变海图的中心位置。我想给出图表中心的纬度/经度对,或者地图区域的窗口/视图的两个纬度/经度对,或者指定多个状态,如US-CT-NY。我希望有一个隐藏的API像 geochart.center = {lat:89,long:-127}

  function drawVisualization(){
var data = google.visualization.arrayToDataTable([
['Lat','Long','Popularity'],

[41.083333333276,-73.39999999978,20.4],
[41.083333333276,-73.39999999978,20.6],
[41.099550000113,-73.415400000078,19.0]
]);

var options = {title:'Temperature',region:'US-CT',resolution:'metros',width:556,height:347};
var geochart = new google.visualization.GeoChart(
document.getElementById('visualization'));
geochart.draw(data,options);
}

http://code.google.com/apis/ajax/playground/?type=visualization#geo_chart

解决方案

不幸的是,在当前版本的google geochart中没有这样的选项。
但是我可以想到一些可能或多或少的CSS黑客入侵。
类似于:

  #visualization {
width:550px;
overflow:hidden;
}
#visualization svg {
margin-left:-100px;
}

你必须弄清楚什么样的价值会适合你。



过去我使用这种方法来改进API在某些区域的'crop'。



这远非完美,但我认为这是操纵生成的地图的作物和中心的唯一方法。

I'm working with marine scientists and they take samples off the coast. I would like to change the center of the chart to be off the coast. I would like to give a latitude/longitude pair for the center of the chart, or two latitude/longitude pairs for a window/view of the map area, or specify multiple states like US-CT-NY. I'm hoping there is a hidden API like geochart.center = {lat: 89, long: -127}.

function drawVisualization() {
  var data = google.visualization.arrayToDataTable([
    ['Lat', 'Long', 'Popularity'],

    [41.083333333276, -73.39999999978, 20.4 ],
    [41.083333333276, -73.39999999978, 20.6 ],
    [41.099550000113, -73.415400000078, 19.0 ]
  ]);

  var options = {title:'Temperature', region:'US-CT', resolution:'metros', width: 556, height: 347};
  var geochart = new google.visualization.GeoChart(
      document.getElementById('visualization'));
  geochart.draw(data, options);
} 

http://code.google.com/apis/ajax/playground/?type=visualization#geo_chart

解决方案

Unfortunately there is no such option in the current version of the google geochart. However I can think of some CSS hacks that might work more or less. Something like:

#visualization {
width:550px;
overflow:hidden;
}
#visualization svg {
margin-left:-100px;
}

You would have to figure out what values would work for you.

I've used this method in the past to improve the 'crop' the API does in some of the areas.

It's far from perfect, but I think it's the only way to manipulate a bit the crop and center of the maps generated.

这篇关于更改Google地图GeoChart的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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