首页 > 代码库 > 经纬度坐标转换为百度坐标

经纬度坐标转换为百度坐标

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=rmtT1e2a4k770D9jK1ouGODt"></script>
<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>

 

BMap.Convertor.translate(point, 0, translateCallback);
function translateCallback(point1) {

 }

 

DEMO:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">    <title>百度地图</title>    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=rmtT1e2a4k770D9jK1ouGODt"></script>    <script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script></head><body>    <div style="width:1800px;height:1600px;border:1px solid gray" id="container"></div>    <script type="text/javascript">        var map = new BMap.Map("container");  // 创建地图实例        var longitude = "119.306667";//经度        var latitude = "26.075208";//纬度        var point = new BMap.Point(longitude, latitude);  // 创建点坐标        map.centerAndZoom(point, 15);  // 初始化地图,设置中心点坐标和地图级别        map.addControl(new BMap.NavigationControl()); //添加平移缩放控件        map.addControl(new BMap.ScaleControl());  //添加放大、缩小控件        map.enableScrollWheelZoom();//允许鼠标滑轮操作        var marker = new BMap.Marker(point);        map.setCenter(point);        map.addOverlay(marker);        BMap.Convertor.translate(point, 0, translateCallback);        function translateCallback(point1) {            var marker1 = new BMap.Marker(point1);            map.addOverlay(marker1);            var label = new BMap.Label("转换后的百度坐标", { offset: new BMap.Size(20, -10) });            marker1.setLabel(label); //添加百度label            map.setCenter(point1);        }    </script></body></html>

  

经纬度坐标转换为百度坐标