更改Google地图GeoChart的中心 [英] Change center of Google Map GeoChart
问题描述
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屋!