我使用Google Maps API v3创建了一个简单的静态HTML页面。这在某些浏览器(Windows XP上的IE v8)中运行良好,但我无法在Mac OS X 10.6.8和Windows XP上加载最新版本的Safari。当我打开Safari开发者控制台时,我收到了这些错误:
TypeError: 'undefined' is not a constructor (evaluating 'new google.maps.Size(150,50)')
TypeError: 'undefined' is not a constructor (evaluating 'new google.maps.LatLng(-30.2965590,153.1152650)')
我已将该文件的副本放在网上:
http://dl.dropbox.com/u/34923164/Errors_GoogleMaps.htm
以下是html内容:
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>Google Maps Sample</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var map = null;
function initialize() {
var myOptions = {
zoom: 13,
center: new google.maps.LatLng(-30.2965590,153.1152650),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
google.maps.event.addListener(map, 'click', function() {
infowindow.close();
});
var point = new google.maps.LatLng(-30.2965590,153.1152650);
var icon = 'http://www.google.com/intl/en_us/mapfiles/ms/icons/blue-dot.png';
var marker = createMarker(point,'Location: 33 Harbour Drive Coffs Harbour', icon)
var point = new google.maps.LatLng(-30.2864430,153.1360230);
var icon = 'http://www.google.com/intl/en_us/mapfiles/ms/icons/red-dot.png';
var marker = createMarker(point,'Person: Fred Flinstone (108 Park Beach Road Coffs Harbour)')
var point = new google.maps.LatLng(-30.2941737,153.1156785);
var icon = 'http://www.google.com/intl/en_us/mapfiles/ms/icons/red-dot.png';
var marker = createMarker(point,'Person: Barney Rubble (108 Grafton St Coffs Harbour)')
}
var infowindow = new google.maps.InfoWindow(
{
size: new google.maps.Size(150,50)
});
function createMarker(latlng, html, icon) {
var contentString = html;
var marker = new google.maps.Marker({
position: latlng,
icon: icon,
map: map,
zIndex: Math.round(latlng.lat()*-100000)<<5
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map,marker);
});
}
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
<div id="map_canvas"></div>
</body>
</html>
答案 0 :(得分:0)
我已尝试在Dropbox上发布您的代码并且没有看到任何使用Safari 5.1(Lion)和Chrome 12.0.742的错误可能您在缓存中有问题或您的网络有一些问题而且它没有下载javascript正确的谷歌代码
我的2美分