1

我正在使用最新的 Jvectormap (1.2.2) 但找不到设置所有国家颜色的任何示例。我相信在以前的版本中它只是“颜色:”,但现在已经停产了?

下面的代码有效,但颜色部分无效。我在我的网站上使用白色背景,因此希望所有国家/地区默认具有不同的颜色。

 <script>
  $(function(){
        $('#world-map').vectorMap({
    map: 'world_mill_en',
    color: '#000000',
        backgroundColor: '#ffffff',
        series: {
       regions: [{
            values: {
                IN:'#33250B',
                US:'#003366'
        }
       }]
         }
     })
  });
 </script>
4

3 回答 3

3

我不确定您的意思是什么,但是要设置您可以使用的所有国家/地区颜色:

var regionStyling = {initial: {fill: '#128da7'},hover: {fill: "#A0D1DC"}};

jQuery('#world-map').vectorMap({
    map: 'world_mill_en',
    normalizeFunction: 'polynomial',
    regionStyle:regionStyling,
    backgroundColor: '#383f47',
    series: {regions: [{values: {},attribute: 'fill'}]}
});

这对我有用,如果你想指定每个国家,你可以使用:

 jQuery('#world-map').vectorMap({
    map: 'world_mill_en',
    normalizeFunction: 'polynomial',
    backgroundColor: '#383f47',
    series: {regions: [{values: {"US" : "#000"},attribute: 'fill'}]}
});
于 2013-04-25T10:47:38.413 回答
1

在 jVectorMap 的 1.xx 分支中,可以通过使用regionStyle配置参数来实现所需的功能。在此处的文档中查看更多信息。

于 2013-02-20T15:35:10.573 回答
0

要为所有区域设置默认颜色,请设置regionStyle.default.fill.

这是您进行更改的代码:

<script>
    $(function(){
        $('#world-map').vectorMap({
            map: 'world_mill_en',
            regionStyle: { initial: { fill: '#000000' } },  //Changed this line
            backgroundColor: '#ffffff',
            series: {
                regions: [{
                    values: {
                        IN:'#33250B',
                        US:'#003366'
                    }
                }]
            }
        })
    });
</script>
于 2014-09-22T18:20:09.583 回答