0
我不知道爲什麼,但地圖畫布不出現在屏幕上... 我用Fusion TablesLayer嚮導2.0添加過濾器(基於文本的搜索)。也許問題是IF ... ELSE語句。或者一些小的語法錯誤。請幫忙!破碎的代碼 - 融合表地圖
<!DOCTYPE html>
<html>
<head>
<style>
#map-canvas { width:500px; height:400px; }
</style>
<script type="text/javascript" src="http://maps.google.com/maps/apijs?sensor=false"> </script>
<script type="text/javascript">
var map;
var layer10;
function initialize() {
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(-30.08870187538118, -51.16813659667969),
zoom: 11,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
layer10 = new google.maps.FusionTablesLayer({
query: {
select: "'ENDERECO_GOOGLE'",
from: 3767057
},
map: map
});
}
//the function to activate filters
function changeMap10() {
var searchString = document.getElementById('search-string-10').value.replace(/'/g, "\\'");
var filter = document.getElementById('filter').value.replace(/'/g, "\\'");
if (filter == "TURNO"){
layer10.setOptions({
query: {
select: "'ENDERECO_GOOGLE'",
from: 3767057,
}
});
}
layer10.setOptions({
query: {
select: "'ENDERECO_GOOGLE'",
from: 3767057,
where: "'TURNO'" = '" + searchString + "'"
}
});
else if (filter == "DIA_SEMANA"){
layer10.setOptions({
query: {
select: "'ENDERECO_GOOGLE'",
from: 3767057,
}
});
}
layer10.setOptions({
query: {
from: 3767057,
where: "'DIA_SEMANA'" = '" + searchString + "'"
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
<div style="margin-top: 10px;">
<label>Choose data!</label><input type="text" id="search-string-10">
<input type="button" onclick="changeMap10()" value="Search">
</div>
</body>
</html>
非常感謝Stefan! –