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
eb4de9ef
Commit
eb4de9ef
authored
Aug 14, 2021
by
纪泽龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抽屉列表点击infowindow显示
parent
1ad5a4ef
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
252 additions
and
135 deletions
+252
-135
gaodeMapView.js
gassafety-web/src/utils/gaodeMapView.js
+137
-111
index.vue
gassafety-web/src/views/enterprise/mapView/index.vue
+115
-24
No files found.
gassafety-web/src/utils/gaodeMapView.js
View file @
eb4de9ef
...
@@ -49,6 +49,7 @@ class gaodeMap {
...
@@ -49,6 +49,7 @@ class gaodeMap {
// 工人轨迹用的窗口
// 工人轨迹用的窗口
markerPassedPolylineInfoWindow
=
null
;
markerPassedPolylineInfoWindow
=
null
;
view
=
null
;
view
=
null
;
handleInfoWindowOpenFunc
=
null
;
//构造函数中设置中央点默认值
//构造函数中设置中央点默认值
constructor
(
center
)
{
constructor
(
center
)
{
...
@@ -101,8 +102,15 @@ class gaodeMap {
...
@@ -101,8 +102,15 @@ class gaodeMap {
// console.log("缩放开始")
// console.log("缩放开始")
this
.
closeInfoWindow
();
this
.
closeInfoWindow
();
});
});
this
.
myMap
.
on
(
"moveend"
,
()
=>
{
if
(
this
.
handleInfoWindowOpenFunc
)
{
this
.
handleInfoWindowOpenFunc
();
this
.
handleInfoWindowOpenFunc
=
null
;
}
});
this
.
districtBoundaries
();
this
.
districtBoundaries
();
}
}
// 地图移动结束
/**
/**
* 获取map
* 获取map
...
@@ -156,7 +164,10 @@ class gaodeMap {
...
@@ -156,7 +164,10 @@ class gaodeMap {
}
}
});
});
}
}
// 地图中点平移
panTo
(
lnglat
)
{
this
.
myMap
.
panTo
(
lnglat
);
}
/**
/**
* 添加Market
* 添加Market
* @param markerType
* @param markerType
...
@@ -247,10 +258,10 @@ class gaodeMap {
...
@@ -247,10 +258,10 @@ class gaodeMap {
DEVICE_TYPE
.
SMALLINSPECTOR
!=
markerType
DEVICE_TYPE
.
SMALLINSPECTOR
!=
markerType
)
{
)
{
// marker.content = this.getMarketContent(data, markerInfoWindow);
// marker.content = this.getMarketContent(data, markerInfoWindow);
marker
.
on
(
"mouseover"
,
infoOpen
);
marker
.
infoWindow
=
infoWindow
;
marker
.
on
(
"mouseover"
,
that
.
infoOpen
);
marker
.
on
(
"mouseout"
,
infoClose
);
marker
.
on
(
"mouseout"
,
infoClose
);
marker
.
setExtData
(
data
);
marker
.
setExtData
(
data
);
that
.
deviceType
=
markerType
;
that
.
deviceType
=
markerType
;
let
editWindow
=
that
.
createInfowindow
(
"编辑"
);
let
editWindow
=
that
.
createInfowindow
(
"编辑"
);
editWindow
.
fileArr
=
editWindow
.
fileArr
=
...
@@ -327,16 +338,21 @@ class gaodeMap {
...
@@ -327,16 +338,21 @@ class gaodeMap {
//infoWindow.close(map, e.target.getPosition());
//infoWindow.close(map, e.target.getPosition());
}
}
function
infoOpen
(
e
)
{
// function infoOpen(e) {}
return
marker
;
}
infoOpen
=
e
=>
{
if
(
e
.
target
.
getExtData
().
alarmState
==
1
)
{
if
(
e
.
target
.
getExtData
().
alarmState
==
1
)
{
if
(
e
.
target
.
getExtData
().
deviceType
==
4
)
{
if
(
e
.
target
.
getExtData
().
deviceType
==
4
)
{
that
.
markerType
=
"7"
;
this
.
markerType
=
"7"
;
}
else
if
(
e
.
target
.
getExtData
().
deviceType
<=
3
)
{
}
else
if
(
e
.
target
.
getExtData
().
deviceType
<=
3
)
{
that
.
markerType
=
+
e
.
target
.
getExtData
().
deviceType
+
1
+
""
;
this
.
markerType
=
+
e
.
target
.
getExtData
().
deviceType
+
1
+
""
;
}
}
console
.
log
(
"that.markerType"
,
that
.
markerType
);
console
.
log
(
"that.markerType"
,
this
.
markerType
);
// 警告状态这样就要换infowindow
// 警告状态这样就要换infowindow
e
.
target
.
content
=
that
.
getMarketContent
(
e
.
target
.
content
=
this
.
getMarketContent
(
e
.
target
.
getExtData
(),
e
.
target
.
getExtData
(),
markerInfoWindowWarn
markerInfoWindowWarn
);
);
...
@@ -348,12 +364,12 @@ class gaodeMap {
...
@@ -348,12 +364,12 @@ class gaodeMap {
// : e.target.getExtData().deviceType + "";
// : e.target.getExtData().deviceType + "";
// 上图状态跟后台状态不统一,所以需要判断一下
// 上图状态跟后台状态不统一,所以需要判断一下
if
(
e
.
target
.
getExtData
().
deviceType
==
4
)
{
if
(
e
.
target
.
getExtData
().
deviceType
==
4
)
{
that
.
markerType
=
"7"
;
this
.
markerType
=
"7"
;
}
else
if
(
e
.
target
.
getExtData
().
deviceType
<=
3
)
{
}
else
if
(
e
.
target
.
getExtData
().
deviceType
<=
3
)
{
that
.
markerType
=
+
e
.
target
.
getExtData
().
deviceType
+
1
+
""
;
this
.
markerType
=
+
e
.
target
.
getExtData
().
deviceType
+
1
+
""
;
}
}
console
.
log
(
"that
.markerType"
);
console
.
log
(
"this
.markerType"
);
e
.
target
.
content
=
that
.
getMarketContent
(
e
.
target
.
content
=
this
.
getMarketContent
(
e
.
target
.
getExtData
(),
e
.
target
.
getExtData
(),
markerInfoWindow
markerInfoWindow
);
);
...
@@ -362,20 +378,16 @@ class gaodeMap {
...
@@ -362,20 +378,16 @@ class gaodeMap {
let
options
=
map
.
getStatus
();
let
options
=
map
.
getStatus
();
options
.
scrollWheel
=
false
;
options
.
scrollWheel
=
false
;
map
.
setStatus
(
options
);
map
.
setStatus
(
options
);
infoWindow
.
setContent
(
e
.
target
.
content
);
e
.
target
.
infoWindow
.
setContent
(
e
.
target
.
content
);
infoWindow
.
open
(
map
,
e
.
target
.
getPosition
());
e
.
target
.
infoWindow
.
open
(
map
,
e
.
target
.
getPosition
());
// 检测是否碰到底部的bottomData
// 检测是否碰到底部的bottomData
that
.
boxCollision
(
infoWindow
.
dom
);
this
.
boxCollision
(
e
.
target
.
infoWindow
.
dom
);
// that.addCloneDome(e.target, infoWindow);
// that.addCloneDome(e.target, infoWindow);
// infoWindow.close();
// infoWindow.close();
that
.
markerInfoWindow
=
infoWindow
;
this
.
markerInfoWindow
=
e
.
target
.
infoWindow
;
}
};
return
marker
;
}
/**
/**
* marker添加拖拽事件
* marker添加拖拽事件
*/
*/
...
@@ -399,7 +411,7 @@ class gaodeMap {
...
@@ -399,7 +411,7 @@ class gaodeMap {
* @returns {string}
* @returns {string}
*/
*/
getMarketContent
(
Data
,
markerInfoWindow
)
{
getMarketContent
(
Data
,
markerInfoWindow
)
{
let
data
=
{
...
Data
}
let
data
=
{
...
Data
};
data
.
class
=
this
;
data
.
class
=
this
;
console
.
log
(
"this.markerType"
,
this
.
markerType
);
console
.
log
(
"this.markerType"
,
this
.
markerType
);
switch
(
this
.
markerType
)
{
switch
(
this
.
markerType
)
{
...
@@ -407,7 +419,7 @@ class gaodeMap {
...
@@ -407,7 +419,7 @@ class gaodeMap {
const
dom
=
createPop
(
markerInfoWindow
,
{
const
dom
=
createPop
(
markerInfoWindow
,
{
title
:
"调压箱"
,
title
:
"调压箱"
,
data
:
data
,
data
:
data
,
map
:
map
,
map
:
map
});
});
const
html
=
dom
.
$el
;
const
html
=
dom
.
$el
;
dom
.
remove
();
dom
.
remove
();
...
@@ -715,17 +727,41 @@ class gaodeMap {
...
@@ -715,17 +727,41 @@ class gaodeMap {
// 信息窗体
// 信息窗体
this
.
newLineAddEvent
(
polyline
);
this
.
newLineAddEvent
(
polyline
);
//添加事件
//添加事件
polyline
.
on
(
"mouseover"
,
e
=>
{
polyline
.
on
(
"mouseover"
,
this
.
polylineMouseOver
);
polyline
.
on
(
"mouseout"
,
e
=>
{
// console.log("polyline.getExtData().lineData.alarmState",polyline.getExtData().lineData.alarmState)
if
(
polyline
.
getExtData
().
lineData
.
alarmState
==
1
)
return
;
polyline
.
setOptions
({
strokeColor
:
"#F7FE38"
});
// infoWindow.close();
});
// 计算info的位置
// function infoPosition() {}
}
map
.
add
(
this
.
polyLines
);
// 缩放地图到合适的视野级别
// map.setFitView();
}
// 鼠标移入线条执行
polylineMouseOver
=
e
=>
{
let
polyline
=
e
.
target
;
if
(
this
.
lineType
==
1
)
return
;
if
(
this
.
lineType
==
1
)
return
;
// 生成infoWindow
// 生成infoWindow
let
infoWindow
;
let
infoWindow
;
// 警告状态时
// 警告状态时
const
item
=
e
.
target
.
getExtData
().
lineData
;
// console.log("item",item)
if
(
e
.
target
.
getExtData
().
lineData
.
alarmState
==
1
)
{
if
(
e
.
target
.
getExtData
().
lineData
.
alarmState
==
1
)
{
infoWindow
=
this
.
lineMouseOver
(
polyline
,
lineInfoWindowWarn
,
item
);
infoWindow
=
this
.
lineMouseOver
(
polyline
,
lineInfoWindowWarn
,
item
);
}
else
{
}
else
{
infoWindow
=
this
.
lineMouseOver
(
polyline
,
lineInfoWindow
,
item
);
infoWindow
=
this
.
lineMouseOver
(
polyline
,
lineInfoWindow
,
item
);
}
}
infoWindow
.
open
(
map
,
e
.
lnglat
);
infoWindow
.
open
(
map
,
e
.
lnglat
);
console
.
log
(
infoWindow
);
// 如果是鼠标真正移入,则计算位置,如果不是鼠标真正移入,是人为执行出现infowindow,则不计算位置
console
.
log
(
"e.originEvent"
,
e
.
originEvent
);
if
(
e
.
originEvent
)
{
// 上方导航的高
// 上方导航的高
const
topBar
=
81
;
const
topBar
=
81
;
// 坐标导航的宽
// 坐标导航的宽
...
@@ -772,25 +808,15 @@ class gaodeMap {
...
@@ -772,25 +808,15 @@ class gaodeMap {
}
else
{
}
else
{
polyline
.
setOptions
({
strokeColor
:
"#FF5A67"
});
polyline
.
setOptions
({
strokeColor
:
"#FF5A67"
});
}
}
infoWindow
.
setOffset
(
new
AMap
.
Pixel
(
X
,
Y
));
infoWindow
.
setOffset
(
new
AMap
.
Pixel
(
X
,
Y
));
}
else
{
infoWindow
.
setOffset
(
new
AMap
.
Pixel
(
20
,
-
20
));
}
this
.
boxCollision
(
infoWindow
.
dom
);
this
.
boxCollision
(
infoWindow
.
dom
);
this
.
showInfoWindow
=
infoWindow
;
this
.
showInfoWindow
=
infoWindow
;
// const
// const
});
};
polyline
.
on
(
"mouseout"
,
e
=>
{
// console.log("polyline.getExtData().lineData.alarmState",polyline.getExtData().lineData.alarmState)
if
(
polyline
.
getExtData
().
lineData
.
alarmState
==
1
)
return
;
polyline
.
setOptions
({
strokeColor
:
"#F7FE38"
});
// infoWindow.close();
});
// 计算info的位置
// function infoPosition() {}
}
map
.
add
(
this
.
polyLines
);
// 缩放地图到合适的视野级别
// map.setFitView();
}
lineMouseOver
(
polyline
,
lineInfoWindow
,
item
)
{
lineMouseOver
(
polyline
,
lineInfoWindow
,
item
)
{
let
dom
=
createPop
(
lineInfoWindow
,
{
let
dom
=
createPop
(
lineInfoWindow
,
{
obj
:
{
a
:
123
,
editorPage
:
true
,
...
item
,
polyline
}
obj
:
{
a
:
123
,
editorPage
:
true
,
...
item
,
polyline
}
...
...
gassafety-web/src/views/enterprise/mapView/index.vue
View file @
eb4de9ef
This diff is collapsed.
Click to expand it.
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