我正試圖分配我的下拉菜單的功能,所以當你點擊所選的縣時,它將在該縣上放火。我已經寫下了我可以在下面通過研究,因爲我是所有這些的新手,但我不知道如何將它們連接在一起。 我知道我沒有附加googlemaps,但我在我的整個頁面中,這只是這一節,我試圖鏈接在一起有麻煩。嘗試將功能分配給我的下拉菜單中的邊界
<!doctype html>
<html>
<head>
<script type="text/javascript">
document.getElementById('counties').addEventListener('click', function(e) {alert(this.value); e.preventDefault();}, false);
$('bedfordshire').click(function(){
alert(this.value);
});
$('buckinghamshire').click(function(){
alert(this.value);
});
$('cambridgeshire').click(function(){
alert(this.value);
});
$('hertfordshire').click(function(){
alert(this.value);
});
$('northamptonshire').click(function(){
alert(this.value);
});
//bedfordshire
bounds = new google.maps.LatLngBounds();
bounds.extend(new google.maps.LatLng(52.33, -0.05));
bounds.extend(new google.maps.LatLng(51.8, -0.8));
map.fitBounds(bounds);
//buckinghamshire
bounds = new google.maps.LatLngBounds();
bounds.extend(new google.maps.LatLng(52.21, -0.33));
bounds.extend(new google.maps.LatLng(51.47, -1.33));
map.fitBounds(bounds);
//cambridgeshire
bounds = new google.maps.LatLngBounds();
bounds.extend(new google.maps.LatLng(52.75, -0.55));
bounds.extend(new google.maps.LatLng(51.99, -0.53));
map.fitBounds(bounds);
//hertfordshire
bounds = new google.maps.LatLngBounds();
bounds.extend(new google.maps.LatLng(52.09, -0.35));
bounds.extend(new google.maps.LatLng(51.59, -0.80));
map.fitBounds(bounds);
//northamptonshire
bounds = new google.maps.LatLngBounds();
bounds.extend(new google.maps.LatLng(52.67, -0.33));
bounds.extend(new google.maps.LatLng(51.94, -1.35));
map.fitBounds(bounds);
</script>
</head>
<body>
<select id="Counties" >
<option value="">Select County</option>
<option value="bedfordshire">Bedfordshire</option>
<option value="buckinghamshire">Buckinghamshire</option>
<option value="cambridgeshire">Cambridgeshire</option>
<option value="hertfordshire">Hertfordshire</option>
<option value="northamptonshire">Northamptonshire</option>
</select>
</body>
</html>
[從選擇下拉菜單更新谷歌地圖(http://stackoverflow.com/questions/5484419/update-google-map-from-select-dropdown-menu) – geocodezip
的javascript/HTML是可能的重複區分大小寫,「縣」與「縣」不一樣。 ('document.getElementById('counties')';不會找到'
與'可能重複'我已經看過,但完全不同的寫到我所做的和我我是一個學習者,只做了幾個星期,所以無法理解它,它幫助了我,所以我問了我。所以區分大小寫有所不同,謝謝。如何將邊界鏈接到每個函數? – Kev