Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
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
hujun
tl_estate
Commits
2adf9d02
Commit
2adf9d02
authored
Sep 18, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
d3f2b147
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
PositionService.php
application/index/service/PositionService.php
+3
-4
No files found.
application/index/service/PositionService.php
View file @
2adf9d02
...
...
@@ -19,6 +19,7 @@ class PositionService
* @param $first_position //起点(举个栗子:'31.067059,121.518854')
* @param $end_position //终点(举个栗子:'31.079655,121.51713')
* @return string 返回数值单位 '米'
* 百度轻量级路线规划服务文档地址 http://lbsyun.baidu.com/index.php?title=webapi/directionlite-v1
*/
public
function
getPositionDistance
(
$first_position
,
$end_position
)
{
...
...
@@ -27,7 +28,6 @@ class PositionService
}
$ak
=
'eqkGg4WQehHn4k7ssWZTv8RPvydUm35s'
;
// $url ="http://api.map.baidu.com/direction/v2/transit?origin={$first_position}&destination={$end_position}&ak={$ak}";
$url
=
"http://api.map.baidu.com/directionlite/v1/walking?origin=
{
$first_position
}
&destination=
{
$end_position
}
&ak=
{
$ak
}
"
;
$data
=
file_get_contents
(
$url
);
$data
=
str_replace
(
'renderOption&&renderOption('
,
''
,
$data
);
...
...
@@ -54,7 +54,6 @@ class PositionService
$first_position
=
$a_latitude
.
','
.
$a_longitude
;
$end_position
=
$b_latitude
.
','
.
$b_longitude
;
$distance
=
$this
->
getPositionDistance
(
$first_position
,
$end_position
);
dump
(
$distance
);
if
(
$distance
<=
$limit_distance
)
{
$result
=
true
;
}
else
{
...
...
@@ -75,8 +74,8 @@ class PositionService
* @return int
*/
function
getDistance
(
$lat1
,
$lng1
,
$lat2
,
$lng2
){
//
将角度转为狐
度
$radLat1
=
deg2rad
(
$lat1
);
// deg2rad()函数将角度转换为弧度
//
将角度转为狐度 deg2rad()函数将角度转换为弧
度
$radLat1
=
deg2rad
(
$lat1
);
$radLat2
=
deg2rad
(
$lat2
);
$radLng1
=
deg2rad
(
$lng1
);
$radLng2
=
deg2rad
(
$lng2
);
...
...
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