我在jQuery UI标签中有Google街景地图。我只获得了传递给地图的邮政编码的详细信息,但在地图上看不到任何内容。不幸的是,当我完全击中F12(检查元素)地图加载时。怎么了,请给我一些建议。
听到我的代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<script type='text/javascript' src='/js/lib/dummy.js'></script>
<link rel="stylesheet" type="text/css" href="/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<script type='text/javascript' src="http://maps.googleapis.com/maps/api/js?sensor=false&.js"></script>
<style type='text/css'></style>
</head>
<body>
<div id="map_canvas" style="height:300px">map</div>
<script type='text/javascript'>//<![CDATA[
google.maps.event.addDomListener(window, 'load', function() {
var map;
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(1.280095,103.850949);
var mapOptions = {
center: latlng,
zoom:5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),mapOptions);
console.log(map.streetView)
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
});
map.streetView.setPosition(results[0].geometry.location);
map.streetView.setVisible(true);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
codeAddress(locations);
});
//]]>
</script>
</body>
</html>