Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gassafety
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
耿迪迪
gassafety
Commits
e2b35608
Commit
e2b35608
authored
Aug 30, 2021
by
纪泽龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
地图模式infowindow显示逻辑优化
parent
bd863e8e
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
242 additions
and
93 deletions
+242
-93
lineInfoWindow.vue
gassafety-web/src/components/PopWindow/lineInfoWindow.vue
+15
-6
markerInfoWindow.vue
gassafety-web/src/components/PopWindow/markerInfoWindow.vue
+41
-21
markerInfoWindow.vue
...fety-web/src/components/PopWindowGis/markerInfoWindow.vue
+3
-7
index.vue
gassafety-web/src/components/TopNav/index.vue
+1
-0
index.js
gassafety-web/src/directive/permission/index.js
+2
-0
unContent.js
gassafety-web/src/directive/permission/unContent.js
+10
-0
gaodeMap.js
gassafety-web/src/utils/gaodeMap.js
+106
-44
gaodeMapView.js
gassafety-web/src/utils/gaodeMapView.js
+0
-3
index.vue
gassafety-web/src/views/device/map/index.vue
+47
-8
index.vue
gassafety-web/src/views/enterprise/mapView/index.vue
+17
-4
No files found.
gassafety-web/src/components/PopWindow/lineInfoWindow.vue
View file @
e2b35608
...
@@ -59,11 +59,7 @@
...
@@ -59,11 +59,7 @@
<
el
-
col
:
span
=
"13"
>
<
el
-
col
:
span
=
"13"
>
<
div
>
<
div
>
<
span
>
最后巡检日期:
<
/span
>
<
span
>
最后巡检日期:
<
/span
>
<
span
>
{{
<
span
>
{{
obj
.
inspectionTime
?
obj
.
inspectionTime
:
"-"
}}
<
/span
>
obj
.
inspectionTime
?
obj
.
inspectionTime
:
"-"
}}
<
/span
>
<
/div
>
<
/div
>
<
/el-col
>
<
/el-col
>
...
@@ -73,7 +69,7 @@
...
@@ -73,7 +69,7 @@
<
/div
>
<
/div
>
<
div
>
<
div
>
<
span
>
备注信息:
<
/span
>
<
span
>
备注信息:
<
/span
>
<
span
>
{{
obj
.
remarks
}}
<
/span
>
<
span
v
-
un
-
content
>
{{
obj
.
remarks
}}
<
/span
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
template
v
-
if
=
"!obj.editorPage"
>
<
template
v
-
if
=
"!obj.editorPage"
>
...
@@ -140,6 +136,19 @@ export default {
...
@@ -140,6 +136,19 @@ export default {
border
-
radius
:
4
px
;
border
-
radius
:
4
px
;
box
-
shadow
:
0
px
3
px
6
px
rgba
(
0
,
0
,
0
,
0.16
);
box
-
shadow
:
0
px
3
px
6
px
rgba
(
0
,
0
,
0
,
0.16
);
// overflow: hidden;
// overflow: hidden;
&
:
before
{
content
:
""
;
position
:
absolute
;
left
:
-
20
px
;
top
:
5
px
;
width
:
0
px
;
height
:
0
px
;
/* border: 20px solid red; */
border
-
top
:
15
px
solid
transparent
;
border
-
bottom
:
15
px
solid
transparent
;
/* border-left: 50px solid greenyellow; */
border
-
right
:
30
px
solid
#
053
b6a
;
}
.
top
{
.
top
{
width
:
100
%
;
width
:
100
%
;
height
:
51
px
;
height
:
51
px
;
...
...
gassafety-web/src/components/PopWindow/markerInfoWindow.vue
View file @
e2b35608
...
@@ -2,41 +2,51 @@
...
@@ -2,41 +2,51 @@
<div
class=
"wrapper"
>
<div
class=
"wrapper"
>
<span
class=
"dot-left"
></span>
<span
class=
"dot-left"
></span>
<div
class=
"top display-default"
>
<div
class=
"top display-default"
>
<div
class=
"left text"
>
{{
data
.
deviceName
}}
</div>
<div
class=
"left text"
>
{{
data
.
deviceName
}}
</div>
<div
class=
"right text"
>
<div
class=
"right text"
>
<img
src=
"../../assets/images/closeBtn.png"
alt=
""
@
click=
"map.clearInfoWindow()"
/>
<img
src=
"../../assets/images/closeBtn.png"
alt=
""
@
click=
"map.clearInfoWindow()"
/>
</div>
</div>
</div>
</div>
<!-- 设备信息 -->
<!-- 设备信息 -->
<div
class=
"content"
>
<div
class=
"content"
>
<div
class=
"eq-content display-default"
>
<div
class=
"eq-content display-default"
>
<div
class=
"text-wrapper"
>
<div
class=
"text-wrapper"
>
<div
class=
"eq-text"
>
设备类型:
<span>
{{
title
}}
</span></div>
<div
class=
"eq-text"
>
<div
class=
"eq-text"
>
设备型号:
<span>
{{
data
.
deviceModel
}}
</span></div>
设备类型:
<span>
{{
title
}}
</span>
<div
class=
"eq-text"
>
所属管道:
<span>
{{
data
.
pipeName
}}
</span></div>
</div>
<div
class=
"eq-text"
>
物联网编号:
<span>
{{
data
.
iotNo
}}
</span></div>
<div
class=
"eq-text"
>
设备型号:
<span>
{{
data
.
deviceModel
}}
</span>
</div>
<div
class=
"eq-text"
>
所属管道:
<span>
{{
data
.
pipeName
}}
</span>
</div>
<div
class=
"eq-text"
>
物联网编号:
<span>
{{
data
.
iotNo
}}
</span>
</div>
</div>
</div>
<div
class=
"pic"
>
<div
class=
"pic"
>
<img
v-bind:src=
"data.iconUrl"
alt=
""
/>
<img
v-bind:src=
"data.iconUrl"
alt=
""
/>
</div>
</div>
</div>
</div>
<!-- 维修人员 -->
<!-- 维修人员 -->
<div
class=
"maintain-content"
>
<div
class=
"maintain-content"
>
<el-col
:span=
"11"
>
<el-col
:span=
"11"
>
<div>
<div>
<span>
安装日期:
</span>
<span>
安装日期:
</span>
<span>
{{
moment
(
data
.
installationTime
).
format
(
"YYYY-MM-DD"
)
}}
</span>
<span>
{{
moment
(
data
.
installationTime
).
format
(
"YYYY-MM-DD"
)
}}
</span>
</div>
</div>
</el-col>
</el-col>
<el-col
:span=
"13"
>
<el-col
:span=
"13"
>
<div>
<div>
<span>
最后巡检日期:
</span>
<span>
最后巡检日期:
</span>
<span>
{{
<span>
{{
data
.
inspectionTime
?
data
.
inspectionTime
:
"-"
}}
</span>
data
.
inspectionTime
?
data
.
inspectionTime
:
"-"
}}
</span>
</div>
</div>
</el-col>
</el-col>
...
@@ -46,7 +56,7 @@
...
@@ -46,7 +56,7 @@
</div>
</div>
<div>
<div>
<span>
备注信息:
</span>
<span>
备注信息:
</span>
<span
>
{{
data
.
remarks
}}
</span>
<span
v-un-content
>
{{
data
.
remarks
}}
</span>
</div>
</div>
</div>
</div>
<!-- 报警状态 -->
<!-- 报警状态 -->
...
@@ -55,24 +65,22 @@
...
@@ -55,24 +65,22 @@
<div>
详细信息:
<span>
管线两端设备压差较大,管线可能泄漏
</span></div>
<div>
详细信息:
<span>
管线两端设备压差较大,管线可能泄漏
</span></div>
</div>
-->
</div>
-->
</div>
</div>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
moment
from
"moment"
import
moment
from
"moment"
;
//line移入时的的infowindow
//line移入时的的infowindow
export
default
{
export
default
{
props
:
{
props
:
{
obj
:
{
typs
:
Object
},
obj
:
{
typs
:
Object
},
title
:
""
,
title
:
""
,
data
:
{},
data
:
{},
map
:
null
map
:
null
,
},
},
methods
:{
methods
:
{
moment
,
moment
,
}
},
};
};
</
script
>
</
script
>
...
@@ -88,6 +96,19 @@ export default {
...
@@ -88,6 +96,19 @@ export default {
width
:
100%
;
width
:
100%
;
height
:
51px
;
height
:
51px
;
background-color
:
#053b6a
;
background-color
:
#053b6a
;
&
:before
{
content
:
""
;
position
:
absolute
;
left
:
-20px
;
top
:
5px
;
width
:
0px
;
height
:
0px
;
/* border: 20px solid red; */
border-top
:
15px
solid
transparent
;
border-bottom
:
15px
solid
transparent
;
/* border-left: 50px solid greenyellow; */
border-right
:
30px
solid
#053b6a
;
}
.text
{
.text
{
font-weight
:
600
;
font-weight
:
600
;
font-size
:
16px
;
font-size
:
16px
;
...
@@ -199,5 +220,4 @@ export default {
...
@@ -199,5 +220,4 @@ export default {
display
:
flex
;
display
:
flex
;
justify-content
:
space-between
;
justify-content
:
space-between
;
}
}
</
style
>
</
style
>
gassafety-web/src/components/PopWindowGis/markerInfoWindow.vue
View file @
e2b35608
...
@@ -4,11 +4,7 @@
...
@@ -4,11 +4,7 @@
<div
class=
"top display-default"
>
<div
class=
"top display-default"
>
<div
class=
"left text"
>
{{
data
.
deviceName
}}
</div>
<div
class=
"left text"
>
{{
data
.
deviceName
}}
</div>
<div
class=
"right text"
>
<div
class=
"right text"
>
<img
<img
src=
"../../assets/images/closeBtn.png"
alt=
""
@
click=
"close"
/>
src=
"../../assets/images/closeBtn.png"
alt=
""
@
click=
"close"
/>
</div>
</div>
</div>
</div>
<!-- 设备信息 -->
<!-- 设备信息 -->
...
@@ -98,10 +94,10 @@ export default {
...
@@ -98,10 +94,10 @@ export default {
},
},
});
});
},
},
close
(){
close
()
{
this
.
map
.
clearInfoWindow
();
this
.
map
.
clearInfoWindow
();
this
.
data
.
class
.
view
.
bottomDataShow
=
true
;
this
.
data
.
class
.
view
.
bottomDataShow
=
true
;
}
}
,
},
},
};
};
</
script
>
</
script
>
...
...
gassafety-web/src/components/TopNav/index.vue
View file @
e2b35608
...
@@ -235,6 +235,7 @@ export default {
...
@@ -235,6 +235,7 @@ export default {
.el-menu--horizontal
>
.el-submenu
.el-submenu__title
{
.el-menu--horizontal
>
.el-submenu
.el-submenu__title
{
height
:
50px
!
important
;
height
:
50px
!
important
;
line-height
:
50px
!
important
;
line-height
:
50px
!
important
;
border
:none
!
important
;
margin-left
:
15px
;
margin-left
:
15px
;
}
}
.el-menu--horizontal
>
.el-menu-item
:not
(
.is-disabled
)
:hover
,
.el-menu--horizontal
>
.el-menu-item
:not
(
.is-disabled
)
:hover
,
...
...
gassafety-web/src/directive/permission/index.js
View file @
e2b35608
import
hasRole
from
'./hasRole'
import
hasRole
from
'./hasRole'
import
hasPermi
from
'./hasPermi'
import
hasPermi
from
'./hasPermi'
import
unContent
from
'./unContent'
const
install
=
function
(
Vue
)
{
const
install
=
function
(
Vue
)
{
Vue
.
directive
(
'hasRole'
,
hasRole
)
Vue
.
directive
(
'hasRole'
,
hasRole
)
Vue
.
directive
(
'hasPermi'
,
hasPermi
)
Vue
.
directive
(
'hasPermi'
,
hasPermi
)
Vue
.
directive
(
'un-content'
,
unContent
)
}
}
if
(
window
.
Vue
)
{
if
(
window
.
Vue
)
{
...
...
gassafety-web/src/directive/permission/unContent.js
0 → 100644
View file @
e2b35608
/**
* 无内容显示-
* Copyright (c) 2021 gassafety
*/
export
default
{
inserted
(
el
,
binding
,
vnode
)
{
el
.
innerHTML
=
el
.
innerHTML
.
replace
(
/
\s
+/g
,
""
)
?
el
.
innerHTML
:
"-"
;
}
};
gassafety-web/src/utils/gaodeMap.js
View file @
e2b35608
...
@@ -37,6 +37,8 @@ class gaodeMap {
...
@@ -37,6 +37,8 @@ class gaodeMap {
view
=
null
;
view
=
null
;
// 地图移动结束后出现infowindow用的函数
// 地图移动结束后出现infowindow用的函数
handleInfoWindowOpenFunc
=
null
;
handleInfoWindowOpenFunc
=
null
;
// 点击左侧抽屉的时候,改变的flag
leftListClick
=
false
;
//构造函数中设置中央点默认值
//构造函数中设置中央点默认值
constructor
(
center
)
{
constructor
(
center
)
{
...
@@ -59,6 +61,8 @@ class gaodeMap {
...
@@ -59,6 +61,8 @@ class gaodeMap {
this
.
myMap
.
on
(
"click"
,
e
=>
{
this
.
myMap
.
on
(
"click"
,
e
=>
{
// if (this.lineType !=1 || this.lineFlag) return;
// if (this.lineType !=1 || this.lineFlag) return;
this
.
closeInfoWindow
();
this
.
polyLinesColorClear
();
if
(
this
.
lineType
!=
1
||
this
.
lineFlag
)
return
;
if
(
this
.
lineType
!=
1
||
this
.
lineFlag
)
return
;
// 除了这里,还要利用vue页面的window事件辅助,当组件出来的时候,就得利用window事件
// 除了这里,还要利用vue页面的window事件辅助,当组件出来的时候,就得利用window事件
...
@@ -81,7 +85,10 @@ class gaodeMap {
...
@@ -81,7 +85,10 @@ class gaodeMap {
// 地图开始平移删除infowindow
// 地图开始平移删除infowindow
this
.
myMap
.
on
(
"movestart"
,
()
=>
{
this
.
myMap
.
on
(
"movestart"
,
()
=>
{
// console.log("地图平移");
// console.log("地图平移");
this
.
closeInfoWindow
();
// 抽屉点击的时候让infowindow隐藏
if
(
this
.
leftListClick
)
{
this
.
closeInfoWindow
();
}
});
});
// 地图开始缩放删除infowindow
// 地图开始缩放删除infowindow
this
.
myMap
.
on
(
"zoomstart"
,
()
=>
{
this
.
myMap
.
on
(
"zoomstart"
,
()
=>
{
...
@@ -92,6 +99,8 @@ class gaodeMap {
...
@@ -92,6 +99,8 @@ class gaodeMap {
if
(
this
.
handleInfoWindowOpenFunc
)
{
if
(
this
.
handleInfoWindowOpenFunc
)
{
this
.
handleInfoWindowOpenFunc
();
this
.
handleInfoWindowOpenFunc
();
this
.
handleInfoWindowOpenFunc
=
null
;
this
.
handleInfoWindowOpenFunc
=
null
;
// 移动结束之后,leftListClick变成false
this
.
leftListClick
=
false
;
}
}
// console.log("缩放开始")
// console.log("缩放开始")
if
(
!
this
.
onceFlag
)
{
if
(
!
this
.
onceFlag
)
{
...
@@ -198,6 +207,7 @@ class gaodeMap {
...
@@ -198,6 +207,7 @@ class gaodeMap {
)
{
)
{
marker
.
content
=
this
.
getMarketContent
(
data
);
marker
.
content
=
this
.
getMarketContent
(
data
);
marker
.
on
(
"mouseover"
,
this
.
infoOpen
);
marker
.
on
(
"mouseover"
,
this
.
infoOpen
);
marker
.
on
(
"click"
,
this
.
infoOpen
);
marker
.
on
(
"mouseout"
,
infoClose
);
marker
.
on
(
"mouseout"
,
infoClose
);
marker
.
infoWindow
=
infoWindow
;
marker
.
infoWindow
=
infoWindow
;
marker
.
setExtData
(
data
);
marker
.
setExtData
(
data
);
...
@@ -313,6 +323,13 @@ class gaodeMap {
...
@@ -313,6 +323,13 @@ class gaodeMap {
}
}
// 其他设备
// 其他设备
infoOpen
=
e
=>
{
infoOpen
=
e
=>
{
// 如果是无状态并且鼠标mouseover
if
(
this
.
view
.
targetNum
==
0
&&
e
.
type
==
"mouseover"
)
{
return
;
}
// 如果是新建状态 不出弹框
if
(
this
.
view
.
targetNum
==
1
)
return
;
let
options
=
map
.
getStatus
();
let
options
=
map
.
getStatus
();
options
.
scrollWheel
=
false
;
options
.
scrollWheel
=
false
;
map
.
setStatus
(
options
);
map
.
setStatus
(
options
);
...
@@ -489,11 +506,12 @@ class gaodeMap {
...
@@ -489,11 +506,12 @@ class gaodeMap {
let
path
=
coordinates
?
eval
(
coordinates
)
:
[];
let
path
=
coordinates
?
eval
(
coordinates
)
:
[];
let
polyline
=
new
AMap
.
Polyline
({
let
polyline
=
new
AMap
.
Polyline
({
path
,
path
,
strokeColor
:
"#
F7FE38
"
,
strokeColor
:
"#
2EE7E7
"
,
strokeWeight
:
4
,
strokeWeight
:
4
,
strokeOpacity
:
0.9
,
strokeOpacity
:
0.9
,
zIndex
:
50
,
zIndex
:
50
,
bubble
:
true
,
cursor
:
"pointer"
,
bubble
:
false
,
geodesic
:
true
,
geodesic
:
true
,
extData
:
{
extData
:
{
type
:
"line"
,
type
:
"line"
,
...
@@ -527,7 +545,7 @@ class gaodeMap {
...
@@ -527,7 +545,7 @@ class gaodeMap {
});
});
let
infoWindow
=
new
AMap
.
InfoWindow
({
let
infoWindow
=
new
AMap
.
InfoWindow
({
isCustom
:
true
,
isCustom
:
true
,
autoMove
:
fals
e
,
autoMove
:
tru
e
,
content
:
dom
.
$el
,
content
:
dom
.
$el
,
//信息船体偏移量
//信息船体偏移量
offset
:
new
AMap
.
Pixel
(
0
,
0
),
offset
:
new
AMap
.
Pixel
(
0
,
0
),
...
@@ -538,8 +556,9 @@ class gaodeMap {
...
@@ -538,8 +556,9 @@ class gaodeMap {
polyline
.
infoWindow
=
infoWindow
;
polyline
.
infoWindow
=
infoWindow
;
//添加事件
//添加事件
polyline
.
on
(
"mouseover"
,
this
.
polylineMouseOver
);
polyline
.
on
(
"mouseover"
,
this
.
polylineMouseOver
);
polyline
.
on
(
"click"
,
this
.
polylineMouseOver
);
polyline
.
on
(
"mouseout"
,
e
=>
{
polyline
.
on
(
"mouseout"
,
e
=>
{
polyline
.
setOptions
({
strokeColor
:
"#
F7FE38
"
});
polyline
.
setOptions
({
strokeColor
:
"#
2EE7E7
"
});
// infoWindow.close();
// infoWindow.close();
});
});
// 计算info的位置
// 计算info的位置
...
@@ -554,8 +573,16 @@ class gaodeMap {
...
@@ -554,8 +573,16 @@ class gaodeMap {
}
}
// 鼠标移入管道
// 鼠标移入管道
polylineMouseOver
=
e
=>
{
polylineMouseOver
=
e
=>
{
console
.
log
(
e
.
type
);
let
polyline
=
e
.
target
;
let
polyline
=
e
.
target
;
if
(
this
.
lineType
==
1
)
return
;
// 如果是无状态或者是新建并且是鼠标移入
if
(
this
.
view
.
targetNum
==
0
&&
e
.
type
==
"mouseover"
)
{
polyline
.
setOptions
({
strokeColor
:
"#F7FE38"
});
return
;
}
// 当选择的是新建的时候,线是点不了的
if
(
this
.
lineType
==
1
||
this
.
view
.
targetNum
==
1
)
return
;
// 上方导航的高
// 上方导航的高
let
X
=
20
,
let
X
=
20
,
Y
=
-
20
;
Y
=
-
20
;
...
@@ -599,20 +626,49 @@ class gaodeMap {
...
@@ -599,20 +626,49 @@ class gaodeMap {
console
.
log
(
"靠下了"
);
console
.
log
(
"靠下了"
);
Y
=
-
infoWindowHeight
-
20
;
Y
=
-
infoWindowHeight
-
20
;
}
}
polyline
.
setOptions
({
strokeColor
:
"#FF5A67"
});
X
=
23
;
Y
=
-
20
;
// polyline.setOptions({ strokeColor: "#FF5A67" });
// 浮动的时候为新建时,不变色
if
(
this
.
view
.
targetNum
!=
1
)
{
polyline
.
setOptions
({
strokeColor
:
"#F7FE38"
});
}
}
}
polyline
.
infoWindow
.
setOffset
(
new
AMap
.
Pixel
(
X
,
Y
));
polyline
.
infoWindow
.
setOffset
(
new
AMap
.
Pixel
(
X
,
Y
));
polyline
.
infoWindow
.
open
(
map
,
e
.
lnglat
);
// 如果是戍边浮动出现infowindow 就让窗口在固定的位置出现,这样就不显得乱了
if
(
e
.
type
==
"mouseover"
)
{
const
{
coordinates
}
=
polyline
.
getExtData
().
lineData
;
// 计算出前两个点的中点
const
arr1
=
eval
(
coordinates
)[
0
];
const
arr2
=
eval
(
coordinates
)[
1
];
const
a
=
this
.
centerNum
(
arr1
[
0
],
arr2
[
0
]);
const
b
=
this
.
centerNum
(
arr1
[
1
],
arr2
[
1
]);
const
a2
=
this
.
centerNum
(
a
,
arr1
[
0
])
const
b2
=
this
.
centerNum
(
b
,
arr1
[
1
])
polyline
.
infoWindow
.
open
(
map
,
[
a2
,
b2
]);
}
else
{
polyline
.
infoWindow
.
open
(
map
,
e
.
lnglat
);
}
// polyline.infoWindow=infoWindow;
// polyline.infoWindow=infoWindow;
this
.
showInfoWindow
=
polyline
.
infoWindow
;
this
.
showInfoWindow
=
polyline
.
infoWindow
;
// const
// const
};
};
polyLinesColorClear
()
{
this
.
polyLines
.
forEach
(
item
=>
{
item
.
setOptions
({
strokeColor
:
"#2EE7E7"
});
});
}
centerNum
(
num1
,
num2
){
return
(
Number
(
num1
)
+
Number
(
num2
)
)
/
2
}
// 创建一条新的线
// 创建一条新的线
createNewLine
()
{
createNewLine
()
{
map
.
remove
(
this
.
markerOverlays
);
map
.
remove
(
this
.
markerOverlays
);
console
.
log
(
"创造一条线了啊"
);
this
.
mouseTool
.
polyline
({
this
.
mouseTool
.
polyline
({
// bubbles:false,
// bubbles:false,
strokeWeight
:
4
,
strokeWeight
:
4
,
...
@@ -650,6 +706,7 @@ class gaodeMap {
...
@@ -650,6 +706,7 @@ class gaodeMap {
// obj.polyEditor.on('adjust',(e)=>{
// obj.polyEditor.on('adjust',(e)=>{
// console.log("addnode")
// console.log("addnode")
// })
// })
obj
.
on
(
"mousedown"
,
e
=>
{
obj
.
on
(
"mousedown"
,
e
=>
{
console
.
log
(
e
.
originEvent
);
console
.
log
(
e
.
originEvent
);
console
.
log
(
"lineType"
,
this
.
lineType
);
console
.
log
(
"lineType"
,
this
.
lineType
);
...
@@ -717,28 +774,24 @@ class gaodeMap {
...
@@ -717,28 +774,24 @@ class gaodeMap {
const
{
const
{
lineData
:
{
pipeName
,
deviceInfoList
}
lineData
:
{
pipeName
,
deviceInfoList
}
}
=
obj
.
getExtData
();
}
=
obj
.
getExtData
();
console
.
log
(
"deviceInfoList"
,
deviceInfoList
);
let
devices
=
" "
;
let
content
;
var
devices
=
" "
;
if
(
deviceInfoList
)
{
for
(
var
i
=
0
;
i
<
deviceInfoList
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
deviceInfoList
.
length
;
i
++
)
{
var
item
=
deviceInfoList
[
i
];
var
item
=
deviceInfoList
[
i
];
devices
=
devices
+
item
.
deviceName
+
" "
;
devices
=
devices
+
item
.
deviceName
+
" "
;
}
content
=
`请确认是否删除管道名称为 +
${
pipeName
}
+的数据项,该管道下包含的设备(
${
devices
}
)将一并删除`
;
}
else
{
content
=
`请确认是否删除管道名称为
${
pipeName
}
的数据项,该管道下不包含任何设备`
;
}
}
vue
vue
.
$confirm
(
.
$confirm
(
content
,
"提示"
,
{
'请确认是否删除管道名称为"'
+
// confirmButtonText: "确定",
pipeName
+
// cancelButtonText: "取消",
'"的数据项,该管道下包含的设备('
+
type
:
"warning"
devices
+
// center: true
")将一并删除"
,
})
"提示"
,
{
// confirmButtonText: "确定",
// cancelButtonText: "取消",
type
:
"warning"
// center: true
}
)
.
then
(()
=>
{
.
then
(()
=>
{
const
{
lineData
}
=
obj
.
getExtData
();
const
{
lineData
}
=
obj
.
getExtData
();
// updatePipe
// updatePipe
...
@@ -751,30 +804,33 @@ class gaodeMap {
...
@@ -751,30 +804,33 @@ class gaodeMap {
// 如果是老线,就要线删除原来的,然后重新包装一遍
// 如果是老线,就要线删除原来的,然后重新包装一遍
if
(
index
>=
0
)
{
if
(
index
>=
0
)
{
this
.
polyLines
.
splice
(
index
,
1
);
this
.
polyLines
.
splice
(
index
,
1
);
// 删除管道的时候,与管道管理额的设备也要删除
// 删除管道的时候,与管道管理额的设备也要删除,
for
(
var
i
=
0
;
i
<
deviceInfoList
.
length
;
i
++
)
{
// 如果管道存在下级设备,也一并删除
const
item
=
deviceInfoList
[
i
];
if
(
deviceInfoList
)
{
for
(
let
j
=
0
;
j
<
this
.
markers
.
length
;
j
++
)
{
for
(
var
i
=
0
;
i
<
deviceInfoList
.
length
;
i
++
)
{
const
item2
=
this
.
markers
[
j
];
const
item
=
deviceInfoList
[
i
];
if
(
item
.
deviceId
==
item2
.
getExtData
().
deviceId
)
{
for
(
let
j
=
0
;
j
<
this
.
markers
.
length
;
j
++
)
{
map
.
remove
(
item2
);
const
item2
=
this
.
markers
[
j
];
const
ind
=
this
.
markers
.
indexOf
(
item2
);
if
(
item
.
deviceId
==
item2
.
getExtData
().
deviceId
)
{
if
(
ind
>=
0
)
{
map
.
remove
(
item2
);
this
.
markers
.
splice
(
ind
,
1
);
const
ind
=
this
.
markers
.
indexOf
(
item2
);
if
(
ind
>=
0
)
{
this
.
markers
.
splice
(
ind
,
1
);
}
break
;
}
}
break
;
}
}
}
}
}
}
map
.
remove
(
obj
);
map
.
remove
(
obj
);
// 列表变化
// 列表变化
const
pipeArr
=
this
.
polyLines
.
map
(
item
=>
{
const
pipeArr
=
this
.
polyLines
.
map
(
item
=>
{
return
item
.
getExtData
().
lineData
;
return
item
.
getExtData
().
lineData
;
})
})
;
const
markerArr
=
this
.
markers
.
map
(
item
=>
{
const
markerArr
=
this
.
markers
.
map
(
item
=>
{
return
item
.
getExtData
();
return
item
.
getExtData
();
});
});
this
.
view
.
pipeClassify
(
pipeArr
)
this
.
view
.
pipeClassify
(
pipeArr
)
;
this
.
view
.
deviceClassify
(
markerArr
);
this
.
view
.
deviceClassify
(
markerArr
);
this
.
view
.
pipeList
();
this
.
view
.
pipeList
();
}
}
...
@@ -809,7 +865,8 @@ class gaodeMap {
...
@@ -809,7 +865,8 @@ class gaodeMap {
item
.
setExtData
(
opstions
);
item
.
setExtData
(
opstions
);
let
attr
=
item
.
getOptions
();
let
attr
=
item
.
getOptions
();
attr
.
strokeColor
=
"#F7FE38"
;
// attr.strokeColor = "#F7FE38";
attr
.
strokeColor
=
"#2EE7E7"
;
item
.
setOptions
(
attr
);
item
.
setOptions
(
attr
);
});
});
}
}
...
@@ -875,7 +932,6 @@ class gaodeMap {
...
@@ -875,7 +932,6 @@ class gaodeMap {
device
.
form
.
longitude
=
postion
.
lng
;
device
.
form
.
longitude
=
postion
.
lng
;
device
.
form
.
latitude
=
postion
.
lat
;
device
.
form
.
latitude
=
postion
.
lat
;
}
}
device
.
show
();
device
.
show
();
});
});
e
.
obj
.
on
(
"mouseover"
,
function
()
{
e
.
obj
.
on
(
"mouseover"
,
function
()
{
...
@@ -892,6 +948,12 @@ class gaodeMap {
...
@@ -892,6 +948,12 @@ class gaodeMap {
if
(
e
.
obj
&&
e
.
obj
.
getExtData
().
type
==
"newLine"
)
{
if
(
e
.
obj
&&
e
.
obj
.
getExtData
().
type
==
"newLine"
)
{
console
.
log
(
"挂上事件"
);
console
.
log
(
"挂上事件"
);
that
.
newLineAddEvent
(
e
.
obj
);
that
.
newLineAddEvent
(
e
.
obj
);
e
.
obj
.
on
(
"mouseover"
,
()
=>
{
e
.
obj
.
setOptions
({
strokeColor
:
"#F7FE38"
});
});
e
.
obj
.
on
(
"mouseout"
,
()
=>
{
e
.
obj
.
setOptions
({
strokeColor
:
"#80d8ff"
});
});
// 记录这条线
// 记录这条线
// console.log(e.obj.getPath().length)
// console.log(e.obj.getPath().length)
// 如果只有一个点,并没有连成线的时候就不close 大于一个点的时候才执行clse
// 如果只有一个点,并没有连成线的时候就不close 大于一个点的时候才执行clse
...
...
gassafety-web/src/utils/gaodeMapView.js
View file @
e2b35608
...
@@ -53,9 +53,7 @@ class gaodeMap {
...
@@ -53,9 +53,7 @@ class gaodeMap {
markerPassedPolylineInfoWindow
=
null
;
markerPassedPolylineInfoWindow
=
null
;
view
=
null
;
view
=
null
;
handleInfoWindowOpenFunc
=
null
;
handleInfoWindowOpenFunc
=
null
;
onceFlag
=
false
;
onceFlag
=
false
;
//构造函数中设置中央点默认值
//构造函数中设置中央点默认值
constructor
(
center
)
{
constructor
(
center
)
{
this
.
markers
=
[];
this
.
markers
=
[];
...
@@ -96,7 +94,6 @@ class gaodeMap {
...
@@ -96,7 +94,6 @@ class gaodeMap {
})
})
.
catch
(()
=>
{});
.
catch
(()
=>
{});
}
}
// //console.log("抬起来了");
// //console.log("抬起来了");
});
});
// 地图开始平移删除infowindow
// 地图开始平移删除infowindow
...
...
gassafety-web/src/views/device/map/index.vue
View file @
e2b35608
<
template
>
<
template
>
<div>
<div>
<div
style=
"width: 100vw;"
:style=
"
{height:`${boxHeight}px`}" id="container">
</div>
<div
:style=
"
{ height: `${boxHeight}px`, width: `${boxWidth}px` }"
id="container"
>
</div>
<div
class=
"btn-wrapper"
>
<div
class=
"btn-wrapper"
>
<div
class=
"myBtn"
>
<div
class=
"myBtn"
>
<div
<div
...
@@ -238,6 +241,7 @@ export default {
...
@@ -238,6 +241,7 @@ export default {
backFlag
:
true
,
backFlag
:
true
,
// 抽屉内的滚动条的高需要赋值赋值
// 抽屉内的滚动条的高需要赋值赋值
boxHeight
:
""
,
boxHeight
:
""
,
boxWidth
:
""
,
drawerOpacity
:
false
,
drawerOpacity
:
false
,
// 左边的bar的active判定
// 左边的bar的active判定
leftBarNum
:
[
1
,
2
,
3
,
4
,
7
],
leftBarNum
:
[
1
,
2
,
3
,
4
,
7
],
...
@@ -295,14 +299,21 @@ export default {
...
@@ -295,14 +299,21 @@ export default {
};
};
},
},
mounted
()
{
mounted
()
{
this
.
onResize
();
window
.
removeEventListener
(
"resize"
,
this
.
onResize
);
window
.
addEventListener
(
"resize"
,
this
.
onResize
);
this
.
initMap
();
this
.
initMap
();
this
.
boxHeight
=
document
.
body
.
clientHeight
-
81
;
},
},
methods
:
{
methods
:
{
onResize
()
{
this
.
boxHeight
=
document
.
body
.
clientHeight
-
81
;
this
.
boxWidth
=
document
.
body
.
clientWidth
-
100
;
},
async
initMap
()
{
async
initMap
()
{
let
gaoMap
=
new
gaodeMap
(
"石家庄"
);
let
gaoMap
=
new
gaodeMap
(
"石家庄"
);
this
.
gaoMap
=
gaoMap
;
this
.
gaoMap
=
gaoMap
;
this
.
gaoMap
.
view
=
this
;
this
.
gaoMap
.
view
=
this
;
window
.
removeEventListener
(
"click"
,
this
.
barClose
);
window
.
addEventListener
(
"click"
,
this
.
barClose
);
window
.
addEventListener
(
"click"
,
this
.
barClose
);
gaoMap
.
addMouseTool
();
gaoMap
.
addMouseTool
();
gaoMap
.
searchTips
(
"tipinput"
);
gaoMap
.
searchTips
(
"tipinput"
);
...
@@ -392,6 +403,7 @@ export default {
...
@@ -392,6 +403,7 @@ export default {
// 0是初始,1是新建 2是编辑 3删除
// 0是初始,1是新建 2是编辑 3删除
this
.
gaoMap
.
lineType
=
1
;
this
.
gaoMap
.
lineType
=
1
;
if
(
this
.
gaoMap
.
newLineObj
==
null
)
{
if
(
this
.
gaoMap
.
newLineObj
==
null
)
{
console
.
log
(
this
.
gaoMap
.
newLineObj
);
this
.
gaoMap
.
createNewLine
();
this
.
gaoMap
.
createNewLine
();
}
}
}
else
{
}
else
{
...
@@ -546,8 +558,12 @@ export default {
...
@@ -546,8 +558,12 @@ export default {
console
.
log
(
"window"
);
console
.
log
(
"window"
);
this
.
deviceType
=
false
;
this
.
deviceType
=
false
;
// 关闭当前线条的infowindow
// 关闭当前线条的infowindow
this
.
gaoMap
.
closeInfoWindow
();
// 如果当前状态只有是编辑跟删除状态才会关闭
if
(
this
.
targetNum
==
2
||
this
.
targetNum
==
3
)
{
this
.
gaoMap
.
closeInfoWindow
();
}
// 如果没有选择的时候点window 则高亮消失
// 如果没有选择的时候点window 则高亮消失
console
.
log
(
this
.
targetNum
)
if
(
this
.
targetNum
==
1
&&
this
.
iconClass
==
"icon-create"
)
{
if
(
this
.
targetNum
==
1
&&
this
.
iconClass
==
"icon-create"
)
{
this
.
targetNum
=
0
;
this
.
targetNum
=
0
;
}
}
...
@@ -711,18 +727,35 @@ export default {
...
@@ -711,18 +727,35 @@ export default {
panToo
(
iten
,
item
)
{
panToo
(
iten
,
item
)
{
// 如果没打对勾,就啥也不干
// 如果没打对勾,就啥也不干
if
(
!
this
.
leftBarNum
.
includes
(
item
.
value
))
return
;
if
(
!
this
.
leftBarNum
.
includes
(
item
.
value
))
return
;
// 如果地图太大了就吸纳是不出来infowindow了,所以要固定缩放比例
// 如果地图太大了就吸纳是不出来infowindow了,所以要固定缩放比例
// 所有线条颜色还原
this
.
gaoMap
.
leftListClick
=
true
;
this
.
gaoMap
.
polyLinesColorClear
();
this
.
gaoMap
.
myMap
.
setZoom
(
11
);
this
.
gaoMap
.
myMap
.
setZoom
(
11
);
if
(
item
.
list
.
length
>
0
)
{
if
(
item
.
list
.
length
>
0
)
{
if
(
this
.
leftBarNum
.
includes
(
item
.
value
))
{
if
(
this
.
leftBarNum
.
includes
(
item
.
value
))
{
this
.
gaoMap
.
panTo
(
iten
.
path
);
let
path
;
if
(
item
.
value
==
1
)
{
const
a
=
(
Number
(
iten
.
lnglat
[
0
])
+
Number
(
iten
.
path
[
0
]))
/
2
;
const
b
=
(
Number
(
iten
.
lnglat
[
1
])
+
Number
(
iten
.
path
[
1
]))
/
2
;
//屏幕移动的位置
path
=
[
a
,
b
-
0.1
];
// 线条infowindow显示中间,保留六位转换字符串,否则有时候会出现一些问题
iten
.
infoPath
=
[
a
.
toFixed
(
6
),
b
.
toFixed
(
6
)];
console
.
log
(
path
);
}
else
{
path
=
[
iten
.
path
[
0
],
iten
.
path
[
1
]
-
0.1
];
}
// const path =
// item.value == 1
// ? [iten.lnglat[0], iten.lnglat[1] - 0.1]
// : [iten.path[0], iten.path[1] - 0.1];
this
.
gaoMap
.
panTo
(
path
);
}
}
}
}
// 当前地图中心点
// 当前地图中心点
const
{
lat
,
lng
}
=
this
.
gaoMap
.
myMap
.
getCenter
();
const
{
lat
,
lng
}
=
this
.
gaoMap
.
myMap
.
getCenter
();
// 管道是这个方法,因为管道比较特殊
// 管道是这个方法,因为管道比较特殊
if
(
item
.
value
==
1
)
{
if
(
item
.
value
==
1
)
{
this
.
polylineInfoWindowShow
(
iten
,
lat
,
lng
);
this
.
polylineInfoWindowShow
(
iten
,
lat
,
lng
);
}
else
if
(
item
.
value
==
9
)
{
}
else
if
(
item
.
value
==
9
)
{
...
@@ -735,6 +768,7 @@ export default {
...
@@ -735,6 +768,7 @@ export default {
this
.
diveceInfoWindowShow
(
iten
,
lat
,
lng
);
this
.
diveceInfoWindowShow
(
iten
,
lat
,
lng
);
}
}
},
},
// 如果是线条飞过去出现infowindow
// 如果是线条飞过去出现infowindow
polylineInfoWindowShow
(
iten
,
lat
,
lng
)
{
polylineInfoWindowShow
(
iten
,
lat
,
lng
)
{
const
target
=
this
.
gaoMap
.
polyLines
.
filter
((
item
)
=>
{
const
target
=
this
.
gaoMap
.
polyLines
.
filter
((
item
)
=>
{
...
@@ -743,16 +777,20 @@ export default {
...
@@ -743,16 +777,20 @@ export default {
console
.
log
(
"target"
,
target
);
console
.
log
(
"target"
,
target
);
const
e
=
{
const
e
=
{
target
,
target
,
lnglat
:
iten
.
lnglat
,
lnglat
:
iten
.
infoPath
,
};
};
// console.log(target.getOptions());
// 如果是原地不动,就直接执行
// 如果是原地不动,就直接执行
if
(
iten
.
path
[
0
]
==
lng
&&
iten
.
path
[
1
]
==
lat
)
{
if
(
iten
.
infoPath
[
0
]
==
lng
&&
iten
.
infoPath
[
1
]
==
lat
+
0.1
)
{
this
.
gaoMap
.
polylineMouseOver
(
e
);
this
.
gaoMap
.
polylineMouseOver
(
e
);
target
.
setOptions
({
strokeColor
:
"#F7FE38"
});
return
;
return
;
}
}
// 因为地图移动的时候infowindow无法显示
// 因为地图移动的时候infowindow无法显示
this
.
gaoMap
.
handleInfoWindowOpenFunc
=
()
=>
{
this
.
gaoMap
.
handleInfoWindowOpenFunc
=
()
=>
{
this
.
gaoMap
.
polylineMouseOver
(
e
);
this
.
gaoMap
.
polylineMouseOver
(
e
);
target
.
setOptions
({
strokeColor
:
"#F7FE38"
});
};
};
},
},
// 这个是其他设备的infowindow
// 这个是其他设备的infowindow
...
@@ -780,6 +818,7 @@ export default {
...
@@ -780,6 +818,7 @@ export default {
beforeDestroy
()
{
beforeDestroy
()
{
console
.
log
(
"移除window事件"
);
console
.
log
(
"移除window事件"
);
window
.
removeEventListener
(
"click"
,
this
.
barClose
);
window
.
removeEventListener
(
"click"
,
this
.
barClose
);
window
.
removeEventListener
(
"resize"
,
this
.
onResize
);
},
},
};
};
</
script
>
</
script
>
...
...
gassafety-web/src/views/enterprise/mapView/index.vue
View file @
e2b35608
<
template
>
<
template
>
<div>
<div>
<div
style=
"width: 100vw;"
:style=
"
{height:`${boxHeight}px`}" id="container">
</div>
<div
:style=
"
{ height: `${boxHeight}px`, width: `${boxWidth}px` }"
id="container"
>
</div>
<div
v-show=
"false"
class=
"btn-wrapper"
>
<div
v-show=
"false"
class=
"btn-wrapper"
>
<div
class=
"myBtn"
>
<div
class=
"myBtn"
>
<div
<div
...
@@ -379,6 +382,7 @@ export default {
...
@@ -379,6 +382,7 @@ export default {
// 左边抽屉 内嵌scroll盒子的高
// 左边抽屉 内嵌scroll盒子的高
boxHeight
:
""
,
boxHeight
:
""
,
boxWidth
:
""
,
drawerOpacity
:
false
,
drawerOpacity
:
false
,
//抽屉是否收回
//抽屉是否收回
backFlag
:
true
,
backFlag
:
true
,
...
@@ -391,9 +395,11 @@ export default {
...
@@ -391,9 +395,11 @@ export default {
},
},
mounted
()
{
mounted
()
{
this
.
boxHeight
=
document
.
body
.
clientHeight
-
81
;
// this.$nextTick(() => {
// this.$nextTick(() => {
this
.
onResize
();
window
.
removeEventListener
(
"resize"
,
this
.
onResize
);
window
.
addEventListener
(
"resize"
,
this
.
onResize
);
this
.
initMap
();
this
.
initMap
();
// });
// });
},
},
...
@@ -405,6 +411,11 @@ export default {
...
@@ -405,6 +411,11 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
onResize
()
{
this
.
boxHeight
=
document
.
body
.
clientHeight
-
81
;
this
.
boxWidth
=
document
.
body
.
clientWidth
;
console
.
log
(
"挂在"
)
},
initMap
()
{
initMap
()
{
let
gaoMap
=
new
gaodeMap
(
"石家庄"
);
let
gaoMap
=
new
gaodeMap
(
"石家庄"
);
this
.
gaoMap
=
gaoMap
;
this
.
gaoMap
=
gaoMap
;
...
@@ -1271,7 +1282,7 @@ export default {
...
@@ -1271,7 +1282,7 @@ export default {
// return;
// return;
console
.
log
(
"window"
);
console
.
log
(
"window"
);
// 颜色恢复
// 颜色恢复
this
.
deviceType
=
false
;
this
.
deviceType
=
false
;
// 关闭当前线条的infowindow
// 关闭当前线条的infowindow
// this.gaoMap.closeInfoWindow();
// this.gaoMap.closeInfoWindow();
...
@@ -1364,6 +1375,8 @@ export default {
...
@@ -1364,6 +1375,8 @@ export default {
console
.
log
(
"移除window事件"
);
console
.
log
(
"移除window事件"
);
map
.
clearMap
();
map
.
clearMap
();
window
.
removeEventListener
(
"mousedown"
,
this
.
barClose
);
window
.
removeEventListener
(
"mousedown"
,
this
.
barClose
);
window
.
removeEventListener
(
"resize"
,
this
.
onResize
);
// 关闭scoket
// 关闭scoket
if
(
this
.
ws
)
{
if
(
this
.
ws
)
{
console
.
log
(
"socket关闭了"
);
console
.
log
(
"socket关闭了"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment