【发布时间】:2023-04-08 12:05:01
【问题描述】:
我浏览了this link,它显示了一个带有自动完成搜索框的融合表地图图层。但是在这个例子中,只有前 500 行的融合表在自动完成中被索引。
在下方找到fiddle 以供参考。
function initAutoComplete(tableId) {
// Retrieve the unique store names using GROUP BY workaround.
var queryText = encodeURIComponent(
"SELECT 'FB_INDO_2000', COUNT() " +
'FROM ' + tableId + " GROUP BY 'FB_INDO_2000'");
var query = new google.visualization.Query(
'http://www.google.com/fusiontables/gvizdata?tq=' + queryText);
query.send(function(response) {
var numRows = response.getDataTable().getNumberOfRows();
// Create the list of results for display of autocomplete.
var results = [];
for (var i = 0; i < numRows; i++) {
results.push(response.getDataTable().getValue(i, 0));
}
// Use the results to create the autocomplete options.
$('#store').autocomplete({
source: results,
minLength: 2
});
});
}
编辑:正如 geocodezip 所建议的,我通过将查询更改为 FT API v1 来更新我的 fiddle here,
var queryText = encodeURIComponent(
"SELECT 'FB_INDO_2000', COUNT() " + 'FROM ' + tableId + " GROUP BY 'FB_INDO_2000'");
var queryUrlHead = 'https://www.googleapis.com/fusiontables/v1/query?sql=';
var queryUrlTail = '&key=AIzaSyCAI2GoGWfLBvgygLKQp5suUk3RCG7r_ME';
var query = new google.visualization.Query(queryUrlHead + queryText + queryUrlTail);
但无法实现自动完成。
【问题讨论】:
标签: google-maps search autocomplete google-fusion-tables