Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Athena
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
华国豪
Athena
Commits
e73a3e2f
Commit
e73a3e2f
authored
Jan 02, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
6f465ab2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
166 additions
and
150 deletions
+166
-150
tripMap.vue
src/components/global/tripMap.vue
+166
-150
No files found.
src/components/global/tripMap.vue
View file @
e73a3e2f
...
...
@@ -70,7 +70,6 @@
// 地图实例
mapBuild
()
{
if
(
this
.
locationArray
&&
this
.
locationArray
.
length
>
0
)
{
let
lat
=
parseFloat
(
this
.
locationArray
[
0
].
lat
)
let
lng
=
parseFloat
(
this
.
locationArray
[
0
].
lng
)
let
center
=
{
...
...
@@ -117,44 +116,61 @@
this
.
directionsDisplay
.
setMap
(
this
.
map
);
this
.
calcRoute
()
}
},
checkItemIsExists
(
arr
,
checkItem
)
{
var
isExists
=
false
;
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
].
location
==
checkItem
.
location
&&
!
isExists
)
{
isExists
=
true
;
}
}
return
isExists
;
},
calcRoute
:
function
()
{
// 创建路径规划
// 分解数据 获得起 止 以及中间数据
console
.
log
(
this
.
locationArray
,
'加载后....'
);
let
lat
=
parseFloat
(
this
.
locationArray
[
0
].
lat
)
let
lng
=
parseFloat
(
this
.
locationArray
[
0
].
lng
)
let
elat
=
parseFloat
(
this
.
locationArray
[
this
.
locationArray
.
length
-
1
].
lat
)
let
elng
=
parseFloat
(
this
.
locationArray
[
this
.
locationArray
.
length
-
1
].
lng
)
if
(
this
.
locationArray
&&
this
.
locationArray
.
length
>
0
)
{
let
_this
=
this
;
let
start
=
lat
+
','
+
lng
;
let
end
=
elat
+
','
+
elng
;
let
waypoints
=
[];
if
(
this
.
locationArray
.
length
>
2
)
{
this
.
locationArray
.
forEach
((
x
,
index
)
=>
{
if
(
index
>=
1
&&
index
!==
(
this
.
locationArray
.
length
-
1
)
)
{
if
(
x
.
lat
&&
x
.
lng
)
{
let
obj
=
{
location
:
x
.
lat
+
','
+
x
.
lng
}
waypoints
.
push
(
obj
)
if
(
!
_this
.
checkItemIsExists
(
waypoints
,
obj
))
{
waypoints
.
push
(
obj
);
}
});
}
});
var
startArray
=
waypoints
[
0
].
location
.
split
(
','
);
var
endArray
=
waypoints
[
waypoints
.
length
-
1
].
location
.
split
(
','
);
let
lat
=
parseFloat
(
startArray
[
0
]);
let
lng
=
parseFloat
(
startArray
[
1
]);
let
elat
=
parseFloat
(
endArray
[
0
]);
let
elng
=
parseFloat
(
endArray
[
1
]);
let
start
=
lat
+
','
+
lng
;
let
end
=
elat
+
','
+
elng
;
let
request
=
{
// 组装连线数据
origin
:
start
,
// 起
destination
:
end
,
// 止
travelMode
:
google
.
maps
.
TravelMode
.
DRIVING
,
// waypoints: [{location:"30.5226477,104.05806469999993"},{location:"30.67416759999999,104.04721970000003"}] // 中间点数据
waypoints
:[]
};
if
(
waypoints
.
length
>
0
)
{
request
.
waypoints
=
waypoints
if
(
waypoints
&&
waypoints
.
length
>
0
)
{
if
(
waypoints
.
length
>
2
)
{
waypoints
.
forEach
((
item
,
index
)
=>
{
if
(
index
!=
0
&&
index
!=
waypoints
.
length
-
1
)
{
request
.
waypoints
.
push
(
item
);
}
console
.
log
(
waypoints
,
'waypointsss'
)
})
}
}
console
.
log
(
request
,
'request'
)
_this
.
directionsService
.
route
(
request
,
function
(
result
,
status
)
{
if
(
status
==
google
.
maps
.
DirectionsStatus
.
OK
)
{
_this
.
directionsDisplay
.
setDirections
(
result
);
}
});
}
},
},
}
...
...
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