码迷,mamicode.com
首页 > 其他好文 > 详细

坐标修正

时间:2014-10-15 18:31:21      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   ar   java   sp   div   on   cti   

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>常用坐标转换</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
<script type="text/javascript" src="http://dev.baidu.com/wiki/static/map/API/examples/script/convertor.js"></script></head>
<body>
<div style="width:520px;height:340px;border:1px solid gray" id="container"></div>
<div>谷歌(lng,lat)
<input style="width:150px" value="116.32715863448607" type="text" id="ggX" /><input style="width:150px" value="39.990912172420714" type="text" id="ggY" /><input value="google->baidu" type="button" onclick="ggxy()" />
GPS(lng,lat)
<input style="width:150px" value="116.397428" type="text" id="gpsX" /><input style="width:150px" value="39.90923" type="text" id="gpsY" /><input value="GPS->baidu" type="button" onclick="gpsxy()" />
百度(lng,lat)
<span id="baiduXY"> </span></div>
</body>
</html>
<script type="text/javascript">

var bm = new BMap.Map("container");
var point = new BMap.Point(116.404844,39.923125);
bm.centerAndZoom(point, 15);
bm.addControl(new BMap.NavigationControl());

ggxy = function (){
var x = document.getElementById("ggX").value;
var y = document.getElementById("ggY").value;
var ggPoint = new BMap.Point(x,y);
BMap.Convertor.translate(ggPoint,2,translateCallback);
}

gpsxy = function (){
var xx = document.getElementById("gpsX").value;
var yy = document.getElementById("gpsY").value;
var gpsPoint = new BMap.Point(xx,yy);
BMap.Convertor.translate(gpsPoint,0,translateCallback);
}
translateCallback = function (point){
bm.clearOverlays();
var marker = new BMap.Marker(point);
bm.addOverlay(marker);
bm.setCenter(point);
document.getElementById("baiduXY").innerHTML = point.lng + "," + point.lat;
}
</script>

坐标修正

标签:style   http   io   ar   java   sp   div   on   cti   

原文地址:http://www.cnblogs.com/qiaoxu/p/4026451.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!