Commit e84c01ea authored by heng.zhang3@inzymeits.com's avatar heng.zhang3@inzymeits.com
Browse files

解决冲突

parents b2fcbd4b facd4f27
{
"liveServer.settings.port": 5501
}
\ No newline at end of file
<html>
<head>
<meta charset="utf-8">
<meta charset="utf-8" />
<title>示例集合</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
html {
margin: 0;
......@@ -134,18 +134,17 @@
<input type="button" id="removePerceptual" value="清除感知目标物" />
<input type="button" id="addPerceptualheat" value="添加交通热力图" />
<input type="button" id="deletePerceptualheat" value="删除交通热力图" />
</div>
<div>
<input type="button" id="addPerceptualheatEffect" value="热力图宏观效果" />
<input type="button" id="removePerceptualheatEffect" value="移除热力图宏观效果" />
<input type="button" id="addSignal" value="信号灯" />
<!-- <input type="button" id="CreateTIMSignal" value="创建停止线" />
<input type="button" id="DeleteTIMSignal" value="删除停止线" /> -->
<input type="button" id="CreateTIMSignal" value="创建停止线" />
<input type="button" id="DeleteTIMSignal" value="删除停止线" />
</div>
<div>
<input type="button" id="addTrafficIncident" value="开始交通事件" />
<input type="button" id="removeTrafficIncident" value="结束交通事件" />
<!-- <input type="button" id="removeTrafficIncident" value="结束交通事件" /> -->
</div>
<div>
<input type="button" id="bindHistoryVehicle" value="开始历史轨迹" />
......@@ -155,7 +154,7 @@
</div>
<div>
<input type="button" id="startV2X" value="开始V2X" />
<input type="button" id="hideV2X" value="隐藏V2X" />
<!-- <input type="button" id="hideV2X" value="隐藏V2X" /> -->
<input type="button" id="removeV2X" value="清除V2X" />
</div>
<div>
......@@ -164,8 +163,13 @@
<input type="button" id="hidePolygon" value="隐藏感知区域" />
<input type="button" id="removePolygon" value="删除感知区域" />
</div>
<div>
<input type="button" id="modelClickHighLight" value="注册场景内模型点击高亮" />
<input type="button" id="cancelModelHighlight" value="清除场景内模型高亮" />
<input type="button" id="modelClickRemove" value="注销场景内模型点击事件" />
</div>
</div>
<div id="main-container" style="width:100vw;height:100vh;overflow: hidden;"></div>
<div id="main-container" style="width: 100vw; height: 100vh; overflow: hidden"></div>
</body>
<script src="http://localhost:3000/gis_sdk/js/CMapLoader.map.js"></script>
<script src="./pathplan.js"></script>
......@@ -186,124 +190,94 @@
var trafficIncidentArr = [];//热力图否显示
var polygon = null; // 感知区域
//高亮模型Id
var highlightModelId = null;
var handler = (e) => {
alert(JSON.stringify(e))
alert(JSON.stringify(e));
};
initMap("51world")
initMap("51world");
async function initMap(gis_sdk) {
var url = "http://localhost:3000/hdmap-platform/gateway/cmap2"
var url = "http://localhost:3000/hdmap-platform/gateway/cmap2";
var secretKey = "10b79c61bf1b42e2";
var config = {
gis_sdk: gis_sdk
}
gis_sdk: gis_sdk,
};
config.gis_sdk = gis_sdk;
map = await CMapLoader.loadMap("main-container", config, url, secretKey);
await map.initMap();//地图加载
await map.initMap(); //地图加载
drawControl = map.getControl(1); //类型 1 :绘制 2:量算
measureControl = map.getControl(2); //类型 1 :绘制 2:量算
camera = map.getCamera()
camera = map.getCamera();
road = map.initRoads({
id: '1600840132389756930'
id: "1600840132389756930",
});
}
// 创建停止线
// document.getElementById("CreateTIMSignal").onclick = CreateTIMSignal;
async function CreateTIMSignal() {
const options = [
{
id: '1001',
startPosition: [117.31884370955275, 38.989795506281467],
endPosition: [117.31890374051923, 38.989940666684802]
},
{
id: '1002',
startPosition: [117.31886370955275, 38.989795506281467],
endPosition: [117.31892374051923, 38.989940666684802]
}
]
road.addSignalStopLine(options)
var focusjsondata = {
"longitude": 117.318852,
"latitude": 38.989403,
"height": 15,
}
map.setZoomAndCenter(focusjsondata)
}
// 删除停止线
// document.getElementById("DeleteTIMSignal").onclick = DeleteTIMSignal;
async function DeleteTIMSignal() {
road.removeSignalStopLine()
}
// 获取地图中心点和级别
document.getElementById("getZoomAndCenter").onclick = getZoomAndCenter;
async function getZoomAndCenter() {
var points = await map.getZoomAndCenter()
alert(JSON.stringify(points))
var points = await map.getZoomAndCenter();
alert(JSON.stringify(points));
}
// 设置地图中心点和级别
document.getElementById("setZoomAndCenter").onclick = setZoomAndCenter;
function setZoomAndCenter() {
var options = {
"longitude": 117.31884370955275,
"latitude": 38.989795506281467,
"height": 527.966445,
"zoom": 16
}
map.setZoomAndCenter(options)
longitude: 117.31884370955275,
latitude: 38.989795506281467,
height: 527.966445,
zoom: 16,
};
map.setZoomAndCenter(options);
}
// 限制地图显示范围和级别
document.getElementById("lockMap").onclick = lockMap;
function lockMap() {
var options = {
xmin: 117.31000,
xmin: 117.31,
ymin: 38.842072,
zmin: 500,
xmax: 117.37358,
ymax: 39.109915,
zmax: 15000
}
zmax: 15000,
};
var points = map.lockMap(options)
var points = map.lockMap(options);
}
// 解锁地图显示范围和级别
document.getElementById("unlockMap").onclick = unlockMap;
function unlockMap() {
map.unlockMap()
map.unlockMap();
}
// 获取相机参数
document.getElementById("getCameraView").onclick = getCameraView;
async function getCameraView() {
var points = await camera.getCameraView()
alert(JSON.stringify(points))
var points = await camera.getCameraView();
alert(JSON.stringify(points));
}
// 监听相机参数变化
document.getElementById("addCameraEvent").onclick = addCameraEvent;
function addCameraEvent() {
camera.addCameraEvent('changed', (e) => {
alert(JSON.stringify(e))
camera.addCameraEvent("changed", (e) => {
alert(JSON.stringify(e));
});
}
// 移除相机参数监听事件
document.getElementById("removeCameraEvent").onclick = removeCameraEvent;
function removeCameraEvent() {
camera.removeCameraEvent('changed');
camera.removeCameraEvent("changed");
}
// 设置相机
......@@ -312,8 +286,8 @@
var options = {
position: [117.3670360408276, 39.00412281044355, 276.84],
orientation: [0, -90],
}
camera.flyTo(options)
};
camera.flyTo(options);
}
// 开始相机导览
......@@ -324,65 +298,66 @@
pathList: [
{
cameraState: {
"longitude": 117.31875105674682,
"latitude": 38.98881187638633,
"height": 16.151980453069932,
"pitch": -3,
"heading": -89.45378112792969
longitude: 117.31875105674682,
latitude: 38.98881187638633,
height: 16.151980453069932,
pitch: -3,
heading: -89.45378112792969,
},
time: 10
time: 10,
},
{
cameraState: {
"longitude": 117.31839940049078,
"latitude": 38.99208154792654,
"height": 100.212235805514,
"pitch": -29.176807403564453,
"heading": 37.64432144165039
longitude: 117.31839940049078,
latitude: 38.99208154792654,
height: 100.212235805514,
pitch: -29.176807403564453,
heading: 37.64432144165039,
},
time: 10
time: 10,
},
{
cameraState: {
"longitude": 117.32332105679387,
"latitude": 38.99363368117575,
"height": 110.1469806258995,
"pitch": -33.12812805175781,
"heading": 130.16888427734375
longitude: 117.32332105679387,
latitude: 38.99363368117575,
height: 110.1469806258995,
pitch: -33.12812805175781,
heading: 130.16888427734375,
},
time: 10
time: 10,
},
]
}
camera.startFly(options)
],
};
camera.startFly(options);
}
// 暂停相机导览
document.getElementById("pauseFly").onclick = pauseFly;
function pauseFly() {
camera.pauseFly()
camera.pauseFly();
}
// 继续相机导览
document.getElementById("resuFly").onclick = resuFly;
function resuFly() {
camera.resuFly()
camera.resuFly();
}
// 结束相机导览
document.getElementById("stopFly").onclick = stopFly;
function stopFly() {
camera.stopFly()
camera.stopFly();
}
// 地图变化事件
document.getElementById("addMapChangeEvent").onclick = addMapChangeEvent;
function addMapChangeEvent() {
map.on(map.EventType.MAP_CHANGE, handler)
map.on(map.EventType.MAP_CHANGE, handler);
}
// 注销地图变化事件
document.getElementById("removeMapChangeEvent").onclick = removeMapChangeEvent;
document.getElementById("removeMapChangeEvent").onclick =
removeMapChangeEvent;
function removeMapChangeEvent() {
map.off(map.EventType.MAP_CHANGE, handler);
}
......@@ -390,11 +365,12 @@
// 注册鼠标点击事件
document.getElementById("addMouseClickEvent").onclick = addMouseClickEvent;
function addMouseClickEvent() {
map.on(map.EventType.LEFT_CLICK, handler)
map.on(map.EventType.LEFT_CLICK, handler);
}
// 注销鼠标点击事件
document.getElementById("removeMouseClickEvent").onclick = removeMouseClickEvent;
document.getElementById("removeMouseClickEvent").onclick =
removeMouseClickEvent;
function removeMouseClickEvent() {
map.off(map.EventType.LEFT_CLICK, handler);
}
......@@ -402,17 +378,19 @@
// 注册模型点击事件
let clickModel = null;
let pick_model_handler = (e) => {
console.log("模型点击事件", e);
if (e) {
pickModel = map.getModel(e);
if (pickModel) {
// 高亮
pickModel.highLight();
var content = content = {
var content = (content = {
popupSize: [200, 200],
imagePath: `@path:images/radar_online.png`,
popupURL: `http://172.29.128.30:65535/yizhuangDevicePopup.html?name=汽车&brand=厂商&code=型号&mode=通信模式`
};
popupURL: `http://172.29.128.30:65535/yizhuangDevicePopup.html?name=汽车&brand=厂商&code=型号&mode=通信模式`,
});
pickModel.showPopup(content);
}
......@@ -422,19 +400,20 @@
async function addModelClickEvent() {
if (!clickModel) {
let option = {
"id": "model1", //对象ID
"url": 'SM_VEH_Bus_02_01',
"position": [117.318863, 38.989795, 4],//坐标
"rotation": [0, 0, 190],
}
id: "model1", //对象ID
url: "SM_VEH_Bus_02_01",
position: [117.318863, 38.989795, 4], //坐标
rotation: [0, 0, 190],
};
clickModel = await map.addModel(option);
clickModel.focusModel();
}
map.on(map.EventType.PICK_MODEL, pick_model_handler)
map.on(map.EventType.PICK_MODEL, pick_model_handler);
}
// 注销模型点击事件
document.getElementById("removeModelClickEvent").onclick = removeModelClickEvent;
document.getElementById("removeModelClickEvent").onclick =
removeModelClickEvent;
async function removeModelClickEvent() {
map.off(map.EventType.PICK_MODEL, pick_model_handler);
}
......@@ -451,22 +430,21 @@
pickModel.removePopup();
}
// 添加路口标签
document.getElementById("addMarker").onclick = addMarker;
async function addMarker() {
var options = {
id: "marker",
name: '一号路口',
name: "一号路口",
textColor: [255, 215, 0, 1],
fontSize: '16',
fontSize: "16",
position: [117.318863, 38.98979], //设置Marker位置
imageSize: [184, 126], //[1.5,1.6]
textOffset: [50, 50],//[0, -140]
image: "http://wdpapi.51aes.com/doc-static/images/static/markerNormal.png",//mapbox图片
iconOffset: [0, -80] //mapbox图标的偏移
}
textOffset: [50, 50], //[0, -140]
image:
"http://wdpapi.51aes.com/doc-static/images/static/markerNormal.png", //mapbox图片
iconOffset: [0, -80], //mapbox图标的偏移
};
// 添加路口标签
marker = await map.addMarkerOverlay(options);
......@@ -482,65 +460,62 @@
// 隐藏标签
document.getElementById("hideMarker").onclick = hideMarker;
function hideMarker() {
map.hideOverlay(marker)
map.hideOverlay(marker);
}
// 删除标签
document.getElementById("removeMarker").onclick = removeMarker;
async function removeMarker() {
map.removeOverlay(marker)
map.removeOverlay(marker);
}
// 开始Rsu特效
document.getElementById("startRsu").onclick = startRsu;
function startRsu() {
var data =
[
{
"equipmentCode": "S-LC-2503",//编号
"longitude": 117.318166,
"latitude": 38.98827,
"height": 5,
"radius": 20,//辐射圈的大小,这个字段目前是晶众使用有效
},
{
"equipmentCode": "S-LC-2504",//编号
"longitude": 117.319236,
"latitude": 38.98829,
"height": 5,
"radius": 20,//辐射圈的大小,这个字段目前是晶众使用有效
}
]
rsuArr = road.startRsu(data)
var data = [
{
equipmentCode: "S-LC-2503", //编号
longitude: 117.318166,
latitude: 38.98827,
height: 5,
radius: 20, //辐射圈的大小,这个字段目前是晶众使用有效
},
{
equipmentCode: "S-LC-2504", //编号
longitude: 117.319236,
latitude: 38.98829,
height: 5,
radius: 20, //辐射圈的大小,这个字段目前是晶众使用有效
},
];
rsuArr = road.startRsu(data);
}
// 停止Rsu特效
document.getElementById("stopRsu").onclick = stopRsu;
function stopRsu() {
road.stopRsu()
road.stopRsu();
}
// 隐藏Rsu特效
document.getElementById("hideRsu").onclick = hideRsu;
function hideRsu() {
road.hideRsu()
road.hideRsu();
}
// 显示Rsu特效
document.getElementById("showRsu").onclick = showRsu;
function showRsu() {
road.showRsu()
road.showRsu();
}
// 开始下雨
document.getElementById("rain").onclick = rain;
async function rain() {
map.addRainEffect({
speed: 0.5, // 速度,取值范围:[0~1],默认为0.5
size: 0.5, // 大小,取值范围:[0~1],默认为0.5
density: 0.5 // 密度,取值范围:[0~1],默认为0.5
speed: 0.5, // 速度,取值范围:[0~1],默认为0.5
size: 0.5, // 大小,取值范围:[0~1],默认为0.5
density: 0.5, // 密度,取值范围:[0~1],默认为0.5
});
}
......@@ -554,9 +529,9 @@
document.getElementById("snow").onclick = snow;
async function snow() {
map.addSnowEffect({
speed: 0.5, // 速度,取值范围:[0~1],默认为0.5
size: 0.5, // 大小,取值范围:[0~1],默认为0.5
density: 0.5 // 密度,取值范围:[0~1],默认为0.5
speed: 0.5, // 速度,取值范围:[0~1],默认为0.5
size: 0.5, // 大小,取值范围:[0~1],默认为0.5
density: 0.5, // 密度,取值范围:[0~1],默认为0.5
});
}
......@@ -581,38 +556,44 @@
// 绘制点
document.getElementById("point").onclick = point;
function point() {
drawControl.startDraw({
type: 'point'
}, function (e) {
console.log(e)
})
drawControl.startDraw(
{
type: "point",
},
function (e) {
console.log(e);
}
);
}
// 绘制线
document.getElementById("polyline").onclick = polyline;
async function polyline() {
drawControl.startDraw({
type: 'polyline',
lineColor: [255, 246, 45, 0.5],
width: 1
}, function (e) {
console.log(e)
})
drawControl.startDraw(
{
type: "polyline",
lineColor: [255, 246, 45, 0.5],
width: 1,
},
function (e) {
console.log(e);
}
);
}
// 绘制面
document.getElementById("polygon").onclick = polygon;
async function polygon() {
drawControl.startDraw({
type: 'polygon',
fill: [255, 246, 45, 0.5],
lineColor: [0, 255, 0, 0.5],
}, function (e) {
console.log(e)
})
drawControl.startDraw(
{
type: "polygon",
fill: [255, 246, 45, 0.5],
lineColor: [0, 255, 0, 0.5],
},
function (e) {
console.log(e);
}
);
}
// 清除绘制
......@@ -624,61 +605,62 @@
// 坐标点
document.getElementById("start1").onclick = start1;
async function start1() {
measureControl.startMeasurement(1) //1:坐标点 2:直线测量 6 :地表面积
measureControl.startMeasurement(1); //1:坐标点 2:直线测量 6 :地表面积
}
// 直线测量
document.getElementById("start2").onclick = start2;
async function start2() {
measureControl.startMeasurement(2, {
pointSize: 4, // 点大小
pointColor: [33, 176, 219], // 点颜色
textSize: 16, // 文字大小
textColor: [239, 76, 41], // 文字颜色
lineWidth: 2, // 线宽度
lineColor: [33, 176, 219], // 线颜色
}) //1:坐标点 2:直线测量 6 :地表面积
pointSize: 4, // 点大小
pointColor: [33, 176, 219], // 点颜色
textSize: 16, // 文字大小
textColor: [239, 76, 41], // 文字颜色
lineWidth: 2, // 线宽度
lineColor: [33, 176, 219], // 线颜色
}); //1:坐标点 2:直线测量 6 :地表面积
}
// 地表面积
document.getElementById("start6").onclick = start6;
async function start6() {
measureControl.startMeasurement(6, {
pointSize: 4, // 点大小
pointColor: [33, 176, 219], // 点颜色
textSize: 16, // 文字大小
textColor: [239, 76, 41], // 文字颜色
lineColor: [33, 176, 219], // 边框颜色
lineWidth: 2, // 边框宽度
fillColor: [33, 176, 219], // 线颜色
}) //1:坐标点 2:直线测量 6 :地表面积
pointSize: 4, // 点大小
pointColor: [33, 176, 219], // 点颜色
textSize: 16, // 文字大小
textColor: [239, 76, 41], // 文字颜色
lineColor: [33, 176, 219], // 边框颜色
lineWidth: 2, // 边框宽度
fillColor: [33, 176, 219], // 线颜色
}); //1:坐标点 2:直线测量 6 :地表面积
}
// 停止量算
document.getElementById("stopMeasurement").onclick = stopMeasurement;
async function stopMeasurement() {
measureControl.stopMeasurement()
measureControl.stopMeasurement();
}
// 创建指北针
document.getElementById("toNorth").onclick = toNorth;
async function toNorth() {
if (compassItem) return
if (compassItem) return;
// 绑定指北针
compassItem = new map.widgets.Compass({
position: {
left: '20px',
top: '60px'
left: "20px",
top: "60px",
},
declaredClass: ['compass-class'],
iconClass: 'https://th.bing.com/th/id/R.9ac814eb0d80f60139dc27d8ef3193ad?rik=MLzrMDu9QdKAOQ&riu=http%3a%2f%2fpic.ntimg.cn%2ffile%2f20150530%2f2531170_201029314000_2.jpg&ehk=JODHCujwu7ut71vU4vVswA%2f3ljNn9MAdpziiOQMxFnE%3d&risl=&pid=ImgRaw&r=0'//替换指北针图片
})
declaredClass: ["compass-class"],
iconClass:
"https://th.bing.com/th/id/R.9ac814eb0d80f60139dc27d8ef3193ad?rik=MLzrMDu9QdKAOQ&riu=http%3a%2f%2fpic.ntimg.cn%2ffile%2f20150530%2f2531170_201029314000_2.jpg&ehk=JODHCujwu7ut71vU4vVswA%2f3ljNn9MAdpziiOQMxFnE%3d&risl=&pid=ImgRaw&r=0", //替换指北针图片
});
}
// 销毁指南针
document.getElementById("hideNorth").onclick = hideNorth;
async function hideNorth() {
if (!compassItem) return
if (!compassItem) return;
// 销毁
compassItem.destroy();
compassItem = null;
......@@ -689,9 +671,9 @@
async function setDark() {
let option = {
dark: true,
time: 1668009599000
}
map.setDark(option)
time: 1668009599000,
};
map.setDark(option);
}
// 取消夜景
......@@ -699,18 +681,17 @@
async function setday() {
let option = {
dark: false,
time: 1667966400000
}
map.setDark(option)
time: 1667966400000,
};
map.setDark(option);
}
// 创建交通流
document.getElementById("addTrafficFlow").onclick = addTrafficFlow;
async function addTrafficFlow() {
const json = {
id: '21e7a9e6d2884122804788dac1e002cc',
url: 'ws://192.168.60.137:31000/ws/streamer/9e841c8a3f5947559797887ba04779b7'
url: 'ws://192.168.60.137:31000/ws/streamer/b35bb454ccdb4c57b5529bb2976c02c8'
}
map.bindVehicle(json)
}
......@@ -718,53 +699,53 @@
// 删除交通流
document.getElementById("removeTrafficFlow").onclick = removeTrafficFlow;
async function removeTrafficFlow() {
map.removeVehicles()
map.removeVehicles();
}
// 定位车辆(第一人称)
document.getElementById("focusCar1").onclick = focusCar1;
async function focusCar1() {
let options = {
"vehicleId": '仿AYZQS001',
"perspective": 1 // 1第一人称视角、3第三人称视角
}
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").focusVehicle(options)
vehicleId: "仿AYZQS001",
perspective: 1, // 1第一人称视角、3第三人称视角
};
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").focusVehicle(options);
}
// 定位车辆(第三人称)
document.getElementById("focusCar3").onclick = focusCar3;
async function focusCar3() {
let options = {
"vehicleId": '仿AYZQS001',
"perspective": 3 // 1第一人称视角、3第三人称视角
}
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").focusVehicle(options)
vehicleId: "仿AYZQS001",
perspective: 3, // 1第一人称视角、3第三人称视角
};
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").focusVehicle(options);
}
// 清除定位
document.getElementById("focusNoneCar").onclick = focusNoneCar;
async function focusNoneCar() {
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").unfocusVehicle()
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").unfocusVehicle();
}
// 加载车辆路径规划
document.getElementById("loadarrowLineLaye").onclick = loadarrowLineLaye;
function loadarrowLineLaye() {
let timestamp = 1739419194500
var pp = []
let timestamp = 1739419194500;
var pp = [];
for (var key in roadPoints) {
timestamp = timestamp + 2000
timestamp = timestamp + 2000;
let tt = {
"vid": "1",
"vmodel": "1020001",
"vtype": "0",
"coord": roadPoints[key][0] + ',' + roadPoints[key][1] + ',' + '0.00',
"speed": 46.92,
"timestamp": timestamp
}
pp.push(tt)
vid: "1",
vmodel: "1020001",
vtype: "0",
coord: roadPoints[key][0] + "," + roadPoints[key][1] + "," + "0.00",
speed: 46.92,
timestamp: timestamp,
};
pp.push(tt);
}
console.log(pp)
console.log(pp);
//行驶路线
// var option = {
// "id": '1604729991369719809',
......@@ -780,19 +761,19 @@
// 清除车辆路径规划
document.getElementById("cleanarrowLineLaye").onclick = cleanarrowLineLaye;
function cleanarrowLineLaye() {
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").removeRoute()
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").removeRoute();
}
// 显示车辆路径规划
document.getElementById("showRoute").onclick = showRoute;
function showRoute() {
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").showRoute()
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").showRoute();
}
// 隐藏车辆路径规划
document.getElementById("hideRoute").onclick = hideRoute;
function hideRoute() {
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").hideRoute()
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").hideRoute();
}
// 创建感知目标物
......@@ -800,14 +781,15 @@
async function loadPerceptual() {
if (perceptualroad == null) {
perceptualroad = map.initRoads({
id: '123456789'
id: "123456789",
});
}
const json = {
id: '111',//ID
url: 'ws://192.168.60.137:33011/InfoTrans',
}
perceptualroad.bindObjects(json)
id: "111", //ID
// url: "ws://192.168.60.137:33011/InfoTrans", //
url: 'ws://192.168.60.137:31000/ws/streamer/7d72c2a7c3b4440c8a975a3205316171'
};
perceptualroad.bindObjects(json);
perceptual = true; //是否加载了感知物
}
// 显示感知目标物
......@@ -830,191 +812,266 @@
document.getElementById("addPerceptualheat").onclick = addPerceptualheat;
async function addPerceptualheat() {
const json = {
id: '222',//ID
height: '10',//高度
opacity: '0.75',//透明度
dataUrl: 'D://51world//rlt//hdmap1.4(GCJ02_Ortho)_v2.xodr',//文件地址
url: 'ws://192.168.60.137:33021/AnalyzeResult',//ws地址
id: "222", //ID
height: "10", //高度
opacity: "0.75", //透明度
dataUrl: "D://51world//rlt//hdmap1.4(GCJ02_Ortho)_v2.xodr", //文件地址
url: "ws://192.168.60.137:33021/AnalyzeResult", //ws地址
colorSymbols: [
{ "minSpeed": 0, "maxSpeed": 30, "color": "#FF0000" },
{ "minSpeed": 30, "maxSpeed": 60, "color": "#FFFF00" },
{ "minSpeed": 60, "maxSpeed": 90, "color": "#0000FF" },
{ "minSpeed": 90, "maxSpeed": 200, "color": "#00FF00" }
] //颜色
}
perceptualroad.bindPerceptualheat(json)
perceptualshow = true
{ minSpeed: 0, maxSpeed: 30, color: "#FF0000" },
{ minSpeed: 30, maxSpeed: 60, color: "#FFFF00" },
{ minSpeed: 60, maxSpeed: 90, color: "#0000FF" },
{ minSpeed: 90, maxSpeed: 200, color: "#00FF00" },
], //颜色
};
perceptualroad.bindPerceptualheat(json);
perceptualshow = true;
}
// 删除交通热力图
document.getElementById("deletePerceptualheat").onclick = deletePerceptualheat;
document.getElementById("deletePerceptualheat").onclick =
deletePerceptualheat;
async function deletePerceptualheat() {
perceptualroad.getPerceptualheat("222").remove()
perceptualshow = false
perceptualroad.getPerceptualheat("222").remove();
perceptualshow = false;
}
// 交通热力图宏观效果
document.getElementById("addPerceptualheatEffect").onclick = addPerceptualheatEffect;
document.getElementById("addPerceptualheatEffect").onclick =
addPerceptualheatEffect;
async function addPerceptualheatEffect() {
if (!perceptual) {
loadPerceptual()//加载感知物
loadPerceptual(); //加载感知物
}
map.on(map.EventType.MAP_CHANGE, PerceptualheatEffecthandler)
map.on(map.EventType.MAP_CHANGE, PerceptualheatEffecthandler);
}
PerceptualheatEffecthandler = (e) => {
let result = JSON.stringify(e)
console.log("高度为====" + e.height)
let result = JSON.stringify(e);
console.log("高度为====" + e.height);
if (e.height > 500) {
hidePerceptual()
hidePerceptual();
if (!perceptualshow) {
addPerceptualheat()
addPerceptualheat();
}
} else {
showPerceptual()
showPerceptual();
if (perceptualshow) {
deletePerceptualheat()
deletePerceptualheat();
}
}
};
// 移除交通热力图宏观效果
document.getElementById("removePerceptualheatEffect").onclick = removePerceptualheatEffect;
document.getElementById("removePerceptualheatEffect").onclick =
removePerceptualheatEffect;
async function removePerceptualheatEffect() {
map.off(map.EventType.MAP_CHANGE, PerceptualheatEffecthandler);
removePerceptual()
deletePerceptualheat()
removePerceptual();
deletePerceptualheat();
}
//添加信号灯
document.getElementById("addSignal").onclick = addSignal;
function addSignal() {
let options = {
position: [117.325673, 38.996374, 10.53],
orientation: [-34.930073, -44.426579]
}
camera.flyTo(options)
orientation: [-34.930073, -44.426579],
};
camera.flyTo(options);
road.initSignals({
id: '51worldinitSignals',//ID
url: 'wss://itg-dev.cu-sc.com:13443/WSPLUS/socket?msgType=3'
id: "51worldinitSignals", //ID
url: "wss://itg-dev.cu-sc.com:13443/WSPLUS/socket?token=111&msgType=3&reType=51world",
});
}
// 创建停止线
// document.getElementById("CreateTIMSignal").onclick = CreateTIMSignal;
async function CreateTIMSignal() {
const options = [
{
id: "1001",
startPosition: [117.31884370955275, 38.989795506281467],
endPosition: [117.31890374051923, 38.989940666684802],
},
{
id: "1002",
startPosition: [117.31886370955275, 38.989795506281467],
endPosition: [117.31892374051923, 38.989940666684802],
},
];
road.addSignalStopLine(options);
var focusjsondata = {
longitude: 117.318852,
latitude: 38.989403,
height: 15,
};
map.setZoomAndCenter(focusjsondata);
}
// 删除停止线
// document.getElementById("DeleteTIMSignal").onclick = DeleteTIMSignal;
async function DeleteTIMSignal() {
road.removeSignalStopLine();
}
//开始交通事件
document.getElementById("addTrafficIncident").onclick = addTrafficIncident;
async function addTrafficIncident() {
let options = {
position: [117.325401, 38.996133, 28.12],
orientation: [-34.930073, -44.426579]
}
camera.flyTo(options)
orientation: [-34.930073, -44.426579],
};
camera.flyTo(options);
const json = {
"msgId": "973fcdea-e1ea-4fe7-af1c-9ea4e7b637af",
"msgType": "ROADSIDE_TRAFFIC_EVENT",
"deviceId": null,
"collectTime": null,
"reportTime": 1741777564646,
"receiveTime": null,
"message": {
"id": "600354",
"type": "ABNORMAL_PARKING_ALERT",
"type": "9",
"name": "异常停车预警",
"ptcIds": null,
"location": [
msgId: "973fcdea-e1ea-4fe7-af1c-9ea4e7b637af",
msgType: "ROADSIDE_TRAFFIC_EVENT",
deviceId: null,
collectTime: null,
reportTime: 1741777564646,
receiveTime: null,
message: {
id: "600354",
type: "ROADSIDE_TRAFFIC_EVENT",
type: "1",
name: "异常停车预警",
// ptcIds: ['1200002282'], //字符串数组
location: [
{
"longitude": 117.32559766689558,
"latitude": 38.99628656347781,
"elevation": null
}
longitude: 117.32559766689558,
latitude: 38.99628656347781,
elevation: null,
},
],
"level": 1,
"description": null,
"imagesUrl": null,
"videosUrl": null,
"startTime": null,
"endTime": null,
"reportTime": null,
"mqttTime": null,
"accessTime": null,
"eventStatus": 0
}
}
level: 1,
description: null,
imagesUrl: null,
videosUrl: null,
startTime: null,
endTime: null,
reportTime: null,
mqttTime: null,
accessTime: null,
eventStatus: 0,
},
};
trafficIncidentArr = await map.renderTrafficIncident(json)
console.log("tc.................", trafficIncidentArr)
trafficIncidentArr = await map.renderTrafficIncident(json);
console.log("tc.................", trafficIncidentArr);
let index = 0;
const timer = setInterval(async () => {
if (index == 20) {
json.endTime = 1741777564646
trafficIncidentArr = await map.renderTrafficIncident(json)
clearInterval(timer)
json.endTime = 1741777564646;
trafficIncidentArr = await map.renderTrafficIncident(json);
clearInterval(timer);
}
index++;
}, 200)
}
//结束交通事件
document.getElementById("removeTrafficIncident").onclick = removeTrafficIncident;
async function removeTrafficIncident() {
trafficIncidentArr.forEach(item => {
map.stopTrafficIncident(item.trafficIncidentId)
})
}
}, 200);
}
// //结束交通事件
// document.getElementById("removeTrafficIncident").onclick = removeTrafficIncident;
// async function removeTrafficIncident() {
// const json = {
// msgId: "973fcdea-e1ea-4fe7-af1c-9ea4e7b637af",
// msgType: "ROADSIDE_TRAFFIC_EVENT",
// deviceId: null,
// collectTime: null,
// reportTime: 1741777564646,
// receiveTime: null,
// message: {
// id: "600354",
// type: "ROADSIDE_TRAFFIC_EVENT",
// type: "1",
// name: "异常停车预警",
// ptcIds: ['1200002282'], //字符串数组
// location: [
// {
// longitude: 117.32559766689558,
// latitude: 38.99628656347781,
// elevation: null,
// },
// ],
// level: 1,
// description: null,
// imagesUrl: null,
// videosUrl: null,
// startTime: null,
// endTime: 1741777564646,
// reportTime: null,
// mqttTime: null,
// accessTime: null,
// eventStatus: 0,
// },
// };
// trafficIncidentArr.forEach((item) => {
// map.stopTrafficIncident(item.trafficIncidentId, json);
// });
// }
//开始历史轨迹
document.getElementById("bindHistoryVehicle").onclick = bindHistoryVehicle;
async function bindHistoryVehicle() {
let options = {
position: [117.36914548090871335, 39.01187038664559026, 100.12],
orientation: [-90, 0]
}
camera.flyTo(options)
orientation: [-90, 0],
};
camera.flyTo(options);
const json = {
id: '21002cc',
url: 'ws://192.168.60.137:31000/ws/streamer/2a9e3045-8ff6-4da8-970c-8bb1e4ca1ed9'
}
map.bindHistoryVehicle(json)
id: "21002cc",
url: "ws://192.168.60.137:31000/ws/streamer/2a9e3045-8ff6-4da8-970c-8bb1e4ca1ed9",
};
map.bindHistoryVehicle(json);
}
//结束历史轨迹
document.getElementById("removeHistoryVehicle").onclick = removeHistoryVehicle;
document.getElementById("removeHistoryVehicle").onclick =
removeHistoryVehicle;
async function removeHistoryVehicle() {
map.removeHistoryVehicle()
map.removeHistoryVehicle();
}
// 暂停历史轨迹
document.getElementById("pauseHistoryVehicle").onclick = pauseHistoryVehicle;
document.getElementById("pauseHistoryVehicle").onclick =
pauseHistoryVehicle;
function pauseHistoryVehicle() {
map.pauseHistoryVehicle('21002cc')
map.pauseHistoryVehicle("21002cc");
}
// 重新开始历史轨迹
document.getElementById("resumeHistoryVehicle").onclick = resumeHistoryVehicle;
document.getElementById("resumeHistoryVehicle").onclick =
resumeHistoryVehicle;
function resumeHistoryVehicle() {
map.resumeHistoryVehicle('21002cc')
map.resumeHistoryVehicle("21002cc");
}
// 开始V2V
document.getElementById("startV2X").onclick = startV2X;
function startV2X() {
let options = {
color: [255, 0, 0, 1],
vehicleId: "鄂A17U5N"
}
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").startV2x(options)
color: [255, 255, 0, 1],
// vehicleId: "仿AYZQS001", //鄂A17U5N
vehicleId: "测试车辆001", //鄂A17U5N
name: '注意行人'
};
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").startV2x(options);
}
// 隐藏V2V
document.getElementById("hideV2X").onclick = hideV2X;
function hideV2X() {
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").hideV2x()
}
// document.getElementById("hideV2X").onclick = hideV2X;
// function hideV2X() {
// let options = {
// color: [255, 255, 0, 1],
// vehicleId: "仿AYZQS001", //鄂A17U5N
// };
// map.getVehicle("21e7a9e6d2884122804788dac1e002cc").hideV2x(options);
// }
// 清除V2V
document.getElementById("removeV2X").onclick = removeV2X;
function removeV2X() {
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").stopV2x()
let vehicleId = "仿AYZQS001";
map.getVehicle("21e7a9e6d2884122804788dac1e002cc").stopV2x(vehicleId);
}
// 绘制感知区域
......@@ -1057,6 +1114,43 @@
map.removeOverlay(polygon);
}
// 注册模型点击高亮 modelClickHighLight
document.getElementById("modelClickHighLight").onclick = modelClickHighLight;
async function modelClickHighLight() {
map.on(map.EventType.ON_EQUIPMENT_CLICKED, pick_model_hightlight);
}
function pick_model_hightlight(e) {
// 取出id
const modelId = e?.result?.Id || "";
console.log("模型点击高亮", e);
if (modelId) {
highlightModelId = modelId;
map.setModelHighlight(modelId);
map.addPopWindow({
id: modelId,
info: '普通信号灯'
})
return;
}
console.warn("没有模型Id", e);
}
// 清除模型高亮
document.getElementById("cancelModelHighlight").onclick =
cancelModelHighlight;
function cancelModelHighlight() {
console.log("清除模型高亮", highlightModelId);
if (highlightModelId) {
map.cancelModelHighlight(highlightModelId);
map.removePopWindow(highlightModelId);
// highlightModelId = null;
}
}
// 注销模型点击事件
document.getElementById("modelClickRemove").onclick = modelClickRemove;
function modelClickRemove() {
map.off(map.EventType.ON_EQUIPMENT_CLICKED, pick_model_hightlight);
}
</script>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment