Google Maps Fusion Layer会忽略WHERE子句

时间:2015-11-16 16:18:12

标签: javascript google-maps google-fusion-tables

我遇到了一个问题,即我的融合表层中的where子句实际上做了什么。

以下应该做的是从我的融合表中选择所有行' income'如果你在where子句中交换代码,则高于100(或者对于特定的geom(MSOA))。

融合表列average_income是类型Number,MSOA11CD是类型Text。

这里有一个老问题是关于同一主题但是通过我没有的语法错误解决了。 "WHERE" clauses being ignored in Fusion Table Layer in Google Maps

这里小提琴: http://jsfiddle.net/dqthnw7s/

layer = new google.maps.FusionTablesLayer({
    map: map,
    heatmap: {
        enabled: false
    },
    query: {
        select: "*",
        from: "1QEMdQUSmsdEZs9vAchHeKPG_CsKa7L0zW0SBJSCu",
        where: "average_income > 100",
        //tried this too
        //where: 'MSOA11CD = \'E02004590\''

    },
    styles: [{
       where: "average_income > 1000",
        polygonOptions: {
            fillColor: '#002951'
        }
    }, {
        where: "average_income > 800 AND average_income <= 1000",
        polygonOptions: {
            fillColor: '#003466'
        }
    }, {
        where: 'average_income > 100 AND average_income <= 800',
        polygonOptions: {
            fillColor: '#376798'
        }
    }]
});

融合表: https://www.google.com/fusiontables/DataSource?docid=1QEMdQUSmsdEZs9vAchHeKPG_CsKa7L0zW0SBJSCu#rows:id=1

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

选择“*”无效。这需要是一个“几何”专栏。

layer = new google.maps.FusionTablesLayer({
    map: map,
    heatmap: {
        enabled: false
    },
    query: {
        select: "geometry",
        from: "1QEMdQUSmsdEZs9vAchHeKPG_CsKa7L0zW0SBJSCu",
        where: "average_income > 100",
        //tried this too
        //where: 'MSOA_CODE = \'E02004590\''

    },
    styles: [{
       where: "average_income > 1000",
        polygonOptions: {
            fillColor: '#002951'
        }
    }, {
        where: "average_income > 800 AND average_income <= 1000",
        polygonOptions: {
            fillColor: '#003466'
        }
    }, {
        where: 'average_income > 100 AND average_income <= 800',
        polygonOptions: {
            fillColor: '#376798'
        }
    }]
});

updated fiddle