Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
million
Project
Project
Details
Activity
Releases
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
viitto
million
Commits
727713a7
Commit
727713a7
authored
Mar 16, 2023
by
youjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
5e3e8767
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
1 deletion
+80
-1
Map.vue
src/components/car/Map.vue
+80
-1
No files found.
src/components/car/Map.vue
View file @
727713a7
...
...
@@ -53,8 +53,14 @@
let
map
=
new
BMapGL
.
Map
(
`baidu-map_
${
this
.
center
.
Id
}
`
);
// 创建地图实例
let
point
=
new
BMapGL
.
Point
(
this
.
center
.
Lng
,
this
.
center
.
Lat
);
// 创建点坐标
map
.
centerAndZoom
(
point
,
15
);
// 初始化地图,设置中心点坐标和地图级别
map
.
enableScrollWheelZoom
(
true
);
var
scaleCtrl
=
new
BMapGL
.
ScaleControl
();
// 添加比例尺控件
map
.
addControl
(
scaleCtrl
);
var
zoomCtrl
=
new
BMapGL
.
ZoomControl
();
// 添加缩放控件//开启鼠标滚轮缩放
map
.
addControl
(
zoomCtrl
);
this
.
map
=
map
;
},
addMarker
()
{
let
icon
=
require
(
`../../assets/img/marker.png`
);
var
myIcon
=
new
BMapGL
.
Icon
(
icon
,
new
BMapGL
.
Size
(
23
,
25
),
{
...
...
@@ -97,13 +103,86 @@
addCircle
(){
var
mPoint
=
new
BMapGL
.
Point
(
this
.
center
.
Lng
,
this
.
center
.
Lat
);
var
circle
=
new
BMapGL
.
Circle
(
mPoint
,
this
.
center
.
Range
,{
fillColor
:
"blue"
,
strokeWeight
:
1
,
fillOpacity
:
0.3
,
strokeOpacity
:
0.3
});
this
.
map
.
addOverlay
(
circle
);
this
.
map
.
addOverlay
(
circle
);
let
getNeSw
=
circle
.
getBounds
()
var
mPoint1
=
new
BMapGL
.
Point
(
getNeSw
.
ne
.
lng
,
getNeSw
.
ne
.
lat
)
var
mPoint2
=
new
BMapGL
.
Point
(
getNeSw
.
sw
.
lng
,
getNeSw
.
sw
.
lat
)
let
points
=
[
mPoint1
,
mPoint2
]
this
.
map
.
centerAndZoom
(
mPoint
,
this
.
map
.
getViewport
(
points
).
zoom
+
1
);
},
getLocalSearch
(){
var
mPoint
=
new
BMapGL
.
Point
(
this
.
center
.
Lng
,
this
.
center
.
Lat
);
var
local
=
new
BMapGL
.
LocalSearch
(
this
.
map
,
{
renderOptions
:
{
map
:
this
.
map
,
autoViewport
:
false
}});
local
.
searchNearby
(
this
.
keywords
,
mPoint
,
this
.
center
.
Range
);
},
// 根据地图缩放比例获取当前地图比例尺
getMapScale
(
zoom
){
let
scale
=
0
;
switch
(
zoom
)
{
case
1
:
scale
=
10000000
;
break
;
case
2
:
scale
=
5000000
;
break
;
case
3
:
scale
=
2000000
;
break
;
case
4
:
scale
=
1000000
;
break
;
case
5
:
scale
=
500000
;
break
;
case
6
:
scale
=
200000
;
break
;
case
7
:
scale
=
100000
;
break
;
case
8
:
scale
=
50000
;
break
;
case
9
:
scale
=
25000
;
break
;
case
10
:
scale
=
20000
;
break
;
case
11
:
scale
=
10000
;
break
;
case
12
:
scale
=
5000
;
break
;
case
13
:
scale
=
2000
;
break
;
case
14
:
scale
=
1000
;
break
;
case
15
:
scale
=
500
;
break
;
case
16
:
scale
=
200
;
break
;
case
17
:
scale
=
100
;
break
;
case
18
:
scale
=
50
;
break
;
case
19
:
scale
=
20
;
break
;
default
:
scale
=
0
;
break
;
}
return
scale
;
},
},
}
</
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