<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" c />
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}
#l-map{height:100%;width:78%;float:left;border-right:2px solid #bcbcbc;}
#r-result{height:100%;width:20%;float:left;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
<title>GPS转百度</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
//GPS坐标
var xx = 115.439365 ;
var yy = 30.242607;
var gpsPoint = new BMap.Point(xx,yy);
//地图初始化
var bm = new BMap.Map("allmap");
bm.centerAndZoom(gpsPoint, 15);
bm.addControl(new BMap.NavigationControl());
//添加谷歌marker和label
var markergps = new BMap.Marker(gpsPoint);
bm.addOverlay(markergps); //添加GPS标注
var labelgps = new BMap.Label("GPS",{offset:new BMap.Size(20,-10)});
markergps.setLabel(labelgps); //添加GPS标注
//坐标转换完之后的回调函数
translateCallback = function (point){
var marker = new BMap.Marker(point);
bm.addOverlay(marker);
var label = new BMap.Label("实际坐标",{offset:new BMap.Size(20,-10)});
marker.setLabel(label); //添加百度label
bm.setCenter(point);
alert(point.lng + "," + point.lat);
}
setTimeout(function(){
BMap.Convertor.translate(gpsPoint,0,translateCallback); //真实经纬度转成百度坐标
}, 2000);
</script>