这是一个由两部分组成的问题。
首先,当绘制的点只是城市而没有人口或大小时,有没有办法改变谷歌地理图上的标记的大小?我只是列出了没有附加价值的城市,所有Google的例子都有某种类型的人口。
例如,Google使用这段代码,标记的大小由人口反映。
function drawMarkersMap() {
var data = google.visualization.arrayToDataTable([
['City', 'Population', 'Area'],
['Rome', 2761477, 1285.31],
['Milan', 1324110, 181.76],
['Naples', 959574, 117.27],
['Turin', 907563, 130.17],
['Palermo', 655875, 158.9],
['Genoa', 607906, 243.60],
['Bologna', 380181, 140.7],
['Florence', 371282, 102.41]
]);有没有办法改变标记的大小,而不是通过某种区域或人口来设置它?
其次,由于我没有标记大小的数字(只有城市名称),我如何更改标记的颜色?据我所知,colorAxis是基于与正在绘制的城市相关的数字。
colorAxis: {colors: ['green', 'blue']}这里有一个指向应用编程接口文档https://developers.google.com/chart/interactive/docs/gallery/geochart的链接
发布于 2012-10-05 18:34:33
通过一些调整,您可以做到这一点。
看看我创建的一些示例:
http://cmoreira.net/interactive-world-maps-demo/svg-maps-of-the-states-in-usa/
要更改颜色,您应该这样做:
var data = new google.visualization.DataTable();
data.addColumn('string', 'Country');
data.addColumn('number', 'Value');
data.addColumn({type:'string', role:'tooltip'});
data.addRows([[{v:"Olympia Washington",f:"Olympia"},1,"Capital city of the state of Washington"],[{v:"Seattle Washington",f:"Seattle"},2,"Largest city of the state of Washington"],[{v:"Spokane Washington",f:"Spokane"},3,"Seconde Largest city of the state of Washington"],[{v:"Vancouver Washington",f:"Vancouver"},4,"Fourth largest city of the state of Washington"],]);
var options = { colorAxis: {minValue: 1, maxValue:4, colors: ['#4A9928','#204DA8','#992F1A','#2292C9',]},
(...)因此,您递增一个数字,并给出尽可能多的不同颜色来匹配这些值。
为了改变大小,我没有对它进行测试,但我猜如果你使用这个值,一个类似的方法也会起作用:
sizeAxis: {minValue: 1, maxValue:4,minSize:1, maxSize: 4}发布于 2012-08-08 15:58:50
据我从文档中了解,你不能在Google Geochart中直接定义标记的颜色和大小。我建议您尝试另一种解决方案- jVectorMap。使用markers参数定义标记时,可以使用markerDefaults设置每个标记的大小和填充颜色或定义默认参数。
发布于 2018-02-26 13:53:34
/*Code for geo chart configuration option*/
$scope.geoChartConfig = function (data, regionName) {
$scope.chart = {};
$scope.chart.type = "GeoChart";
$scope.chart.data = data
$scope.chart.options = {
// width: 800,
// height: 500,
resolution: 'provinces', //code to set city wise data
region: regionName,
sizeAxis: {
// minValue: 1, //code to set min and max values in geo chart
// maxValue: 4,
minSize: 4, //code to set min and max marker size
maxSize: 4
},
// markerOpacity:1,//code to set opacity or transparancy of chart
displayMode: 'auto', //auto, chart will automatically detect data set whether it is regions or points
keepAspectRatio: true, // code to set max size of chart according to div size html
backgroundColor: '#eaf9ff',
datalessRegionColor: 'white',
defaultColor: '#f5f5f5',
colorAxis: {
colors: ['#1f77b4', '#55FF00', 'red'] //, '#ff0505'
},
};
}https://stackoverflow.com/questions/10942251
复制相似问题