我有以下的谷歌地图的代码:
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-27.444916,153.03),
zoom: 12,
disableDefaultUI: true,
keyboardShortcuts: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
setMarkers(map, beaches);
}
var beaches = [
['Car:806', -27.4481025666613, 153.035155217002, 916],
['Car:520', -27.4777186625335, 153.00697421394, 915],
['Car:1477', -27.4523199466005, 153.029570366226, 914],
['Car:815', -27.5315143182514, 153.023819055977, 913],
['Car:334', -27.3930054770139, 153.104887341157, 912],
['Car:191', -27.4705744176833, 153.030243260862, 911],
...
['Car:618', -27.4146792620242, 153.081801794924, 1],
['Car:1096', -27.3369540394594, 153.069279763313, 0],
];
function setMarkers(map, locations) {
var image = new google.maps.MarkerImage('http://labs.google.com/ridefinder/images/mm_20_orange.png',
new google.maps.Size(20, 32),
new google.maps.Point(0,0),
new google.maps.Point(0, 32));
var shadow = new google.maps.MarkerImage('http://labs.google.com/ridefinder/images/mm_20_shadow.png',
new google.maps.Size(37, 32),
new google.maps.Point(0,0),
new google.maps.Point(0, 32));
var shape = {
coord: [1, 1, 1, 20, 18, 20, 18 , 1],
type: 'poly'
};
for (var i = 0; i < locations.length; i++) {
var beach = locations[i];
var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
shadow: shadow,
icon: image,
shape: shape,
title: beach[0],
zIndex: beach[3]
});
}
}
</script>
它可以在Chrome和IE罚款,但在IE中我得到一个错误。 这一切看起来好像没什么问题,但ID真的想明白为什么我得到这个错误:
网页错误详细信息
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.4; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; .NET CLR 1.1.4322)
Timestamp: Wed, 30 Jan 2013 22:40:09 UTC
Message: '1' is null or not an object
Line: 966
Char: 1
Code: 0
URI: file://ycab01/Homedirs$/it3/Desktop/Michael/WEB%20DEV/CarPositionBrisbane.HTML
到线996的基准是:
var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
我假定IE犯规像该呼叫到阵列中的索引。 我只是不知道是否有不同的方式来做到这一点?
麦克风