以下代码在所有版本的现代浏览器中将谷歌地图从内联 div 加载到颜色框弹出窗口,但无法在 ie7 等过时浏览器中加载地图。
<head>
<script src="http://maps.googleapis.com/maps/api/js?key=/////////;sensor=false"></script>
<script>
var myCenter=new google.maps.LatLng(xxxxxxxx,yyyyyyy);
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(xxxxxxxx,yyyyyyy),
zoom:10,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker=new google.maps.Marker({
position:myCenter,
});
marker.setMap(map);
var infowindow = new google.maps.InfoWindow({
content:"hello world
});
infowindow.open(map,marker);
}
//google.maps.event.addDomListener(window, 'load', initialize);
</script>
<script type="text/javascript">
jQuery(document).ready(function($){
$(".inline").colorbox({
inline:true,
href:"#googleMap",
fixed:true,
onComplete: function(){
initialize();
}
});
});
</script>
</head>
<body>
<div style="display:none;">
<div id="googleMap" style="width:600px;height:500px;">
</div>
</div>
<a class='inline' href="#googleMap">Google Map</a>
</body>
我指出了 ie7 控制台在以下代码块中究竟是如何以及在何处注意到 js 错误的:
var marker=new google.maps.Marker({
position:myCenter,
.....*Error:Expected identifier, string or number...});
jQuery(document).ready(function($){
$(".inline").colorbox({
inline:true,
href:"#googleMap",
fixed:true,
onComplete: function(){
........*Error:Object expected...... initialize();
}
});
});
知道为什么会发生以及如何解决吗?
谢谢,