我正在尝试在 Fusion Tables Map 中创建一个重置按钮,一旦单击它就会显示所有标记。但是有些东西不起作用。请看一下:
这是整个代码:
实际上,我试图从函数 clearBox() 的 layer10 部分“模仿”函数 initialize()。我也尝试使用reset()方法,但也没有用。
<!DOCTYPE html>
<html>
<head>
<style>
#map-canvas { width:500px; height:600px; }
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
var map;
var layerl0;
function initialize() {
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(-30.070876662388095, -51.1907958984375),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
layerl0 = new google.maps.FusionTablesLayer({
query: {
select: "'ENDERECO'",
from: '3385625'
},
map: map
});
}
function changeMapl0() {
var searchString = document.getElementById('search-string-l0').value.replace(/'/g, "\\'");
layerl0.setOptions({
query: {
select: "'ENDERECO'",
from: 3385625,
where: "'TIPO' = '" + searchString + "'"
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
//Function to be activated by the reset button
function clearBox() {
document.getElementById('search-string-l0').value = "";
layerl0 = google.maps.FusionTablesLayer({
query: {
select: "'ENDERECO'",
from: '3385625'
},
});
}
</script>
</head>
<body>
<div id="map-canvas"></div>
<div style="margin-top: 10px;">
<label>Tipo</label>
<select id="search-string-l0" onchange="changeMapl0 (this.value);">
<option value="">--Select--</option>
<option value="Comidas variadas">Comidas variadas</option>
<option value="Restaurante">Restaurante</option>
<option value="Bar">Bar</option>
<option value="Hotel">Hotel</option>
<option value="Shopping Center">Shopping Center</option>
<option value="Teatro">Teatro</option>
<option value="Igreja">Igreja</option>
<option value="Museu">Museu</option>
<option value="Espaço de Cultura">Espaço de Cultura</option>
</select><br/>
<input type="button" onclick="clearBox()" value="Reset Map" />
</div>
</body>
</html>