我不知道为什么,但地图画布没有出现在屏幕上...我使用 Fusion TablesLayer Wizard 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>