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
96256c3d
Commit
96256c3d
authored
Oct 25, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取商圈经纬度
parent
a62d0035
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
0 deletions
+57
-0
BusinessDistrict.php
application/index/controller/BusinessDistrict.php
+4
-0
HouseService.php
application/index/service/HouseService.php
+53
-0
No files found.
application/index/controller/BusinessDistrict.php
View file @
96256c3d
...
@@ -10,6 +10,7 @@ namespace app\index\controller;
...
@@ -10,6 +10,7 @@ namespace app\index\controller;
use
app\index\extend\Basic
;
use
app\index\extend\Basic
;
use
app\index\service\HouseService
;
use
app\model\GBusinessDistrict
;
use
app\model\GBusinessDistrict
;
use
app\model\Regions
;
use
app\model\Regions
;
...
@@ -42,6 +43,9 @@ class BusinessDistrict extends Basic
...
@@ -42,6 +43,9 @@ class BusinessDistrict extends Basic
}
else
{
}
else
{
$business
->
save
(
$data
);
$business
->
save
(
$data
);
$num
=
$business
->
id
;
$num
=
$business
->
id
;
/*获取商圈经纬度*/
$house
=
new
HouseService
();
$house
->
setCityLatAadLng
(
$num
,
$params
[
'business'
],
$params
[
'city'
]);
}
}
if
(
$num
)
{
if
(
$num
)
{
...
...
application/index/service/HouseService.php
View file @
96256c3d
...
@@ -12,6 +12,7 @@ namespace app\index\service;
...
@@ -12,6 +12,7 @@ namespace app\index\service;
use
app\api_broker\service\PushMessageService
;
use
app\api_broker\service\PushMessageService
;
use
app\index\validate\HouseValidate
;
use
app\index\validate\HouseValidate
;
use
app\model\AAgents
;
use
app\model\AAgents
;
use
app\model\GBusinessDistrict
;
use
app\model\GHouseFile
;
use
app\model\GHouseFile
;
use
app\model\GHouses
;
use
app\model\GHouses
;
use
app\model\GHousesExt
;
use
app\model\GHousesExt
;
...
@@ -363,4 +364,55 @@ class HouseService
...
@@ -363,4 +364,55 @@ class HouseService
return
$result
;
return
$result
;
}
}
/**
* 批量设置商圈的经纬度
*/
public
function
setCityLatAadLng
(
$id
,
$name
,
$city
){
if
(
!
$id
or
!
$name
or
!
$city
){
return
false
;
}
$model
=
new
GBusinessDistrict
();
$res
=
$this
->
getLatLng
(
$name
,
$city
);
if
(
$res
){
$longitude
=
$res
[
'lng'
];
//'经度'
$latitude
=
$res
[
'lat'
];
//'维度'
}
else
{
$longitude
=
''
;
//'经度'
$latitude
=
''
;
//'维度'
}
$insert
=
[];
$insert
[
"id"
]
=
$id
;
$insert
[
"longitude"
]
=
$longitude
;
$insert
[
"latitude"
]
=
$latitude
;
$model
->
updateBusinessDistrict
(
$insert
);
//int(1)
return
true
;
}
/**
* @param string $address 地址
* @param string $city 城市名
* @return array
*/
function
getLatLng
(
$address
=
''
,
$city
=
''
)
{
$result
=
array
();
$ak
=
'eqkGg4WQehHn4k7ssWZTv8RPvydUm35s'
;
//您的百度地图ak,可以去百度开发者中心去免费申请
$url
=
"http://api.map.baidu.com/geocoder/v2/?callback=renderOption&output=json&address="
.
$address
.
"&city="
.
$city
.
"&ak="
.
$ak
;
$data
=
file_get_contents
(
$url
);
$data
=
str_replace
(
'renderOption&&renderOption('
,
''
,
$data
);
$data
=
str_replace
(
')'
,
''
,
$data
);
$data
=
json_decode
(
$data
,
true
);
if
(
!
empty
(
$data
)
&&
$data
[
'status'
]
==
0
)
{
$result
[
'lat'
]
=
$data
[
'result'
][
'location'
][
'lat'
];
$result
[
'lng'
]
=
$data
[
'result'
][
'location'
][
'lng'
];
return
$result
;
//返回经纬度结果
}
else
{
return
null
;
}
}
}
}
\ No newline at end of file
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