Jvectormap 1.2.2颜色问题

时间:2013-02-19 18:53:42

标签: jquery map colors country jvectormap

我使用的是最新的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>

3 个答案:

答案 0 :(得分: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'}]}
});

答案 1 :(得分:1)

在jVectorMap的1.x.x分支中,可以使用regionStyle配置参数实现所需的功能。请参阅文档here中的更多内容。

答案 2 :(得分: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>