如何使用地理图表将区域显示为不同的颜色?
How to show regions as different color using Geo-charts?
我必须将佛罗里达州的每个地区显示为不同的颜色。我用 geocharts
表示。
众所周知,佛罗里达州分为 6 个区域(见下文)。每个地区都有县。每个县都有市。每个城市都有社区。
我已经尝试了下面的代码,但没有任何反映。
google.charts.load('current', {
'packages': ['geochart']
});
google.charts.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['State', 'Passed Legislation'],
['FL-BAY', 1], ['FL-GULF', 0]
]);
var options = {
region: 'US-FL', // US
colorAxis: {
colors: ['#ffcccc', '#99ff66']
},
backgroundColor: '#ffffff',
datalessRegionColor: '#f2f2f2',
defaultColor: '#f5f5f5',
};
options['resolution'] = 'provinces';
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(data, options);
};
一个Fiddle可用here
谁能告诉我如何将 BAY、GULF 写为可视化数据?
对于 KML 层,我们可以做同样的事情。
我从 source which has KML data
检索了个别城市数据
var ctaLayer1 = new google.maps.KmlLayer({
url: 'https://rdmedialabs.com/PGT/assets/kml_layer.kml?1',
map: map,
clickable: false,
});
我必须将佛罗里达州的每个地区显示为不同的颜色。我用 geocharts
表示。
众所周知,佛罗里达州分为 6 个区域(见下文)。每个地区都有县。每个县都有市。每个城市都有社区。
我已经尝试了下面的代码,但没有任何反映。
google.charts.load('current', {
'packages': ['geochart']
});
google.charts.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['State', 'Passed Legislation'],
['FL-BAY', 1], ['FL-GULF', 0]
]);
var options = {
region: 'US-FL', // US
colorAxis: {
colors: ['#ffcccc', '#99ff66']
},
backgroundColor: '#ffffff',
datalessRegionColor: '#f2f2f2',
defaultColor: '#f5f5f5',
};
options['resolution'] = 'provinces';
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(data, options);
};
一个Fiddle可用here
谁能告诉我如何将 BAY、GULF 写为可视化数据?
对于 KML 层,我们可以做同样的事情。 我从 source which has KML data
检索了个别城市数据 var ctaLayer1 = new google.maps.KmlLayer({
url: 'https://rdmedialabs.com/PGT/assets/kml_layer.kml?1',
map: map,
clickable: false,
});