请大家帮我看看,为什么这个网页在IE6.0中无法打开啊,我试过在firefox中正常。而且如果把编码从gb2312改为utf-8的话,IE也可以显示。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>路线地图</title>
<!--导入Google Maps API库文件。注意将本代码中的API Key替换为前文申请到的API Key-->
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA1j86tnUDFv8OAtC8dZVtKRT8YXSkg32FmSueYimfV_yj5DJguRRW5eQHwEBk10jwkDxLKNltT_kuQA" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
GMarker.prototype.setIndex = function(index)
{
this.index = index;
}
//用于标示路线的编辑状态
var status;
var isAdd=false;
var isDel=false;
var map;
var polyline;
var ers = [];
var infos=[];
//通过复制产生
var myIcon= new GIcon(G_DEFAULT_ICON, "http://www.google.com/mapfiles/er.png");
//创建地标
function createMarker(point,name)
{
var er = new GMarker(point, {icon: myIcon, draggable: true, bouncy: true});
var index = ers.length;
//dragstart事件,换新图标
GEvent.addListener(er, 'dragstart', function()
{
er.closeInfoWindow();
er.setImage("http://www.google.com/mapfiles/dd-start.png");
});
//dragend事件,换回原图标
GEvent.addListener(er, 'dragend', function()
{
infos[er.index]=null;
er.setImage("http://www.google.com/mapfiles/er.png");
});
//单击er显示或删除
GEvent.addListener(er, 'click', function()
{
if(!isAdd&&!isDel){
//输入地点名称
var temp=prompt("请输入当前位置名称:");
if(temp&&temp!=null){
infos[er.index]=temp;
}
var currentLatLng=er.getLatLng();
if(infos[er.index]&&infos[er.index]!=null){
er.openInfoWindow("当前位置为:"+infos[er.index]+" 坐标为:"+currentLatLng);
}
}
else if(isDel){
deleteMarker(er);
}
});
//mouseover事件,显示当前地点的信息
GEvent.addListener(er, 'mouseover', function()
{
if(infos[er.index]!=null&&infos[er.index]){
er.openInfoWindow("当前位置为:"+infos[er.index]+" 坐标为:"+er.getLatLng());
}
else
er.openInfoWindow("该点还没有名称");
});
//mouseout事件,关闭信息窗口
GEvent.addListener(er, 'mouseout', function()
{
er.closeInfoWindow();
});
//drag事件
//注意,如果添加了polyline,则拖动地标时需要重画路线
GEvent.addListener(er, 'drag', function()
{
redrawPolyline();
});
er.setIndex(index);
ers[index] = er;
infos[er.index]=name;
map.addOverlay(er);
//每创建一个新的地标就重画一次
redrawPolyline();
isAdd=false;
}
//删除该地标
function deleteMarker(er)
{
isDel=false;
//确定是否真的删除
if(!confirm("确定删除该地标吗?")) return;
var index = er.index;
//移除该图层
map.removeOverlay(er);
//从数组中删除指定GMarker并更新index
for(var i = index; i<ers.length-1; i++)
{
ers[i+1].setIndex(i);
ers[i] = ers[i+1];
infos[i]=infos[i+1];
}
infos.length=infos.length-1;
ers.length = ers.length-1;
redrawPolyline();
}
//添加行程路线
function addPolyline()
{
//创建
var points = [];
for(var i=0; i<ers.length; i++)
{
points[i] = ers[i].getPoint();
}
polyline = new GPolyline(
points, //GLatLng()数组
"#FF0000", //折线颜色
3, //折线宽度
0.5 //透明度
);
map.addOverlay(polyline);
}
//删除行程路线
function removePolyline()
{
// polyline.remove();
// polyline = null;
map.removeOverlay(polyline);
}
//重画行程路线
function redrawPolyline()
{
if(polyline)
{
removePolyline();
}
addPolyline();
}//------------------------------------------------------------------------------------------ function beginToAdd()
{
isAdd=true;
}
function beginToRemove()
{
isDel=true;
}
function load()
{
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
//map.enableGoogleBar();
map.disableDoubleClickZoom();
map.enableScrollWheelZoom();
var centerPoint= new GLatLng(39.92, 116.46);
map.setCenter(centerPoint, 4);
var myPoints=[];
var names=[];
myPoints[0]=new GLatLng(39.92,116.46);
myPoints[2]=new GLatLng(22.917,113.2);
myPoints[1]=new GLatLng(31,121);
names[0]="北京";
names[2]="上海";
names[1]="广州";
for(i=0;i<myPoints.length;i++)
//根据已有的点生成路线
createMarker(myPoints[i],names[i]);
GEvent.addListener(map, 'click', function(overlay, point)
{
if(point)
{
if(isAdd)
createMarker(point);
}
});
}
}
//提交路线信息
function submit(){
for(i=0;i<ers.length;i++)
{
alert(ers[i].getLatLng()+" :"+infos[i]);
}
}
//]]>
</script>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left: 738px;
top: 71px;
}
-->
</style>
</head>
<!--加载时调用load()函数加载地图,注意加上onunload="GUnload()"防止内存泄露-->
<body onload="load()" onunload="GUnload()">
<!--以下id为map的DIV元素即为Google地图的容器-->
<div id="map" style="width: 600px; height: 500px"></div>
<div>
<form id="form1" name="form1" target="test" method="post" action="">
<input name="button" type="button" id="btn_add" onclick="beginToAdd()" value="添加地点" />
<input name="btn_delete" type="button" id="btn_delete" onclick="beginToRemove()" value="删除地点" />
<input name="btn_submit" type="button" id="btn_submit" onclick="submit()" value="提交路线" />
</form>
</div>
<div id="bodyframe" style="VISIBILITY: hidden">
<iframe name="test"></iframe></div>
11
<form id="form2" name="form2" method="post" action="">
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>路线地图</title>
<!--导入Google Maps API库文件。注意将本代码中的API Key替换为前文申请到的API Key-->
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA1j86tnUDFv8OAtC8dZVtKRT8YXSkg32FmSueYimfV_yj5DJguRRW5eQHwEBk10jwkDxLKNltT_kuQA" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
GMarker.prototype.setIndex = function(index)
{
this.index = index;
}
//用于标示路线的编辑状态
var status;
var isAdd=false;
var isDel=false;
var map;
var polyline;
var ers = [];
var infos=[];
//通过复制产生
var myIcon= new GIcon(G_DEFAULT_ICON, "http://www.google.com/mapfiles/er.png");
//创建地标
function createMarker(point,name)
{
var er = new GMarker(point, {icon: myIcon, draggable: true, bouncy: true});
var index = ers.length;
//dragstart事件,换新图标
GEvent.addListener(er, 'dragstart', function()
{
er.closeInfoWindow();
er.setImage("http://www.google.com/mapfiles/dd-start.png");
});
//dragend事件,换回原图标
GEvent.addListener(er, 'dragend', function()
{
infos[er.index]=null;
er.setImage("http://www.google.com/mapfiles/er.png");
});
//单击er显示或删除
GEvent.addListener(er, 'click', function()
{
if(!isAdd&&!isDel){
//输入地点名称
var temp=prompt("请输入当前位置名称:");
if(temp&&temp!=null){
infos[er.index]=temp;
}
var currentLatLng=er.getLatLng();
if(infos[er.index]&&infos[er.index]!=null){
er.openInfoWindow("当前位置为:"+infos[er.index]+" 坐标为:"+currentLatLng);
}
}
else if(isDel){
deleteMarker(er);
}
});
//mouseover事件,显示当前地点的信息
GEvent.addListener(er, 'mouseover', function()
{
if(infos[er.index]!=null&&infos[er.index]){
er.openInfoWindow("当前位置为:"+infos[er.index]+" 坐标为:"+er.getLatLng());
}
else
er.openInfoWindow("该点还没有名称");
});
//mouseout事件,关闭信息窗口
GEvent.addListener(er, 'mouseout', function()
{
er.closeInfoWindow();
});
//drag事件
//注意,如果添加了polyline,则拖动地标时需要重画路线
GEvent.addListener(er, 'drag', function()
{
redrawPolyline();
});
er.setIndex(index);
ers[index] = er;
infos[er.index]=name;
map.addOverlay(er);
//每创建一个新的地标就重画一次
redrawPolyline();
isAdd=false;
}
//删除该地标
function deleteMarker(er)
{
isDel=false;
//确定是否真的删除
if(!confirm("确定删除该地标吗?")) return;
var index = er.index;
//移除该图层
map.removeOverlay(er);
//从数组中删除指定GMarker并更新index
for(var i = index; i<ers.length-1; i++)
{
ers[i+1].setIndex(i);
ers[i] = ers[i+1];
infos[i]=infos[i+1];
}
infos.length=infos.length-1;
ers.length = ers.length-1;
redrawPolyline();
}
//添加行程路线
function addPolyline()
{
//创建
var points = [];
for(var i=0; i<ers.length; i++)
{
points[i] = ers[i].getPoint();
}
polyline = new GPolyline(
points, //GLatLng()数组
"#FF0000", //折线颜色
3, //折线宽度
0.5 //透明度
);
map.addOverlay(polyline);
}
//删除行程路线
function removePolyline()
{
// polyline.remove();
// polyline = null;
map.removeOverlay(polyline);
}
//重画行程路线
function redrawPolyline()
{
if(polyline)
{
removePolyline();
}
addPolyline();
}//------------------------------------------------------------------------------------------ function beginToAdd()
{
isAdd=true;
}
function beginToRemove()
{
isDel=true;
}
function load()
{
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
//map.enableGoogleBar();
map.disableDoubleClickZoom();
map.enableScrollWheelZoom();
var centerPoint= new GLatLng(39.92, 116.46);
map.setCenter(centerPoint, 4);
var myPoints=[];
var names=[];
myPoints[0]=new GLatLng(39.92,116.46);
myPoints[2]=new GLatLng(22.917,113.2);
myPoints[1]=new GLatLng(31,121);
names[0]="北京";
names[2]="上海";
names[1]="广州";
for(i=0;i<myPoints.length;i++)
//根据已有的点生成路线
createMarker(myPoints[i],names[i]);
GEvent.addListener(map, 'click', function(overlay, point)
{
if(point)
{
if(isAdd)
createMarker(point);
}
});
}
}
//提交路线信息
function submit(){
for(i=0;i<ers.length;i++)
{
alert(ers[i].getLatLng()+" :"+infos[i]);
}
}
//]]>
</script>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left: 738px;
top: 71px;
}
-->
</style>
</head>
<!--加载时调用load()函数加载地图,注意加上onunload="GUnload()"防止内存泄露-->
<body onload="load()" onunload="GUnload()">
<!--以下id为map的DIV元素即为Google地图的容器-->
<div id="map" style="width: 600px; height: 500px"></div>
<div>
<form id="form1" name="form1" target="test" method="post" action="">
<input name="button" type="button" id="btn_add" onclick="beginToAdd()" value="添加地点" />
<input name="btn_delete" type="button" id="btn_delete" onclick="beginToRemove()" value="删除地点" />
<input name="btn_submit" type="button" id="btn_submit" onclick="submit()" value="提交路线" />
</form>
</div>
<div id="bodyframe" style="VISIBILITY: hidden">
<iframe name="test"></iframe></div>
11
<form id="form2" name="form2" method="post" action="">
</form>
</body>
</html>
http://hi.baidu.com/toosyer/blog/item/0800723d4e615ace9f3d62a5.html