我需要有人引导/指导我在哪里编码错误,因为我无法弄清楚我的代码哪里出错了。此代码在我的 IE 和 FF 中运行良好,但在 Chrome 或 Safari 中运行良好。右边,当我单击下拉列表选择时,它将显示所选位置的确切地图。但是在我的 Chrome 和 Safari 中,它只显示了初始地图,而不是显示从列表中选择的位置。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Google Maps JavaScript API Example</title>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAn5fGcWgolNQy8U9PV2YsP1P3Knn23Jro&sensor=false"></script>
<script type="text/javascript">
// Variables Initialize
var marker;
var map;
var image = "flag.png";
function initialize(lat,lng) {
var singapore = new google.maps.LatLng(lat,lng);
var settings = {
zoom: 11,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: singapore,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.TOP_RIGHT},
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL},
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP},
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.DEFAULT,
position: google.maps.ControlPosition.LEFT_TOP},
scaleControl: true,
scaleControlOptions: {
position: google.maps.ControlPosition.BOTTOM_RIGHT}
};
map = new google.maps.Map(document.getElementById("map_canvas"), settings);
marker = new google.maps.Marker({
map: map,
draggable:false,
animation: google.maps.Animation.DROP,
position: singapore,
title:"Singapore",
icon: image
});
}
</script>
</head>
<body onload="initialize('1.28563','103.80918')" onunload="GUnload()">
<select>
<option onclick="initialize('1.28563','103.80918')">--Select Location--</option>
<option onclick="initialize('1.28527','103.82682')">Blk 18A Jalan Membina</option>
<option onclick="initialize('1.28277','103.82562')">Blk 26 Jalan Membina</option>
<option onclick="initialize('1.31546','103.766363')">Blk 321-326 Clementi Ave 5</option>
</select>
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>