Commit e5ad9395 authored by 纪泽龙's avatar 纪泽龙

优化地图模式,优化gis地图

parent 04f12e90
...@@ -88,7 +88,7 @@ class gaodeMap { ...@@ -88,7 +88,7 @@ class gaodeMap {
// 抽屉点击的时候让infowindow隐藏 // 抽屉点击的时候让infowindow隐藏
if (this.leftListClick) { if (this.leftListClick) {
console.log("moveStart") console.log("moveStart");
this.closeInfoWindow(); this.closeInfoWindow();
} }
}); });
...@@ -330,7 +330,7 @@ class gaodeMap { ...@@ -330,7 +330,7 @@ class gaodeMap {
} }
// 如果是新建状态 不出弹框 // 如果是新建状态 不出弹框
if (this.view.targetNum == 1) return; if (this.view.targetNum == 1) return;
console.log(e.target) console.log(e.target);
let options = map.getStatus(); let options = map.getStatus();
options.scrollWheel = false; options.scrollWheel = false;
map.setStatus(options); map.setStatus(options);
...@@ -558,6 +558,9 @@ class gaodeMap { ...@@ -558,6 +558,9 @@ class gaodeMap {
//添加事件 //添加事件
polyline.on("mouseover", this.polylineMouseOver); polyline.on("mouseover", this.polylineMouseOver);
polyline.on("click", this.polylineMouseOver); polyline.on("click", this.polylineMouseOver);
polyline.on("mousedown", e => {
this.polyLinesColorClear(polyline);
});
polyline.on("mouseout", e => { polyline.on("mouseout", e => {
polyline.setOptions({ strokeColor: "#2EE7E7" }); polyline.setOptions({ strokeColor: "#2EE7E7" });
// infoWindow.close(); // infoWindow.close();
...@@ -576,14 +579,17 @@ class gaodeMap { ...@@ -576,14 +579,17 @@ class gaodeMap {
polylineMouseOver = e => { polylineMouseOver = e => {
console.log(e.type); console.log(e.type);
let polyline = e.target; let polyline = e.target;
// 如果是无状态或者是新建并且是鼠标移入 // 如果是无状态或者是新建并且是鼠标移入
if (this.view.targetNum == 0 && e.type == "mouseover") { if (this.view.targetNum == 0 && e.type == "mouseover") {
polyline.setOptions({ strokeColor: "#F7FE38" }); polyline.setOptions({ strokeColor: "#F7FE38" });
return; return;
} }
// 当选择的是新建的时候,线是点不了的 // 当选择的是新建的时候,线是点不了的
if (this.lineType == 1 || this.view.targetNum == 1) return; if (this.lineType == 1 || this.view.targetNum == 1) return;
if((this.view.targetNum==2||this.view.targetNum==3)&&e.type=="mouseover"){
this.polyLinesColorClear(polyline);
}
// 上方导航的高 // 上方导航的高
let X = 20, let X = 20,
Y = -20; Y = -20;
...@@ -640,9 +646,9 @@ class gaodeMap { ...@@ -640,9 +646,9 @@ class gaodeMap {
// 如果是戍边浮动出现infowindow 就让窗口在固定的位置出现,这样就不显得乱了 // 如果是戍边浮动出现infowindow 就让窗口在固定的位置出现,这样就不显得乱了
if (e.type == "mouseover") { if (e.type == "mouseover") {
const coordinates=polyline.getPath().map(item=>{ const coordinates = polyline.getPath().map(item => {
return [item.lng,item.lat ] return [item.lng, item.lat];
}) });
// const { coordinates } = polyline.getExtData().lineData; // const { coordinates } = polyline.getExtData().lineData;
// 计算出前两个点的中点 // 计算出前两个点的中点
const arr1 = coordinates[0]; const arr1 = coordinates[0];
...@@ -669,9 +675,11 @@ class gaodeMap { ...@@ -669,9 +675,11 @@ class gaodeMap {
// const // const
}; };
polyLinesColorClear() { polyLinesColorClear(polylines) {
this.polyLines.forEach(item => { this.polyLines.forEach(item => {
item.setOptions({ strokeColor: "#2EE7E7" }); if (item != polylines) {
item.setOptions({ strokeColor: "#2EE7E7" });
}
}); });
} }
centerNum(num1, num2) { centerNum(num1, num2) {
...@@ -709,7 +717,6 @@ class gaodeMap { ...@@ -709,7 +717,6 @@ class gaodeMap {
} }
// 新建line增加编辑以及右键菜单 // 新建line增加编辑以及右键菜单
closeInfoWindow() { closeInfoWindow() {
this.showInfoWindow && this.showInfoWindow.close(); this.showInfoWindow && this.showInfoWindow.close();
this.markerInfoWindow && this.markerInfoWindow.close(); this.markerInfoWindow && this.markerInfoWindow.close();
} }
......
...@@ -54,8 +54,8 @@ class gaodeMap { ...@@ -54,8 +54,8 @@ class gaodeMap {
view = null; view = null;
handleInfoWindowOpenFunc = null; handleInfoWindowOpenFunc = null;
onceFlag = false; onceFlag = false;
用来判断点击左边抽屉列表的时候移动才消失 // 用来判断点击左边抽屉列表的时候移动才消失
leftListClick=false; leftListClick = false;
//构造函数中设置中央点默认值 //构造函数中设置中央点默认值
constructor(center) { constructor(center) {
this.markers = []; this.markers = [];
...@@ -902,18 +902,23 @@ class gaodeMap { ...@@ -902,18 +902,23 @@ class gaodeMap {
infoWindow.setOffset(new AMap.Pixel(X, Y)); infoWindow.setOffset(new AMap.Pixel(X, Y));
} else { } else {
infoWindow.setOffset(new AMap.Pixel(20, -20)); infoWindow.setOffset(new AMap.Pixel(20, -20));
this.polyLinesColorClear(polyline);
// polyline.setOptions({ strokeColor: "#F7FE38" });
} }
this.boxCollision(infoWindow.dom); this.boxCollision(infoWindow.dom);
this.showInfoWindow = infoWindow; this.showInfoWindow = infoWindow;
// const // const
}; };
// 所有的线的颜色归位,如果是报警的,就红色,不是就蓝色 // 所有的线的颜色归位,如果是报警的,就红色,不是就蓝色
polyLinesColorClear() { polyLinesColorClear(polyline) {
this.polyLines.forEach(item => { this.polyLines.forEach(item => {
if (item.getExtData().lineData.alarmState == 1) { if (item != polyline) {
item.setOptions({ strokeColor: "#ff0000" }); if (item.getExtData().lineData.alarmState == 1) {
} else { item.setOptions({ strokeColor: "#ff0000" });
item.setOptions({ strokeColor: "#2EE7E7" }); } else {
item.setOptions({ strokeColor: "#2EE7E7" });
}
} }
}); });
} }
......
...@@ -389,6 +389,8 @@ export default { ...@@ -389,6 +389,8 @@ export default {
} }
// 关闭当前的infowindow // 关闭当前的infowindow
this.gaoMap.closeInfoWindow(); this.gaoMap.closeInfoWindow();
// 清除所有线的颜色
this.gaoMap.polyLinesColorClear();
this.deviceType = !this.deviceType; this.deviceType = !this.deviceType;
this.gaoMap.mapOperateType = "add"; this.gaoMap.mapOperateType = "add";
...@@ -448,6 +450,8 @@ export default { ...@@ -448,6 +450,8 @@ export default {
} }
// 关闭当前的infowindow // 关闭当前的infowindow
this.gaoMap.closeInfoWindow(); this.gaoMap.closeInfoWindow();
// 清空管道颜色
this.gaoMap.polyLinesColorClear();
this.createReset(); this.createReset();
}, },
deleteDevice() { deleteDevice() {
...@@ -469,6 +473,8 @@ export default { ...@@ -469,6 +473,8 @@ export default {
} }
// 关闭当前的infowindow // 关闭当前的infowindow
this.gaoMap.closeInfoWindow(); this.gaoMap.closeInfoWindow();
// 清空管道颜色
this.gaoMap.polyLinesColorClear();
this.createReset(); this.createReset();
}, },
selectDeviceType(val) { selectDeviceType(val) {
......
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