Request-URI太大(Fusion表格层Google地图)

时间:2013-10-04 10:28:16

标签: javascript jquery google-maps-api-3 google-fusion-tables

我正在尝试将融合表格图层数据放在我的Google Map上,但我收到错误 Request-URI Too Large 。我经常搜索,但无法通过POST方法或其他方法找到它如何使其工作。问题是where clause,但我不能缩短where子句。有没有人可以帮助我或指导我?

提前感谢您的帮助。

layer = new google.maps.FusionTablesLayer({
    map: googleMap,
    heatmap: {enabled: false},
    query: {
        select: "col4",
        from: "tableID",
        where: "",
    },
    styles: [{
        polygonOptions: {
            fillOpacity: 0.3
        }
    }, {
        where: "col0 in ('Jefferson','Pulaski','Los Angeles','Denver','Middlesex','New Castle','Duval','Pinellas','Lee','Broward','Fulton','Cobb','Ada','Tazewell','Cook','Marion','Hendricks','Putnam','Adams','Boone','Orleans','Plymouth','Baltimore','Washington','Macomb','Genesee','Oakland','Hennepin','Jackson','Shelby','Granite','Forsyth','Mecklenburg','Wake','Douglas','Gloucester','Passaic','Bernalillo','Sandoval','Clark','New York','Montgomery','Hamilton','Tulsa','Oklahoma','Multnomah','Lane','Chester','Philadelphia','York','Lehigh','Kent','Horry','Davidson','Travis','Harris','Dallas','Fairfax','Chesterfield','King','Brown','Laramie','Kalamazoo','Cabarrus','San Diego','Pennington','Richland','Weber','Ramsey','Hartford') AND col3 in ('AL','AR','CA','CO','CT','DC','DE','FL','GA','ID','IL','IN','WV','OH','KY','LA','MA','MD','MI','MN','MO','TN','MT','NC','NE','NJ','NM','NV','NY','OK','OR','PA','RI','SC','TX','VA','VT','WA','WI','WY','SD')",
        polygonOptions: {
            fillColor: '#ffffff',
            strokeColor: '#ff0000',
            fillOpacity: 0.3
        }
    }],
    options: {
        styleId: 1,
        templateId: 2
    }
});

1 个答案:

答案 0 :(得分:3)

使用动态查询后,您将始终遇到Request URI Too Large问题。一种解决方案是生成您正在查询运行时的融合表 - 意味着在用户选择您创建表的动态参数之后......或者更可能是来自服务器端的视图(php,asp,java) - 并传递创建的表id到应用程序中的视图层。缺点是:你将放松所有的动态,因为创建后桌子需要在谷歌的一侧缓存以正确显示(在创建表格的另一个5-30秒)。

听取我的建议:FT不是为了显示动态过滤的数据而设计的。可以应用一些小过滤器,例如:过滤单个字段的单个值,但就是这样。 要实现您的目标,您可能需要考虑OpenLayers + GeoServer + WMS方法。这些是开源的,比上面的解决方法快约100倍。