我正在使用 jVectorMap v1.1 并且我有这段相关的代码:
var america = "#d84148";
var europe = "#0060d0";
var africa = "#44984d";
var asia = "#e3a430";
var oceania = "#2ecdd0";
series: {
regions: [{
values: data['colours'],
scale: {
"America" : america,
"Europe" : europe,
"Africa" : africa,
"Asia" : asia,
"Oceania" : oceania
},
normalizeFunction: 'linear',
attribute: 'fill'
}]
}
我获得的矢量数据是来自naturalearth.com的world_mill_en,它包含每个国家/地区的1px分隔,充当该国家/地区的边界。我正在构建的应用程序必须显示整个大陆,因此不允许有边界。
在属性
上,我只能将fill
或描边
设置为参数,并且可以在使用时为边框设置纯色>填充
。
我想知道是否可以同时使用 fill
和 lines
作为属性。或者是否有一种方法可以将区域的笔划设置为与其各自区域相同的颜色。 IE。
if (stroke == "none")
{
stroke = "that region's colour"
}
最佳答案
搜索各种示例后,我在此链接中找到了我的解决方案:
https://github.com/bjornd/jvectormap/blob/master/tests/markers.html
我需要做的就是:
var america = "#d84148";
var europe = "#0060d0";
var africa = "#44984d";
var asia = "#e3a430";
var oceania = "#2ecdd0";
series: {
regions: [{
values: data['colours'],
scale: {
"America" : america,
"Europe" : europe,
"Africa" : africa,
"Asia" : asia,
"Oceania" : oceania
},
normalizeFunction: 'linear',
attribute: 'fill'
}, {
values: data['colours'],
scale: {
"America" : america,
"Europe" : europe,
"Africa" : africa,
"Asia" : asia,
"Oceania" : oceania
},
normalizeFunction: 'linear',
attribute: 'stroke'
}]
}
就这样,问题解决了。复制区域数组内的整个部分,包括大括号,将填充更改为描边。
关于javascript - 有没有办法使用 "fill"和 "stroke"作为区域比例颜色的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13344196/