使用Google Visualization API GeoCharts使用鼠标悬停突出大陆 [英] highlight continent with mouseover using Google Visualization API GeoCharts
本文介绍了使用Google Visualization API GeoCharts使用鼠标悬停突出大陆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下面的代码,我希望当我有一个大陆的鼠标悬停时,它应该突出显示这个大陆:我试过这段代码,但是我没有那么努力
I have following code and I expect that when I have mouseover that a continent it should highlight that continent: I tried this code but I did not got that working
google.maps.event.addListener(map,'mouseover',function(e){
google.load('visualization', '1', {'packages': ['geochart']});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Country', 'Popularity'],
['Germany', 200],
['United States', 300],
['Brazil', 400],
['Canada', 500],
['France', 600],
['RU', 700]
]);
var options = {colors:['#002e5f','#CCCCCC']};
var chart = new google.visualization.GeoChart(document.getElementById('googleMap'));
chart.draw(data, options);
};
推荐答案
此代码应该有所帮助:
This code should help:
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Region Code', 'Continent', 'Popularity'],
['142', 'Asia', 200],
['150', 'Europe', 300],
['019', 'Americas', 400],
['009', 'Oceania', 600],
['002', 'Africa', 700]
]);
var options = {
resolution: 'continents'
};
var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));
chart.draw(data, options);
}
这篇关于使用Google Visualization API GeoCharts使用鼠标悬停突出大陆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文