如何判断我是否遇到FusionTablesLayer的其中一个限制?在下面的代码段中,我得到了以下内容:
“无法加载资源:服务器响应状态为400 ()“
错误。但是,如果我只删除where子句中的一个GEO_ID2值,它会产生结果。如果省略where子句,则会返回更多数据。
var map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(40.7459,-96.682152),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
dropMarker();
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'geometry',
from: '1xdysxZ94uUFIit9eXmnw1fYc6VcQiXhceFd_CVKa',
where: 'GEO_ID2 in (20001,20003,20005,20007,20009,20011,20013,20015,20017,20019,20021,20023,20025,20027,20029,20031,20033,20035,20037,20039,20041,20043,20045,20047,20049,20051,20053,20055,20057,20059,20061,20063,20065,20067,20069,20071,20073,20075,20077,20079,20081,20083,20085,20087,20089,20091,20093,20095,20097,20099,20101,20103,20105,20107,20109,20111,20113,20115,20117,20119,20121,20123,20125,20127,20129,20131,20133,20135,20137,20139,20141,20143,20145,20147,20149,20151,20153,20155,20157,20159,20161,20163,20165,20167,20169,20171,20173,20175,20177,20179,20181,20183,20185,20187,20189,20191,20193,20195,20197,20199,20201,20203,20205,20207,20209,31001,31003,31005,31007,31009,31011,31013,31015,31017,31019,31021,31023,31025,31027,31029,31031,31033,31035,31037,31039,31041,31043,31045,31047,31049,31051,31053,31055,31057,31059,31061,31063,31065,31067,31069,31071,31073,31075,31077,31079,31081,31083,31085,31087,31089,31091,31093,31095,31097,31099,31101,31103,31105,31107,31109,31111,31113,31115,31117,31119,31121,31123,31125,31127,31129,31131,31133,31135,31137,31139,31141,31143,31145,31147,31149,31151,31153,31155,31157,31159,31161,31163,31165,31167,31169,31171)'
}
});
layer.setMap(map)
答案 0 :(得分:0)
将代码放入a jsfiddle并查看Chrome中的javascript控制台,我看到了:
Failed to load resource: the server responded with a status of 400 (Bad Request)
https://maps.googleapis.com/maps/vt?pb=!1m4!1m3!1i6!2i13!3i22!1m4!1m3!1i6!2i13!3i23!1m4!1m3!1i6!2i14!3i22!1m4!1m3!1i6!2i14!3i23!1m4!1m3!1i6!2i15!3i22!1m4!1m3!1i6!2i15!3i23!1m4!1m3!1i6!2i13!3i24!1m4!1m3!1i6!2i13!3i25!1m4!1m3!1i6!2i14!3i24!1m4!1m3!1i6!2i14!3i25!1m4!1m3!1i6!2i15!3i24!1m4!1m3!1i6!2i15!3i25!1m4!1m3!1i6!2i16!3i22!1m4!1m3!1i6!2i16!3i23!1m4!1m3!1i6!2i16!3i24!1m4!1m3!1i6!2i16!3i25!2m9!1e2!2sft%3A1xdysxZ94uUFIit9eXmnw1fYc6VcQiXhceFd_CVKa!4m2!1ssg!2sGEO_ID2%2520in%2520(20001%252C20003%252C20005%252C20007%252C20009%252C20011%252C20013%252C20015%252C20017%252C20019%252C20021%252C20023%252C20025%252C20027%252C20029%252C20031%252C20033%252C20035%252C20037%252C20039%252C20041%252C20043%252C20045%252C20047%252C20049%252C20051%252C20053%252C20055%252C20057%252C20059%252C20061%252C20063%252C20065%252C20067%252C20069%252C20071%252C20073%252C20075%252C20077%252C20079%252C20081%252C20083%252C20085%252C20087%252C20089%252C20091%252C20093%252C20095%252C20097%252C20099%252C20101%252C20103%252C20105%252C20107%252C20109%252C20111%252C20113%252C20115%252C20117%252C20119%252C20121%252C20123%252C20125%252C20127%252C20129%252C20131%252C20133%252C20135%252C20137%252C20139%252C20141%252C20143%252C20145%252C20147%252C20149%252C20151%252C20153%252C20155%252C20157%252C20159%252C20161%252C20163%252C20165%252C20167%252C20169%252C20171%252C20173%252C20175%252C20177%252C20179%252C20181%252C20183%252C20185%252C20187%252C20189%252C20191%252C20193%252C20195%252C20197%252C20199%252C20201%252C20203%252C20205%252C20207%252C20209%252C31001%252C31003%252C31005%252C31007%252C31009%252C31011%252C31013%252C31015%252C31017%252C31019%252C31021%252C31023%252C31025%252C31027%252C31029%252C31031%252C31033%252C31035%252C31037%252C31039%252C31041%252C31043%252C31045%252C31047%252C31049%252C31051%252C31053%252C31055%252C31057%252C31059%252C31061%252C31063%252C31065%252C31067%252C31069%252C31071%252C31073%252C31075%252C31077%252C31079%252C31081%252C31083%252C31085%252C31087%252C31089%252C31091%252C31093%252C31095%252C31097%252C31099%252C31101%252C31103%252C31105%252C31107%252C31109%252C31111%252C31113%252C31115%252C31117%252C31119%252C31121%252C31123%252C31125%252C31127%252C31129%252C31131%252C31133%252C31135%252C31137%252C31139%252C31141%252C31143%252C31145%252C31147%252C31149%252C31151%252C31153%252C31155%252C31157%252C31159%252C31161%252C31163%252C31165%252C31167%252C31169%252C31171)!4m2!1ssc!2sgeometry!5i1!3m3!2sen-US!3sUS!5e18!4e3!12m1!5b1&callback=_xdc_._eb8bpk&token=53264
我的文本编辑器说这是2480字节。
在the fusion-tables issue tracker:Issue 49: OR in filters,
中解决此问题IN子句中列出的项目数没有限制。但是,可以与Maps API一起使用的网址长度是有限制的。看到: http://support.microsoft.com/kb/208427(Internet Explorer中的最大URL长度为2,083个字符)