代码优化
This commit is contained in:
parent
4457e9a2b6
commit
f168f2a3e6
|
|
@ -460,7 +460,9 @@ function saveData(data) {
|
||||||
tbSpanTowerList = JSON.parse(pointsStr).map((item) => {
|
tbSpanTowerList = JSON.parse(pointsStr).map((item) => {
|
||||||
return {
|
return {
|
||||||
id: item.id || null,
|
id: item.id || null,
|
||||||
lon: item.lng.toString().slice(0, 10),
|
lon: item.lon
|
||||||
|
? item.lon.toString().slice(0, 10)
|
||||||
|
: item.lng.toString().slice(0, 10),
|
||||||
lat: item.lat.toString().slice(0, 10),
|
lat: item.lat.toString().slice(0, 10),
|
||||||
sort: item.sort,
|
sort: item.sort,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ let cablewayList = []; // 索道列表
|
||||||
let towerList = []; // 塔列表
|
let towerList = []; // 塔列表
|
||||||
let crossingList = []; // 跨越列表
|
let crossingList = []; // 跨越列表
|
||||||
let crossingListNew = []; // 跨越列表
|
let crossingListNew = []; // 跨越列表
|
||||||
|
let crossingLineListNew = []; // 跨越线列表
|
||||||
let highwayList = []; // 公路列表
|
let highwayList = []; // 公路列表
|
||||||
let aThousandFieldsList = []; // 牵张场地
|
let aThousandFieldsList = []; // 牵张场地
|
||||||
let intLng = 116.254; // 初始经度
|
let intLng = 116.254; // 初始经度
|
||||||
|
|
@ -306,6 +307,7 @@ function getLocationInfo(id) {
|
||||||
|
|
||||||
crossingList = [];
|
crossingList = [];
|
||||||
crossingListNew = [];
|
crossingListNew = [];
|
||||||
|
crossingLineListNew = [];
|
||||||
cablewayList = [];
|
cablewayList = [];
|
||||||
towerList = [];
|
towerList = [];
|
||||||
|
|
||||||
|
|
@ -324,6 +326,7 @@ function getLocationInfo(id) {
|
||||||
} else {
|
} else {
|
||||||
crossingList = [];
|
crossingList = [];
|
||||||
crossingListNew = [];
|
crossingListNew = [];
|
||||||
|
crossingLineListNew = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.highwayList.length > 0) {
|
if (data.highwayList.length > 0) {
|
||||||
|
|
@ -341,8 +344,10 @@ function getLocationInfo(id) {
|
||||||
// 处理一下交叉信息
|
// 处理一下交叉信息
|
||||||
if (crossingList && crossingList.length > 0) {
|
if (crossingList && crossingList.length > 0) {
|
||||||
crossingList.forEach((item) => {
|
crossingList.forEach((item) => {
|
||||||
|
let lineList = [];
|
||||||
if (item.lonAndLat && item.lonAndLat.indexOf(",") > -1) {
|
if (item.lonAndLat && item.lonAndLat.indexOf(",") > -1) {
|
||||||
const lonAndLatList = item.lonAndLat.split(",");
|
const lonAndLatList = item.lonAndLat.split(",");
|
||||||
|
|
||||||
lonAndLatList.forEach((lonAndLat, index) => {
|
lonAndLatList.forEach((lonAndLat, index) => {
|
||||||
const lonAndLatItem = lonAndLat.split("@");
|
const lonAndLatItem = lonAndLat.split("@");
|
||||||
crossingListNew.push({
|
crossingListNew.push({
|
||||||
|
|
@ -350,8 +355,16 @@ function getLocationInfo(id) {
|
||||||
baiduLat: lonAndLatItem[1],
|
baiduLat: lonAndLatItem[1],
|
||||||
...item,
|
...item,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
lineList.push({
|
||||||
|
baiduLon: lonAndLatItem[0],
|
||||||
|
baiduLat: lonAndLatItem[1],
|
||||||
|
...item,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
crossingLineListNew.push({ lineList });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
initMap();
|
initMap();
|
||||||
|
|
@ -717,7 +730,7 @@ async function addAllMapPoints() {
|
||||||
});
|
});
|
||||||
|
|
||||||
graphicLayerList.push(billboard);
|
graphicLayerList.push(billboard);
|
||||||
// graphicLayerList.push(graphic);
|
graphicLayerList.push(label2);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -931,14 +944,20 @@ async function addMapLine() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
graphicLayer.addGraphic(polyline);
|
graphicLayer.addGraphic(polyline);
|
||||||
|
graphicLayerList.push(polyline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绘制交叉线路
|
// 绘制交叉线路
|
||||||
if (crossingListNew.length > 0) {
|
if (crossingLineListNew.length > 0) {
|
||||||
for (let i = 0; i < crossingListNew.length - 1; i++) {
|
for (let i = 0; i < crossingLineListNew.length; i++) {
|
||||||
const startPoint = crossingListNew[i];
|
for (
|
||||||
const endPoint = crossingListNew[i + 1];
|
let j = 0;
|
||||||
|
j < crossingLineListNew[i].lineList.length - 1;
|
||||||
|
j++
|
||||||
|
) {
|
||||||
|
const startPoint = crossingLineListNew[i].lineList[j];
|
||||||
|
const endPoint = crossingLineListNew[i].lineList[j + 1];
|
||||||
|
|
||||||
// 创建线段点数组
|
// 创建线段点数组
|
||||||
const positions = [
|
const positions = [
|
||||||
|
|
@ -960,6 +979,8 @@ async function addMapLine() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
graphicLayer.addGraphic(polyline);
|
graphicLayer.addGraphic(polyline);
|
||||||
|
graphicLayerList.push(polyline);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -998,6 +1019,7 @@ async function addMapLine() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
graphicLayer.addGraphic(polyline);
|
graphicLayer.addGraphic(polyline);
|
||||||
|
graphicLayerList.push(polyline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -1037,6 +1059,7 @@ async function addMapLine() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
graphicLayer.addGraphic(polyline);
|
graphicLayer.addGraphic(polyline);
|
||||||
|
graphicLayerList.push(polyline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue