我正在尝试在护目镜街道地图中应用新加坡邮政编码。我在位置变量中传递邮政编码,但是当我更改邮政编码时,地图位置无法更改。不知道我哪里错了。请帮忙。这是新加坡的一些邮政编码:189969、189927 这是我的代码
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<script type='text/javascript' src='mootools-core-1.3.2.js'></script>
<link rel="stylesheet" type="text/css" href="/css/normalize.css">
<style type='text/css'>
#map_canvas {
background:#ccc;
height:400px;
width:100%;
}
</style>
<script type='text/javascript'>//<![CDATA[
window.addEvent('load', function() {
var map;
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(1.280095,103.850949);
var panoramaOptions = {
position: latlng,
};
map = new google.maps.StreetViewPanorama(document.getElementById('map_canvas'),panoramaOptions);
var locations = ['189969'];
function codeAddress(locations) {
for (i = 0; i < locations.length; i++) {
geocoder.geocode( { 'address': locations[i]}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
codeAddress(locations);
});//]]>
</script>
</head>
<body>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="map_canvas">map</div>
</body>
</html>