FusionTablesLayer多边形仅接受最多四个条件样式

时间:2012-03-03 00:58:41

标签: google-fusion-tables

我正在使用Google Fusion Tables,Maps API和FusionTablesLayer构建选举热图。对于给定的候选人,地图会根据他们赢得的投票百分比来遮蔽县的颜色。

我正在使用layer.setOptions()来设置百分比桶,并根据投票的位置设置逐渐变暗的fillColors。例如,对于Santorum:

layer.setOptions({
            query: 
            {
                select: 'geometry',
                from: '3102804'
            }, 
            styles: 
            [{
                polygonOptions:
                {
                    fillColor:"#000000",
                    fillOpacity: .8
                }
            },
            {
                where: "SantorumPercentage < '.04'", 
                polygonOptions:
                {
                    fillColor:"#ffeaeb"

                }
            },
            {
                where: "SantorumPercentage < '.08' AND SantorumPercentage >= '.04'", 
                polygonOptions:
                {
                    fillColor:"#fedada"

                }
            },
            {
                where: "SantorumPercentage < '.14' AND SantorumPercentage >='.08' ", 
                polygonOptions:
                {
                    fillColor:"#fec9ca"

                }
            },
            {
                where: "SantorumPercentage < '.18' AND SantorumPercentage >= '.14' ", 
                polygonOptions:
                {
                    fillColor:"#feb8ba"

                }
            },
            {
                where: "SantorumPercentage < '.22' AND SantorumPercentage >= '.18' ", 
                polygonOptions:
                {
                    fillColor:"#fda8aa"

                }
            },
            {
                where: "SantorumPercentage < '.26' AND SantorumPercentage >='.22' ", 
                polygonOptions:
                {
                    fillColor:"#fd9799"

                }
            },
            {
                where: "SantorumPercentage < '.30' AND SantorumPercentage >= '.26' ", 
                polygonOptions:
                {
                    fillColor:"#fd8689"

                }
            },
            {
                where: "SantorumPercentage < '.34' AND SantorumPercentage >= '.30' ", 
                polygonOptions:
                {
                    fillColor:"#fc7679"

                }
            },
            {
                where: "SantorumPercentage < '.38' AND SantorumPercentage >= '.34' ", 
                polygonOptions:
                {
                    fillColor:"#fc6569"

                }
            },
            {
                where: "SantorumPercentage < '.42' AND SantorumPercentage >= '.38' ", 
                polygonOptions:
                {
                    fillColor:"#fc5459"

                }
            },
            {
                where: "SantorumPercentage < '.46' AND SantorumPercentage >= '.42' ", 
                polygonOptions:
                {
                    fillColor:"#fb4448"

                }
            },
            {
                where: "SantorumPercentage < '.50' AND SantorumPercentage >= '.46' ", 
                polygonOptions:
                {
                    fillColor:"#fb3338"

                }
            },
            {
                where: "SantorumPercentage < '.54' AND SantorumPercentage >= '.50' ", 
                polygonOptions:
                {
                    fillColor:"#fb2228"

                }
            },
            {
                where: "SantorumPercentage < '.60' AND SantorumPercentage >= '.54' ", 
                polygonOptions:
                {
                    fillColor:"#fb2228"

                }
            },
            {
                where: "SantorumPercentage >= '.60'", 
                polygonOptions:
                {
                    fillColor:"#f6050b"

                }
            }]


        });

然而,英国“金融时报”似乎只承认前4个“桶”,即桑托勒姆赢得超过18%的选票作为默认阴影,即黑色。

这是我的代码的问题吗?或者FT只允许最多四种条件样式?

2 个答案:

答案 0 :(得分:1)

根据Google Maps API文档,您应该能够将5种样式应用于单个图层:

http://code.google.com/apis/maps/documentation/javascript/layers.html#fusion_table_styles

答案 1 :(得分:0)

我之前在另一个项目上遇到过同样的问题,并且无法通过Maps API解决它。为了解决这个问题,我使用了FT API样式,这在做你正在做的样式时很麻烦。我还发现了来自Rebecca with FT的post reply,它解释了你“最多可以应用5个造型规则”。我还没有在融合表文档中找到它。

另一种可能的解决方法是执行与自定义图标解决方法类似的操作,请求几何体,然后将其显示为多边形叠加层。

https://developers.google.com/fusiontables/docs/samples/custom_markers