123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>坐标转换</title>
- <script src="Common/mapClass/coordtransform.js"></script>
- <script>
- function btConvertClick(){
- var lng=document.getElementById("txtLng").value;
- var lat=document.getElementById("txtLat").value;
- var wgs84togcj02 = coordtransform.wgs84togcj02(lng, lat);
- document.getElementById("txtOutputX").value=wgs84togcj02[0];
- document.getElementById("txtOutputY").value=wgs84togcj02[1];
- var gcj02tobd09 = coordtransform.gcj02tobd09(wgs84togcj02[0], wgs84togcj02[1]);
- document.getElementById("txtOutputX1").value=gcj02tobd09[0];
- document.getElementById("txtOutputY1").value=gcj02tobd09[1];
- }
- //国测局坐标(火星坐标,比如高德地图在用),百度坐标,wgs84坐标(谷歌国外以及绝大部分国外在线地图使用的坐标)
- //百度经纬度坐标转国测局坐标
- //var bd09togcj02 = coordtransform.bd09togcj02(116.404, 39.915);
- //国测局坐标转百度经纬度坐标
- //var gcj02tobd09 = coordtransform.gcj02tobd09(116.404, 39.915);
- //wgs84转国测局坐标
- //var wgs84togcj02 = coordtransform.wgs84togcj02(116.404, 39.915);
- //国测局坐标转wgs84坐标
- //var gcj02towgs84 = coordtransform.gcj02towgs84(116.404, 39.915);
- //console.log(bd09togcj02);
- //console.log(gcj02tobd09);
- //console.log(wgs84togcj02);
- //console.log(gcj02towgs84);
- //result
- //bd09togcj02: [ 116.39762729119315, 39.90865673957631 ]
- //gcj02tobd09: [ 116.41036949371029, 39.92133699351021 ]
- //wgs84togcj02: [ 116.41024449916938, 39.91640428150164 ]
- //gcj02towgs84: [ 116.39775550083061, 39.91359571849836 ]
- </script>
- </head>
- <body>
- <div>
- <label>经纬度坐标</label>
- <input type="text" id="txtLng" value="121.419885">
- <input type="text" id="txtLat" style="display: inline" value="31.258565">
- <button onclick="btConvertClick()" style="display: inline">转换</button>
- </div>
- <div>
- <label>高德:</label>
- <input type="text" id="txtOutputX">
- <input type="text" id="txtOutputY" style="display: inline">
- </div>
- <div>
- <label>百度:</label>
- <input type="text" id="txtOutputX1">
- <input type="text" id="txtOutputY1" style="display: inline">
- </div>
- </body>
- </html>
|