Commit 830e60d6 authored by chengdong.lv@inzymeits.com's avatar chengdong.lv@inzymeits.com
Browse files

交通事件

parent 1177792a
const arr = [ const sjarr = [
{ {
id: "14578", id: "14578",
type: "ROAD_SPILL", type: "ROAD_SPILL",
......
...@@ -275,6 +275,7 @@ ...@@ -275,6 +275,7 @@
<script src="http://localhost:3000/gis_sdk/js/CMapLoader.map.js"></script> <script src="http://localhost:3000/gis_sdk/js/CMapLoader.map.js"></script>
<!-- <script src="http://localhost:3000/gis_sdk/js/CMapLoader.map.js"></script> --> <!-- <script src="http://localhost:3000/gis_sdk/js/CMapLoader.map.js"></script> -->
<script src="./SignalLines.js"></script> <script src="./SignalLines.js"></script>
<!-- <script src="./data.js"></script> -->
</head> </head>
<script> <script>
...@@ -391,7 +392,7 @@ ...@@ -391,7 +392,7 @@
function flyTo() { function flyTo() {
var options = { var options = {
position: [117.34584096, 38.99557144, 276.84], position: [117.34584096, 38.99557144, 276.84],
orientation: [0, -90], orientation: [-34.930073, -44.426579], //[0, -90], //设置俯视
}; };
camera.flyTo(options); camera.flyTo(options);
} }
...@@ -1013,9 +1014,10 @@ ...@@ -1013,9 +1014,10 @@
road.removeSignalStopLine(); road.removeSignalStopLine();
} }
var arr = [] var arr = [];
//开始交通事件 //开始交通事件
document.getElementById("addTrafficIncident").onclick = addTrafficIncident; document.getElementById("addTrafficIncident").onclick = addTrafficIncident;
async function addTrafficIncident() { async function addTrafficIncident() {
// 订阅事件 websocket事件 // 订阅事件 websocket事件
const url = const url =
...@@ -1024,69 +1026,29 @@ ...@@ -1024,69 +1026,29 @@
socket.onopen = function (event) { socket.onopen = function (event) {
console.log("socket连接成功!"); console.log("socket连接成功!");
}; };
const fun = async (json) => {
const { id, name, type, location } = json;
window.trafficIncidentArr = trafficIncidentArr; const find = trafficIncidentArr.find((item) => item.id == id);
let index = 0;
let show = false;
const fun1 = async (json) => {
const { endTime, id, name, location } = json;
console.log("idididididid", index, id, name);
if (name == "违规停车/停车占道" && !show) {
show = true;
console.log("违规停车/停车占道违规停车/停车占道", json, id);
let optionsTest = {
position: [location[0].longitude, location[0].latitude, 28.12],
orientation: [-34.930073, -44.426579],
};
camera.flyTo(optionsTest);
}
// 从 trafficIncidentArr 中的每一项中找出 trafficIncidentId== id 的数据 if (json.endTime) {
const find = trafficIncidentArr.find( if (find) {
(item) => item.trafficIncidentId == id
);
if (find ) {
if(index > 50 && name == "违规停车/停车占道") {
map.stopTrafficIncident(id, json); map.stopTrafficIncident(id, json);
return;
} }
return; return;
} }
index++; if (find) {
return;
// if (index > 50) {
// if (name == "违规停车/停车占道") {
// if (find) {
// debugger;
// map.stopTrafficIncident(id, json);
// }
// }
// return;
// } else {
// }
console.log("index", index, name);
if (endTime) {
// trafficIncidentArr = map.stopTrafficIncident(id, json);
// debugger
// return;
} }
trafficIncidentArr = await map.renderTrafficIncident(json); trafficIncidentArr.push(json);
await map.renderTrafficIncident(json);
}; };
socket.onmessage = async function (event) { socket.onmessage = async function (event) {
const json = JSON.parse(event.data); const json = JSON.parse(event.data);
fun1(json); await fun(json);
if(arr.length<100) {
arr.push(json)
}
}; };
} }
......
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