UNPKG

tedp

Version:

terra dp init

111 lines (91 loc) 2.9 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="./dist/tumap.js"></script> <style> * { margin: 0; padding: 0; } #mapContainer{ position:absolute; width:100%; height:100%; } .control-box{ position:absolute; right:10px; top:5px; background:rgba(0,0,0,.5); border:1px solid rgba(255,255,255,.8); border-radius: 6px; overflow: hidden; color:#fff; font-size:13px; padding: 5px; box-sizing: border-box; } .control-box>span{ margin-left: 5px; } .input-text{ width:120px; height:25px; line-height:25px; box-sizing: border-box; } .control-button{ height:25px; line-height:25px; cursor: pointer; padding: 2px 5px; box-sizing: border-box; margin-left:10px; } </style> </head> <body> <!--地图容器--> <div id="mapContainer"></div> <div class="control-box"> <span> 经度:</span> <input class="input-text" type="text" id="lg-text" value="117.0381" /> <span> 纬度:</span> <input class="input-text" type="text" id="lt-text" value="39.3826" /> <input class="control-button" type="button" value="转换" onclick="transformLocal()" > </div> <script type="text/javascript"> var map = TUMap.createMap({ //地图容器 id:"mapContainer", //UE4服务地址 必须设置 当前示例以地址栏地址 为服务地址 ,用户需要替换为自己的服务地址 url:window.parent.window.exampleServerUrl ,//"http://localhost:81/", onInit:function(){ transformWord(); } }) ; //如果想单独调换转换请使用 TUTransForm 类进行转换 需要指定中心点 // function transLocalMethod(){ // var trans = new TUTransForm({x:117.038112825, y:39.382696649}) ; // trans.transformWGS84ToLocal(); // trans.transformLocalToWGS84() // } //经纬度转 UE4坐标 function transformLocal( ){ var lg = document.getElementById("lg-text").value ; var lt = document.getElementById("lt-text").value ; var position = map.transformWGS84ToLocal(lg,lt) ; alert(JSON.stringify(position)) ; } //开启UE4坐标拾取 转经纬度 function transformWord(){ //开启提取 map.pickPosition(function(e){ alert(JSON.stringify(map.transformLocalToWGS84(e.location))); }); } </script> </body> </html>