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
e5f6c55d
Commit
e5f6c55d
authored
Jul 12, 2021
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
地图工具类 gengdidi
parent
3bbdfba8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
24 deletions
+40
-24
index.html
gassafety-web/public/index.html
+1
-1
gaodeMap.js
gassafety-web/src/utils/gaodeMap.js
+31
-14
index.vue
gassafety-web/src/views/enterprise/map/index.vue
+8
-9
No files found.
gassafety-web/public/index.html
View file @
e5f6c55d
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<title><
%=
webpackConfig
.
name
%
></title>
<title><
%=
webpackConfig
.
name
%
></title>
<!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
<!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
<script
src=
"https://webapi.amap.com/maps?v=2.0&key=eed7ca3167f765467aa377fa78e61ece&plugin=Map3D,AMap.DistrictSearch,AMap.Scale,AMap.OverView,AMap.ToolBar,AMap.MouseTool,AMap.ControlBar,AMap.CircleEditor,AMap.PolyEditor
,AMap.MapType
"
></script>
<script
src=
"https://webapi.amap.com/maps?v=2.0&key=eed7ca3167f765467aa377fa78e61ece&plugin=Map3D,AMap.DistrictSearch,AMap.Scale,AMap.OverView,AMap.ToolBar,AMap.MouseTool,AMap.ControlBar,AMap.CircleEditor,AMap.PolyEditor"
></script>
<style>
<style>
html
,
html
,
body
,
body
,
...
...
gassafety-web/src/utils/gaodeMap.js
View file @
e5f6c55d
...
@@ -74,7 +74,7 @@ class gaodeMap {
...
@@ -74,7 +74,7 @@ class gaodeMap {
*/
*/
addMarker
(
lnglats
){
addMarker
(
lnglats
){
let
infoWindow
=
new
AMap
.
InfoWindow
({
offset
:
new
AMap
.
Pixel
(
-
13
,
-
70
)});
let
infoWindow
=
new
AMap
.
InfoWindow
({
offset
:
new
AMap
.
Pixel
(
-
13
,
-
70
)});
for
(
let
i
=
0
,
marker
;
i
<
lnglats
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
lnglats
.
length
;
i
++
)
{
let
marker
=
new
AMap
.
Marker
({
let
marker
=
new
AMap
.
Marker
({
position
:
lnglats
[
i
],
position
:
lnglats
[
i
],
map
:
map
,
map
:
map
,
...
@@ -161,12 +161,12 @@ class gaodeMap {
...
@@ -161,12 +161,12 @@ class gaodeMap {
* 添加鼠标事件
* 添加鼠标事件
*/
*/
addMouseTool
(){
addMouseTool
(){
var
mouseTool
=
new
AMap
.
MouseTool
(
map
);
let
mouseTool
=
new
AMap
.
MouseTool
(
map
);
//监听draw事件可获取画好的覆盖物
//监听draw事件可获取画好的覆盖物
var
overlays
=
[];
let
overlays
=
[];
mouseTool
.
on
(
'draw'
,
function
(
e
){
mouseTool
.
on
(
'draw'
,
function
(
e
){
overlays
.
push
(
e
.
obj
);
overlays
.
push
(
e
.
obj
);
})
})
;
function
draw
(
type
){
function
draw
(
type
){
switch
(
type
){
switch
(
type
){
...
@@ -211,33 +211,50 @@ class gaodeMap {
...
@@ -211,33 +211,50 @@ class gaodeMap {
}
}
}
}
var
radios
=
document
.
getElementsByName
(
'func'
);
let
radios
=
document
.
getElementsByName
(
'func'
);
for
(
var
i
=
0
;
i
<
radios
.
length
;
i
+=
1
){
for
(
let
i
=
0
;
i
<
radios
.
length
;
i
+=
1
){
radios
[
i
].
onchange
=
function
(
e
){
radios
[
i
].
onchange
=
function
(
e
){
draw
(
e
.
target
.
value
)
draw
(
e
.
target
.
value
)
}
}
}
}
draw
(
'marker'
)
draw
(
'marker'
)
;
document
.
getElementById
(
'clear'
).
onclick
=
function
(){
document
.
getElementById
(
'clear'
).
onclick
=
function
(){
map
.
remove
(
overlays
)
map
.
remove
(
overlays
)
overlays
=
[];
overlays
=
[];
}
}
document
.
getElementById
(
'close'
).
onclick
=
function
(){
document
.
getElementById
(
'close'
).
onclick
=
function
(){
mouseTool
.
close
(
true
)
//关闭,并清除覆盖物
mouseTool
.
close
(
true
)
//关闭,并清除覆盖物
for
(
var
i
=
0
;
i
<
radios
.
length
;
i
+=
1
){
for
(
let
i
=
0
;
i
<
radios
.
length
;
i
+=
1
){
radios
[
i
].
checked
=
false
;
radios
[
i
].
checked
=
false
;
}
}
}
}
}
}
amapLoader
(){
/**
AMap
.
plugin
([
'AMap.ToolBar'
,
'AMap.Scale'
,
'AMap.OverView'
,
'AMap.MapType'
,
'AMap.Geolocation'
],
function
(){
* 添加地图控件
//创建并添加工具控件,上下左右移动,以及缩放
*/
addMapControl
(){
AMap
.
plugin
([
'AMap.ToolBar'
,
'AMap.Scale'
,
'AMap.HawkEye'
,
'AMap.MapType'
,
'AMap.Geolocation'
,
],
function
(){
// 在图面添加工具条控件,工具条控件集成了缩放、平移、定位等功能按钮在内的组合控件
//map.addControl(new AMap.ToolBar());
//map.addControl(new AMap.ToolBar());
// 在图面添加比例尺控件,展示地图在当前层级和纬度下的比例尺
map
.
addControl
(
new
AMap
.
Scale
());
map
.
addControl
(
new
AMap
.
Scale
());
//map.addControl(new AMap.OverView({isOpen:true}))
map
.
addControl
(
new
AMap
.
MapType
());
// 在图面添加鹰眼控件,在地图右下角显示地图的缩略图
//map.addControl(new AMap.Geolocation());
map
.
addControl
(
new
AMap
.
HawkEye
({
isOpen
:
true
}));
// 在图面添加类别切换控件,实现默认图层与卫星图、实施交通图层之间切换的控制
map
.
addControl
(
new
AMap
.
MapType
({
position
:{
top
:
'10px'
,
left
:
'100px'
}}));
// 在图面添加定位控件,用来获取和展示用户主机所在的经纬度位置
// map.addControl(new AMap.Geolocation());
});
});
}
}
...
...
gassafety-web/src/views/enterprise/map/index.vue
View file @
e5f6c55d
...
@@ -40,21 +40,20 @@
...
@@ -40,21 +40,20 @@
gaoMap
.
addMarker
(
lnglats
)
gaoMap
.
addMarker
(
lnglats
)
let
path
=
[
let
path
=
[
[
[
[
114.534792
,
38.022417
],
[
114.436698
,
38.083306
],
[
114.544748
,
38.073245
],
[
114.57952
,
38.065468
],
[
114.58114
,
38.066218
],
[
114.57952
,
38.002732
],
[
114.593843
,
38.040265
]
[
114.440131
,
38.006519
],
[
114.436698
,
38.083306
]
],
],
[
[
[
114.508699
,
38.082434
],
[
114.528708
,
38.075198
],
[
114.559167
,
38.087298
],
[
114.530768
,
38.00165
]
[
114.628175
,
38.049457
],
[
114.543718
,
38.021605
]
]
]
]
]
gaoMap
.
addPolyline
(
path
);
gaoMap
.
addPolyline
(
path
);
gaoMap
.
addMouseTool
();
gaoMap
.
addMouseTool
();
gaoMap
.
a
mapLoader
();
gaoMap
.
a
ddMapControl
();
}
}
};
};
</
script
>
</
script
>
...
...
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