用Gmap api做了张地图,可是发现一个问题,在firefox下显示正常,在ie下浏览器会重置,调试了半天,也没搞定,先发了再说。代码如下:
代码开始
<script type=”text/javascript” src=”http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA43IALmfadaZgVb1L-IEizRT2DsZWTaQwEcLbsDtQz1jnLAblVRRx2_bEwFhsxfHsq9k-5A0PT7xjxw”>
</script><div id=”map” style=”width: 600px; height: 400px;”></div>
<script type=”text/javascript”>
//<![CDATA[
if (GBrowserIsCompatible()) {var map=new GMap(document.getElementById(“map”));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setMapType(G_HYBRID_TYPE);
map.centerAndZoom(new GPoint(121.5581,29.8394), 8);// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
var baseIcon = new GIcon();
baseIcon.shadow = “http://www.google.com/mapfiles/shadow50.png”;
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);// Create a lettered icon for this point using our icon class
var letter = String.fromCharCode(“A”.charCodeAt(0) + 25);
var icon0 = new GIcon(baseIcon);
icon0.image = “http://www.google.com/mapfiles/marker” + letter + “.png”;var ningbo = new GMarker(new GPoint(121.5581,29.83941),icon0);
GEvent.addListener(ningbo, “click”, function(){
ningbo.openInfoWindowHtml(“美女啊,我爱你啦!”);
});
map.addOverlay(ningbo);// Create a lettered icon for this point using our icon class
var letter = String.fromCharCode(“A”.charCodeAt(0) + 24);
var icon = new GIcon(baseIcon);
icon.image = “http://www.google.com/mapfiles/marker” + letter + “.png”;var zhoushan = new GMarker(new GPoint(122.1018,30.0207),icon);
GEvent.addListener(zhoushan, “click”, function(){
zhoushan.openInfoWindowHtml(“你说什么啊?我饭吃过啦!”);
});
map.addOverlay(zhoushan);}
//]]>
</script>
代码结束
google的api文挡里面的实例使用了
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 500px; height: 300px"></div>
</body>
我估计错误就出现在这个地方,donews的模板我好象设置不了body onload。