| | |
| | | <meta http-equiv="Cache-control" content="no-cache" /> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> |
| | | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| | | <script src="js/jquery.1.12.4.js"></script> |
| | | <script src="js/tumap.js"></script> |
| | | <style> |
| | | html, |
| | |
| | | } |
| | | </style> |
| | | <script> |
| | | $(function () { |
| | | window.onload = function () { |
| | | window.map = new TUMap({ |
| | | id: 'map', // div的id |
| | | url: 'http://192.168.20.39:91', // UE服务地址 |
| | |
| | | console.log("初始化完成"); |
| | | } |
| | | }) |
| | | }); |
| | | } |
| | | |
| | | // 转为WGS84坐标 |
| | | function toWGS84() { |
| | | // 坐标转化 |
| | | function transform() { |
| | | var trans = new TUTransForm({ x: 117.038112825, y: 39.382696649 }); |
| | | trans.transformWGS84ToLocal(); |
| | | trans.transformLocalToWGS84(); |
| | | } |
| | | |
| | | // 转为UE坐标 |
| | | function toUECoord() { |
| | | |
| | | } |
| | | |
| | | // 获取镜头信息 |
| | |
| | | |
| | | // 飞行 |
| | | function flyTo() { |
| | | var x = 117.038112825, y = 39.382696649, z = 5000; |
| | | var roll = 0, pitch = 0, yaw = 0, distance = 1000; |
| | | var callBack = function () { console.log("flyTo"); } |
| | | var time = 3; // 3s |
| | | |
| | | map.flyTo(x, y, z, roll, pitch, yaw, distance, callBack, time); |
| | | } |
| | | |
| | | // 切换镜头 |
| | | function setView() { |
| | | var x = 117.038112825, y = 39.382696649, z = 5000; |
| | | var roll = 0, pitch = 0, yaw = 0, distance = 1000; |
| | | |
| | | map.setView(x, y, z, roll, pitch, yaw, distance); |
| | | } |
| | | |
| | | // 天气特效:sun-晴天 ,rain-雨天,snow-雪天 |
| | | // 天气特效 |
| | | function setWeather() { |
| | | // sun-晴天 ,rain-雨天,snow-雪天 |
| | | map.setWeather("snow"); |
| | | } |
| | | |
| | | // 时间特效:morning-早晨,noon-中午,evening-傍晚,night-夜晚,darkWorld-暗色场景 |
| | | // 时间特效 |
| | | function setTime() { |
| | | // morning-早晨,noon-中午,evening-傍晚,night-夜晚,darkWorld-暗色场景 |
| | | map.setTime("night"); |
| | | } |
| | | |
| | | // 文字标签 |
| | | function createLabel() { |
| | | var options = { |
| | | id: 1, //唯一标识,不可重复 可不填 |
| | | x: 1000, //x轴ue4坐标 |
| | | y: 1000, //y轴ue4坐标 |
| | | z: 0,//z轴ue4坐标 |
| | | vectorType: "WGS84",//坐标类型 2.1.5版本后可设置 |
| | | size: { width: 480, height: 180 },//label的大小 |
| | | text: '测试文字',//显示的文字 |
| | | scale: 1,//缩放 |
| | | type: 'Type1',//类型 Default,Type1,Type2 |
| | | backgroundColor: "#ffffff",//背景色 支持rgba TUColor |
| | | fillColor: "#00ff00",//文字颜色 |
| | | visibility: true//默认是否显示 |
| | | id: 1, // 唯一标识,不可重复,可不填 |
| | | x: 1000, // x轴ue4坐标 |
| | | y: 1000, // y轴ue4坐标 |
| | | z: 0, // z轴ue4坐标 |
| | | size: { width: 480, height: 180 }, // label的大小 |
| | | text: '测试文字', // 显示的文字 |
| | | scale: 1, // 缩放 |
| | | type: 'Type1', // 类型 Default,Type1,Type2 |
| | | backgroundColor: "#ffffff", // 背景色支持rgba |
| | | fillColor: "#00ff00", // 文字颜色 |
| | | visibility: true // 默认是否显示 |
| | | }; |
| | | |
| | | var lbl = map.createLabel(options); |
| | |
| | | y: 1000, // y轴ue4坐标 |
| | | z: 0, // z轴ue4坐标 |
| | | image: "http://www.terra-it.cn/images/tubiao/indexLogo.png", // 图片地址 |
| | | scale: 0.5,//缩放 |
| | | clickedScale: 0.7, |
| | | scale: 0.5, // 缩放比例 |
| | | clickedScale: 0.7, // 点击后比例 |
| | | visibility: true, // 默认是否显示 |
| | | alertWindow: { // 可选,点击弹窗 |
| | | url: "http://localhost/testAlertWindow.html", // 弹窗地址 |
| | |
| | | scale: 0.5,//缩放 |
| | | clickedScale: 0.7, |
| | | visibility: true, // 默认是否显示 |
| | | alertWindow: {//可选,点击弹窗 |
| | | alertWindow: { // 可选,点击弹窗 |
| | | url: "http://localhost/testAlertWindow.html", // 弹窗地址 |
| | | size: new Vector2(180, 90), // 弹窗大小 |
| | | offset: new Vector2(50, -100) // 弹窗位置,右:x正,下:y正 |
| | |
| | | var param = { |
| | | location: new TUVector3(0, 0, 0), // 中心点 |
| | | radius: 15000, |
| | | type: 2, //0上浮横格,1实色,2箭头,3三角 |
| | | type: 2, // 0上浮横格,1实色,2箭头,3三角 |
| | | color: "#ff0000", |
| | | height: 15000, //默认5000 |
| | | brightness: 10 //默认10 |
| | | height: 15000, // 默认5000 |
| | | brightness: 10 // 默认10 |
| | | } |
| | | var circle = map.createCircleArea(param); |
| | | // circle.removeFromMap(); // 移除 |
| | |
| | | map.resetTime(); // 移除时间特效 |
| | | map.clearAllCovering(); // 清除所有覆盖物 |
| | | } |
| | | |
| | | </script> |
| | | </head> |
| | | <body> |
| | | <div id="map"></div> |
| | | |
| | | <div id="container"> |
| | | <button onclick="toWGS84();">转为WGS84坐标</button> |
| | | <button onclick="toUECoord();">转为UE坐标</button> |
| | | <button onclick="transform();">坐标转换</button> |
| | | <button onclick="getCamera();">获取镜头信息</button> |
| | | <button onclick="flyTo();">飞行</button> |
| | | <button onclick="setView();">切换镜头</button> |