| | |
| | | <!DOCTYPE html> |
| | | <html xmlns="http://www.w3.org/1999/xhtml"> |
| | | |
| | | <head> |
| | | <title>UE接口测试</title> |
| | | <meta http-equiv="Expires" content="0" /> |
| | |
| | | |
| | | // 坐标转化 |
| | | function transform() { |
| | | var trans = new TUTransForm({ x: 117.038112825, y: 39.382696649 }); |
| | | trans.transformWGS84ToLocal(); |
| | | trans.transformLocalToWGS84(); |
| | | var coordinate = { x: 117.038112825, y: 39.382696649 } |
| | | var Wgs84ToLocal = map.transformWGS84ToLocal(coordinate.x, coordinate.y) |
| | | console.log('Wgs84ToLocal', Wgs84ToLocal) |
| | | var LocalToWGS84 = map.transformLocalToWGS84(Wgs84ToLocal.x, coordinate.y) |
| | | console.log('LocalToWGS84', LocalToWGS84) |
| | | } |
| | | |
| | | // 获取镜头信息 |
| | |
| | | // 天气特效 |
| | | function setWeather() { |
| | | // sun-晴天 ,rain-雨天,snow-雪天 |
| | | map.setWeather("snow"); |
| | | map.setWeather('rain') // 晴天 |
| | | } |
| | | |
| | | // 时间特效 |
| | | function setTime() { |
| | | // morning-早晨,noon-中午,evening-傍晚,night-夜晚,darkWorld-暗色场景 |
| | | map.setTime("night"); |
| | | map.setTime("evening"); |
| | | } |
| | | |
| | | // 文字标签 |
| | |
| | | }; |
| | | |
| | | var lbl = map.createLabel(options); |
| | | lbl.show(true); // 显示 |
| | | // lbl.show(true); // 显示 |
| | | |
| | | // lbl.show(false); // 隐藏 |
| | | // lbl.removeFromMap(); // 移除 |
| | | // map.removeLabel(lbl.id); // 移除 |
| | | } |
| | | |
| | | // POI点 |
| | |
| | | clickedScale: 0.7, // 点击后比例 |
| | | visibility: true, // 默认是否显示 |
| | | alertWindow: { // 可选,点击弹窗 |
| | | url: "http://localhost/testAlertWindow.html", // 弹窗地址 |
| | | size: new Vector2(180, 90), // 弹窗大小 |
| | | offset: new Vector2(50, -100) // 弹窗位置,右:x正,下:y正 |
| | | url: "http://192.168.20.89:12306/popupThree.html", // 弹窗地址 |
| | | size: new TUVector2(180, 90), // 弹窗大小 |
| | | offset: new TUVector2(50, -100) // 弹窗位置,右:x正,下:y正 |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // 3DPOI点 |
| | | function create3DBillboard() { |
| | | var param = { |
| | | x: 1000, // x轴ue4坐标 |
| | | y: 1000, // y轴ue4坐标 |
| | | z: 0, // z轴ue4坐标 |
| | | image: "http://www.terra-it.cn/images/tubiao/indexLogo.png", // 图片地址 |
| | | scale: 0.5,//缩放 |
| | | clickedScale: 0.7, |
| | | visibility: true, // 默认是否显示 |
| | | alertWindow: { // 可选,点击弹窗 |
| | | url: "http://localhost/testAlertWindow.html", // 弹窗地址 |
| | | size: new Vector2(180, 90), // 弹窗大小 |
| | | offset: new Vector2(50, -100) // 弹窗位置,右:x正,下:y正 |
| | | } |
| | | } |
| | | var testPoints = [{ "x": 10000, "y": 10000, "z": 4000 }]; |
| | | var points = [] |
| | | testPoints.forEach(function (item) { |
| | | points.push({ |
| | | x: item.x, |
| | | y: item.y, |
| | | z: item.z, |
| | | image: "http://www.terra-it.cn/images/tubiao/indexLogo.png", |
| | | text: "", |
| | | scale: 20, |
| | | clickedScale: 1, |
| | | flash: false, |
| | | canClick: true, |
| | | |
| | | var poi = map.create3DBillboard(param); |
| | | poi.show(true); // 显示 |
| | | |
| | | var enable = true; // 是/否开启回调 |
| | | poi.Enable3DBillboardCallBack(enable, function (data) { |
| | | console.info(data); |
| | | }); |
| | | }); |
| | | poi = map.create3DBillboard(points) |
| | | poi.forEach(function (b) { |
| | | b.show(true) |
| | | }) |
| | | var enable = true; // 是/否开启回调 |
| | | obj = obj.concat(poi); |
| | | |
| | | // poi.show(false); // 隐藏 |
| | | // poi.removeFromMap(); // 移除 |
| | | } |
| | | |
| | | function creat() { |
| | | map.Enable3DBillboardCallBack(true, function (e) { |
| | | console.log(e, "11111111111") |
| | | }) |
| | | } |
| | | // 添加线路 |
| | | function createPolyline() { |
| | | var obj = map.createPolyline({ |
| | | pathWidth: 1000, // 路径宽度 |
| | | pathColor: "#00FF00", // 路径颜色 |
| | | type: 1, // 线路类型: 0高亮 1三角 2箭头 |
| | | data: [ // 路径点位数组,ue4坐标 |
| | | new TUVector3(-129.99, -7.41, 0), |
| | | new TUVector3(-131.00, -134.96, 0), |
| | | new TUVector3(113.83, -128.26, 0), |
| | | new TUVector3(123.84, -550.99, 0) |
| | | ] |
| | | // var obj = map.createPolyline({ |
| | | // pathWidth: 1000, // 路径宽度 |
| | | // pathColor: "#00FF00", // 路径颜色 |
| | | // type: 1, // 线路类型: 0高亮 1三角 2箭头 |
| | | // data: [ // 路径点位数组,ue4坐标 |
| | | // new TUVector3(-129.99, -7.41, 0), |
| | | // new TUVector3(-131.00, -134.96, 0), |
| | | // new TUVector3(113.83, -128.26, 0), |
| | | // new TUVector3(123.84, -550.99, 0) |
| | | // ] |
| | | // }); |
| | | var testPoints = [ |
| | | new TUVector3(77053.6953125, 150984.859375, 0), |
| | | new TUVector3(16167.91015625, 151470.453125, 0), |
| | | new TUVector3(14827.0908203125, 100942.328125, 0), |
| | | new TUVector3(71444.015625, 104834.4375, 0), |
| | | new TUVector3(67891.890625, 57269.85546875, 0), |
| | | new TUVector3(13084.04296875, 56401.7734375, 0), |
| | | new TUVector3(11550.640625, -13705.76953125, 0), |
| | | new TUVector3(7773.74560546875, -103738.140625, 0), |
| | | ]; |
| | | testPointArray = [] |
| | | //绘制路径 |
| | | pathObj = map.createPolyline({ |
| | | data: testPoints, |
| | | pathWidth: 3000, |
| | | type: 0,//0高亮线 1三角 2箭头 |
| | | pathColor: "cyan", |
| | | }); |
| | | |
| | | |
| | | var roll = 0, pitch = -45, yaw = 0, distance = 1000; |
| | | var callBack = function () { console.log("flyTo"); } |
| | | var time = 3; // 3s |
| | | |
| | | |
| | | map.flyTo(116.51446997, 39.772785555, 1000, roll, pitch, yaw, distance, callBack, time); |
| | | } |
| | | |
| | | // 添加区域 |
| | |
| | | color: "#ff0000", // 默认白色 |
| | | brightness: 10, // 默认10 |
| | | data: [ // 围栏点位数组 |
| | | new TUVector3(-129.99, -7.41, 0), |
| | | new TUVector3(-131.00, -134.96, 0), |
| | | new TUVector3(113.83, -128.26, 0), |
| | | new TUVector3(123.84, -550.99, 0) |
| | | new TUVector3(-129.99, -7.41, 0), |
| | | new TUVector3(-131.00, -134.96, 0), |
| | | new TUVector3(113.83, -128.26, 0), |
| | | new TUVector3(123.84, -550.99, 0) |
| | | ] |
| | | } |
| | | var bound = map.createAreaBoundary(param); |
| | |
| | | |
| | | // 拾取坐标 |
| | | function pickPosition() { |
| | | map.pickPosition(function (e) { |
| | | alert(JSON.stringify(e)); // e.objectName-内部编号,e.location-点位的ue4坐标 |
| | | map.endPick(); // 取消拾取 |
| | | }); |
| | | // map.pickPosition(function (e) { |
| | | |
| | | // alert(JSON.stringify(e)); // e.objectName-内部编号,e.location-点位的ue4坐标 |
| | | // map.endPick(); // 取消拾取 |
| | | // }); |
| | | |
| | | var vla = map.transformLocalToWGS84(map.camera.location.x, map.camera.location.y); |
| | | alert(JSON.stringify(vla)) |
| | | } |
| | | |
| | | // 拾取对象 |
| | | function pickObject() { |
| | | map.execute("factory", "callEvent", { eventName: "ClickObjectCallBack", param: "1" }, function (e) { |
| | | console.log(e); |
| | | map.execute("factory", "callEvent", { eventName: "ClickObjectCallBack", param: "0" }, null); // 取消拾取 |
| | | map.pickPosition(function (e) { |
| | | if (e) { |
| | | alert(JSON.stringify(e)) |
| | | } |
| | | }); |
| | | |
| | | // map.execute("factory", "callEvent", { eventName: "ClickObjectCallBack", param: "1" }, function (e) { |
| | | // console.log(e); |
| | | // map.execute("factory", "callEvent", { eventName: "ClickObjectCallBack", param: "0" }, null); // 取消拾取 |
| | | // }); |
| | | } |
| | | |
| | | // 清除 |
| | | function clear() { |
| | | map.resetWeather(); // 移除天气特效 |
| | | map.resetTime(); // 移除时间特效 |
| | | map.clearAllCovering(); // 清除所有覆盖物 |
| | | function objclear() { |
| | | map.clearAllCovering(); |
| | | } |
| | | |
| | | </script> |
| | | </head> |
| | | |
| | | <body> |
| | | <div id="map"></div> |
| | | |
| | |
| | | <button onclick="getCamera();">获取镜头信息</button> |
| | | <button onclick="flyTo();">飞行</button> |
| | | <button onclick="setView();">切换镜头</button> |
| | | <button onclick="setWeather();">天气特效</button> |
| | | <!-- <button onclick="setWeather();">天气特效</button> --> |
| | | <button onclick="setTime();">时间特效</button> |
| | | <button onclick="createLabel();">文字标签</button> |
| | | <button onclick="createBillboard();">POI点</button> |
| | | <button onclick="create3DBillboard();">3DPOI点</button> |
| | | <button onclick="createPolyline();">添加线路</button> |
| | | <!-- <button onclick="createPolyline();">添加线路</button> --> |
| | | <button onclick="createAreaData();">添加区域</button> |
| | | <button onclick="createCircleArea();">光圈</button> |
| | | <button onclick="createAreaBoundary();">围栏</button> |
| | | <button onclick="getMeasureHeight();">高度量测</button> |
| | | <!-- <button onclick="getMeasureHeight();">高度量测</button> |
| | | <button onclick="getDistanceHorizontal();">折线距离量测</button> |
| | | <button onclick="getPlaneArea();">平面面积量测</button> |
| | | <button onclick="pickPosition();">拾取坐标</button> |
| | | <button onclick="getPlaneArea();">平面面积量测</button> --> |
| | | <button onclick="pickPosition();">获取镜头坐标</button> |
| | | <button onclick="pickObject();">拾取对象</button> |
| | | <button onclick="clear();">清除</button> |
| | | <button onclick="objclear();">清除</button> |
| | | </div> |
| | | </body> |
| | | </html> |
| | | |
| | | </html> |