tedp
Version:
terra dp init
123 lines (100 loc) • 3.14 kB
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-button{
height:25px;
line-height:25px;
cursor: pointer;
padding: 2px 5px;
box-sizing: border-box;
margin-right:10px;
}
</style>
</head>
<body>
<!--地图容器-->
<div id="mapContainer"></div>
<div class="control-box">
<input type="button" class="control-button" value="创建效果" onclick="createHotMap()" >
<input type="button" class="control-button" value="显示" onclick="showHotMap(true)" >
<input type="button" class="control-button" value="隐藏" onclick="showHotMap(false)" >
<input type="button" class="control-button" value="移除效果" onclick="removeEffect()" >
</div>
<script type="text/javascript">
var map = TUMap.createMap({
//地图容器
id:"mapContainer",
//UE4服务地址 必须设置 当前示例以地址栏地址 为服务地址 ,用户需要替换为自己的服务地址
url:window.parent.window.exampleServerUrl ,//"http://localhost:81/",
onInit:function(){
createHotMap();
}
}) ;
//生成热力图
var heatMapObject ;
function createHotMap() {
//如果地图没初始化完不进行操作
if(!map.inited)
return ;
//如果有了删除重新创建
if(heatMapObject)
heatMapObject.removeFromMap();
//创建热力图
heatMapObject = map.createHeatmap({
data:createTestPoints(),
type:1
});
//移动到位置
map.focusOn(new TUVector3(-890,-150,1101), new TURotator(-6,-50,9),142461) ;
}
//当前视图范围内随机创建点
function createTestPoints(){
var points = [] ;
for (let i = 0; i < 80; i++) {
points.push({
location:new TUVector3(80000 * Math.random() ,80000 * Math.random(),0),
value:0.6,
radius:15000
});
}
return points ;
}
//显示隐藏热力图
function showHotMap(value) {
if (heatMapObject)
heatMapObject.show(value);
}
//移除效果
function removeEffect(){
if (heatMapObject)
heatMapObject.removeFromMap();
}
</script>
</body>
</html>