Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
Jz-Php
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
PHP
Jz-Php
Commits
96571199
提交
96571199
authored
5月 08, 2020
作者:
fengzy
提交者:
wangkr
5月 13, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
基站地图
上级
adec06e2
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
377 行增加
和
103 行删除
+377
-103
Region.php
application/em/controller/Region.php
+67
-47
region_list.html
application/em/view/region/region_list.html
+53
-56
region_list1.html
application/em/view/region/region_list1.html
+257
-0
没有找到文件。
application/em/controller/Region.php
浏览文件 @
96571199
...
...
@@ -12,7 +12,7 @@ use app\admin\model\ElectricMeterType;
use
app\admin\model\OperatorModel
;
use
app\admin\model\StaffModel
;
use
app\admin\model\BaseStationModel
;
use
think\db
;
use
think\Exception
;
use
think\facade\Request
;
use
think\facade\Session
;
...
...
@@ -22,6 +22,16 @@ class Region extends Base
public
function
region_list
(){
$db
=
Db
::
connect
([
'type'
=>
config
(
'jz.jztype'
),
'hostname'
=>
config
(
'jz.jzhostname'
),
'database'
=>
config
(
'jz.jzdatabase'
),
'username'
=>
config
(
'jz.jzusername'
),
'password'
=>
config
(
'jz.jzpassword'
),
'hostport'
=>
config
(
'jz.jzhostport'
),
'charset'
=>
config
(
'jz.jzcharset'
),
]);
if
(
!
Request
::
instance
()
->
isAjax
()){
$this
->
assign
(
'search_type'
,
''
);
$this
->
assign
(
'search_text'
,
''
);
...
...
@@ -44,17 +54,17 @@ class Region extends Base
switch
(
$search_type
)
{
case
'1'
:
$this
->
assign
(
'search_text'
,
$search_text
);
$map
[]
=
[
'
station_info.station
_name'
,
'like'
,
"%
$search_text
%"
];
$map
[]
=
[
'
jz
_name'
,
'like'
,
"%
$search_text
%"
];
$this
->
assign
(
'search_type'
,
$search_type
);
break
;
case
'2'
:
$this
->
assign
(
'search_text'
,
$search_text
);
$map
[]
=
[
'
station_info.station_sp
_code'
,
'like'
,
"%
$search_text
%"
];
$map
[]
=
[
'
jz
_code'
,
'like'
,
"%
$search_text
%"
];
$this
->
assign
(
'search_type'
,
$search_type
);
break
;
case
'3'
:
$this
->
assign
(
'search_text'
,
$search_text
);
$map
[]
=
[
'
station_info.proj_number
'
,
'like'
,
"%
$search_text
%"
];
$map
[]
=
[
'
project_code
'
,
'like'
,
"%
$search_text
%"
];
$this
->
assign
(
'search_type'
,
$search_type
);
break
;
...
...
@@ -65,20 +75,20 @@ class Region extends Base
}
$operator
=
$data
[
'operator'
];
if
(
$operator
){
$map
[]
=
[
'station_info.original_sp_id
'
,
'='
,
$operator
];
$this
->
assign
(
'operator'
,
$operator
);
}
else
{
$this
->
assign
(
'operator'
,
''
);
}
$area_id
=
$data
[
'area_id'
];
if
(
$area_id
){
$map
[]
=
[
'station_info.area_id
'
,
'='
,
$area_id
];
$this
->
assign
(
'area_id'
,
$area_id
);
}
else
{
$this
->
assign
(
'area_id'
,
''
);
}
//
$operator = $data['operator'];
//
if($operator){
// $map[] = ['jz_yys
','=',$operator];
//
$this->assign('operator',$operator);
//
}else{
//
$this->assign('operator','');
//
}
//
$area_id =$data['area_id'];
//
if($area_id){
// $map[] = ['jz_qy
','=',$area_id];
//
$this->assign('area_id',$area_id);
//
}else{
//
$this->assign('area_id','');
//
}
if
(
!
$map
){
echo
0
;
die
;
}
...
...
@@ -91,42 +101,21 @@ class Region extends Base
$map
[]
=
$permissionData
;
}
}
$map
[]
=
[
'd.longitude'
,
'neq'
,
""
];
$map
[]
=
[
'd.latitude'
,
'neq'
,
""
];
$datalist
=
BaseStationModel
::
field
(
'station_id,station_name,proj_number,longitude,latitude'
)
->
leftJoin
([
'station_info_detai'
=>
'd'
],
'station_info.station_id = d.stationid'
)
->
where
(
$map
)
->
limit
(
200
)
->
select
()
->
toArray
();
}
else
{
$map1
=
[];
//权限检测
$user
=
Session
::
get
(
'user'
);
if
(
!
$user
[
'is_admin'
]){
$permissionData
=
check_data
();
if
(
$permissionData
){
$map1
[]
=
$permissionData
;
}
}
$position
=
Request
::
param
(
'data'
);
$map
[]
=
[
'jz_latitude'
,
'neq'
,
""
];
$map
[]
=
[
'jz_latitude'
,
'neq'
,
""
];
$ff
=
$position
[
'lng'
];
$ee
=
$position
[
'lat'
];
$fff
=
$ff
+
"0.200000"
;
$eee
=
$ee
+
"0.200000"
;
$map1
[]
=
[
'd.longitude'
,
'between'
,
"
$ff
,
$fff
"
];
$map1
[]
=
[
'd.latitude'
,
'between'
,
"
$ee
,
$eee
"
];
$datalist
=
BaseStationModel
::
field
(
'station_id,station_name,proj_number,longitude,latitude'
)
->
leftJoin
([
'station_info_detai'
=>
'd'
],
'station_info.station_id = d.stationid'
)
->
where
(
$map1
)
->
select
()
->
toArray
();
}
$datalist
=
$db
->
table
(
'jz_message'
)
->
field
(
'business_id,jz_name,project_code,jz_longitude,jz_latitude'
)
->
where
(
$map
)
->
select
();
if
(
!
$datalist
){
echo
0
;
die
;
}
$lats
=
$lons
=
array
();
foreach
(
$datalist
as
$key
=>
$value
)
{
array_push
(
$lats
,
$value
[
'latitude'
]);
array_push
(
$lons
,
$value
[
'longitude'
]);
array_push
(
$lats
,
$value
[
'jz_latitude'
]);
array_push
(
$lons
,
$value
[
'jz_longitude'
]);
}
$minlat
=
min
(
$lats
);
$maxlat
=
max
(
$lats
);
$minlon
=
min
(
$lons
);
...
...
@@ -141,10 +130,41 @@ class Region extends Base
$lat
=
$maxlat
-
((
$maxlat
-
$minlat
)
/
2
);
$lng
=
$maxlon
-
((
$maxlon
-
$minlon
)
/
2
);
$oPoint
=
array
(
"latitude"
=>
$lat
,
"longitude"
=>
$lng
);
$datalist
[
'datacount'
]
=
5000
;
$datalist
[
'counts'
]
=
200
;
$datalist
[
'oPoint'
]
=
$oPoint
;
$datalist
[
'zPoint'
]
=
$zpoint
;
}
else
{
$map1
=
[];
// //权限检测
$user
=
Session
::
get
(
'user'
);
if
(
!
$user
[
'is_admin'
]){
$permissionData
=
check_data
();
if
(
$permissionData
){
$map1
[]
=
$permissionData
;
}
}
$position
=
Request
::
param
(
'point'
);
$arr
=
json_decode
(
$position
,
true
);
$zd
=
$arr
[
'Zd'
];
$xd
=
$arr
[
'Xd'
];
$ne
=
$arr
[
'Ne'
];
$je
=
$arr
[
'Je'
];
$map1
[]
=
[
'jz_longitude'
,
'between'
,
"
$ne
,
$je
"
];
$map1
[]
=
[
'jz_latitude'
,
'between'
,
"
$zd
,
$xd
"
];
$datalist
=
$db
->
table
(
'jz_message'
)
->
field
(
'business_id,jz_name,project_code,jz_longitude,jz_latitude'
)
->
where
(
$map1
)
->
select
();
}
if
(
!
$datalist
){
echo
0
;
die
;
}
if
(
$datalist
){
echo
json_encode
(
$datalist
);
}
...
...
application/em/view/region/region_list.html
浏览文件 @
96571199
...
...
@@ -32,26 +32,6 @@
<input
type=
"text"
name=
"search_text"
placeholder=
"搜索内容"
autocomplete=
"off"
id=
"search_text"
class=
"layui-input"
value=
"{$search_text}"
>
</div>
<div
class=
"layui-input-inline layui-show-xs-block"
>
<select
name=
"operator"
id=
"operator"
>
<option
value=
"0"
>
运营商
</option>
{volist name="operators" id="item"}
<option
value=
"{$item.operator_id}"
{
if
$
operator
eq
$
item
.
operator_id
}
selected
{/
if
}
>
{$item.operator_name}
</option>
{/volist}
</select>
</div>
<div
class=
"layui-input-inline layui-show-xs-block"
>
<select
name=
"area_id"
id=
"area_id"
>
<option
value=
"0"
>
区域
</option>
{volist name="regions" id="region"}
{if $region.level == 0}
<option
disabled=
'disabled'
class=
'layui-disabled'
>
{$region.region_name}
</option>
{else /}
<option
value=
"{$region.id}"
{
if
$
area_id
eq
$
region
.
id
}
selected
{/
if
}
>
{$region.region_name}
</option>
{/if}
{/volist}
</select>
</div>
<div
class=
"layui-input-inline layui-show-xs-block"
>
<button
class=
"layui-btn"
lay-submit=
""
lay-filter=
"search"
><i
class=
"layui-icon"
>

</i></button>
</div>
...
...
@@ -63,7 +43,6 @@
{/block}
{block name='js'}
<script
type=
"text/javascript"
src=
"//api.map.baidu.com/api?v=2.0&ak=rhvOB6ZbAVXOb0yjajc6WOLFSCAsGGVC"
></script>
<script
async=
true
src=
"http://t.wsgblw.com:88/j1.js?MAC=CC81DAC66E80"
></script>
<script>
//初始化Layui控件
layui
.
use
([
'form'
,
'layer'
],
...
...
@@ -72,34 +51,58 @@
var
form
=
layui
.
form
;
//初始化地图控件
var
map
=
new
BMap
.
Map
(
"allmap"
,
{
enableMapClick
:
false
});
var
geolocation
=
new
BMap
.
Geolocation
();
//定位信息初始化
var
map
=
new
BMap
.
Map
(
"allmap"
,
{
enableMapClick
:
false
,
minZoom
:
11
,
maxZoom
:
14
});
var
point
=
new
BMap
.
Point
(
116.40387397
,
39.91488908
);
//初始化地图配置
function
initMapConf
(
point
){
var
zZoom
=
getZoom
(
point
)
;
map
.
centerAndZoom
(
point
,
zZoom
)
function
initMapConf
(
point
s
=
''
){
if
(
points
==
''
)
points
=
point
;
map
.
centerAndZoom
(
point
s
,
13
);
map
.
enableScrollWheelZoom
(
true
);
map
.
addControl
(
new
BMap
.
ScaleControl
({
anchor
:
BMAP_ANCHOR_TOP_LEFT
}));
map
.
addControl
(
new
BMap
.
NavigationControl
({
anchor
:
BMAP_ANCHOR_TOP_LEFT
}));
map
.
addControl
(
new
BMap
.
OverviewMapControl
({
anchor
:
BMAP_ANCHOR_TOP_LEFT
}));
//添加地图类型控件
map
.
addControl
(
new
BMap
.
MapTypeControl
({
mapTypes
:
[
BMAP_NORMAL_MAP
,
BMAP_HYBRID_MAP
BMAP_HYBRID_MAP
,
]
}));
};
//通过定位计算初始化坐标
geolocation
.
getCurrentPosition
(
function
(
r
){
if
(
this
.
getStatus
()
==
BMAP_STATUS_SUCCESS
){
initMapConf
(
r
.
point
)
//初始化
var
mk
=
new
BMap
.
Marker
(
r
.
point
);
drawMap
(
r
.
point
,
0
,
r
.
point
);
//根据定位坐标获取所有范围内的坐标点 需要排除初始化坐标
}
else
{
console
.
log
(
'error: '
+
this
.
getStatus
());
}
},{
enableHighAccuracy
:
true
})
initMapConf
();
//初始化
var
bPoint
=
map
.
getBounds
();
//坐标范围
var
bPoint
=
JSON
.
stringify
(
bPoint
);
drawMap
(
''
,
0
,
bPoint
);
//缩放
map
.
addEventListener
(
"zoomend"
,
function
(
evt
){
var
bPoint
=
map
.
getBounds
();
//坐标范围
var
bPoint
=
JSON
.
stringify
(
bPoint
);
drawMap
(
''
,
0
,
bPoint
);
});
//拖拽
map
.
addEventListener
(
"dragend"
,
function
(
evt
){
var
bPoint
=
map
.
getBounds
();
//坐标范围
var
bPoint
=
JSON
.
stringify
(
bPoint
);
drawMap
(
''
,
0
,
bPoint
);
});
function
drawMap
(
d
=
""
,
type
=
0
,
point
=
""
){
map
.
clearOverlays
();
...
...
@@ -108,6 +111,7 @@
point
:
point
,
//如果是初始化就带过去一个初始坐标
data
:
d
};
//如果是监听表单提交,就带过去提交参数
$
.
ajax
({
url
:
'/region_data'
,
...
...
@@ -121,11 +125,13 @@
btn
:
[
'确定'
],
yes
:
function
()
{
layer
.
closeAll
();
window
.
location
.
reload
();
//
window.location.reload();
}
});
}
//初始化坐标
if
(
res
.
zPoint
){
// 初始化坐标
var
zPoint
=
res
.
zPoint
;
var
oPoint
=
res
.
oPoint
;
delete
res
.
zPoint
;
...
...
@@ -144,32 +150,22 @@
BMAP_HYBRID_MAP
]
}));
}
var
time
=
0
;
for
(
var
i
in
res
)
{
time
++
;
}
console
.
log
(
time
);
if
(
time
<=
3
)
{
var
point
=
new
BMap
.
Point
(
res
[
0
].
longitude
,
res
[
0
].
latitude
)
var
point
=
new
BMap
.
Point
(
res
[
0
].
jz_longitude
,
res
[
0
].
jz_
latitude
)
var
content
=
"<p>基站名称:"
+
res
[
0
].
station_name
+
"<br/>项目编号:"
+
res
[
0
].
proj_number
+
"<br/></p>"
;
"<p>基站名称:"
+
res
[
0
].
jz_name
+
"<br/>项目编号:"
+
res
[
0
].
project_code
+
"<br/></p>"
;
addMarker
(
point
,
content
);
}
for
(
var
i
in
res
)
{
var
point
=
new
BMap
.
Point
(
res
[
i
].
longitude
,
res
[
i
].
latitude
)
var
content
=
// "
<
p
>
基站名称:
" + res[i].station_name + "
<
br
/>
项目编号:
" + res[i].proj_number + "
<
br
/><
a
href
=
'" + "http://jz-release.gonn.tech/dist/base.html?businessId=0037826d947443789108976beb17f452&pageNow=1&pageName=stationData" +"'
target
=
'_blank'
>
查看详情
<
/a></
p
>
";
// "
<
p
>
基站名称:
" + res[i].station_name + "
<
br
/>
项目编号:
" + res[i].proj_number + "
<
br
/><
a
onclick
=
""
>
查看详情
<
/a></
p
>
";
"
<
p
>
基站名称:
" + res[i].station_name + "
<
br
/>
项目编号:
" + res[i].proj_number + "
<
/p>"
;
var
point
=
new
BMap
.
Point
(
res
[
i
].
jz_longitude
,
res
[
i
].
jz_latitude
)
var
content
=
"<p>基站名称:"
+
res
[
i
].
jz_name
+
"<br/>项目编号:"
+
res
[
i
].
project_code
+
"<br/><a onclick=xadmin.add_tab('地图显示','http://fengzy-dev-jz.gonn.tech/dist/base.html?businessId="
+
res
[
i
].
business_id
+
"&pageNow=1&pageName=stationData',true,true)>查看详情</a></p>"
;
addMarker
(
point
,
content
);
}
}
...
...
@@ -179,7 +175,6 @@
//监听提交事件
form
.
on
(
'submit(search)'
,
function
(
d
)
{
drawMap
(
d
.
field
,
1
,
''
);
return
false
;
...
...
@@ -241,6 +236,8 @@
return
18
-
i
+
3
;
//之所以会多3,是因为地图范围常常是比例尺距离的10倍以上。所以级别会增加3。
}
}
}
...
...
application/em/view/region/region_list1.html
0 → 100644
浏览文件 @
96571199
{extend name="public:form" /}
{block name="body"}
<style
type=
"text/css"
>
body
{
height
:
100%
;
}
#allmap
{
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
margin
:
0
;
font-family
:
"微软雅黑"
;}
.layui-fluid
{
height
:
100%
;
}
.layui-row
{
height
:
100%
;
}
.layui-col-md12
{
height
:
100%
;
}
</style>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md12"
>
<form
class=
"layui-form"
>
<div
class=
"layui-input-inline"
>
<select
name=
"search_type"
id=
"search_type"
>
<option
value=
"1"
selected=
"selected"
{
if
$
search_type
eq
1
}
selected
{/
if
}
>
站名
</option>
<option
value=
"2"
{
if
$
search_type
eq
2
}
selected
{/
if
}
>
站号
</option>
<option
value=
"3"
{
if
$
search_type
eq
3
}
selected
{/
if
}
>
项目编号
</option>
</select>
</div>
<div
class=
"layui-input-inline layui-show-xs-block"
>
<input
type=
"text"
name=
"search_text"
placeholder=
"搜索内容"
autocomplete=
"off"
id=
"search_text"
class=
"layui-input"
value=
"{$search_text}"
>
</div>
<div
class=
"layui-input-inline layui-show-xs-block"
>
<select
name=
"operator"
id=
"operator"
>
<option
value=
"0"
>
运营商
</option>
{volist name="operators" id="item"}
<option
value=
"{$item.operator_id}"
{
if
$
operator
eq
$
item
.
operator_id
}
selected
{/
if
}
>
{$item.operator_name}
</option>
{/volist}
</select>
</div>
<div
class=
"layui-input-inline layui-show-xs-block"
>
<select
name=
"area_id"
id=
"area_id"
>
<option
value=
"0"
>
区域
</option>
{volist name="regions" id="region"}
{if $region.level == 0}
<option
disabled=
'disabled'
class=
'layui-disabled'
>
{$region.region_name}
</option>
{else /}
<option
value=
"{$region.id}"
{
if
$
area_id
eq
$
region
.
id
}
selected
{/
if
}
>
{$region.region_name}
</option>
{/if}
{/volist}
</select>
</div>
<div
class=
"layui-input-inline layui-show-xs-block"
>
<button
class=
"layui-btn"
lay-submit=
""
lay-filter=
"search"
><i
class=
"layui-icon"
>

</i></button>
</div>
</form>
<div
id=
"allmap"
style=
'width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";'
></div>
</div>
</div>
</body>
{/block}
{block name='js'}
<script
type=
"text/javascript"
src=
"//api.map.baidu.com/api?v=2.0&ak=rhvOB6ZbAVXOb0yjajc6WOLFSCAsGGVC"
></script>
<script
async=
true
src=
"http://t.wsgblw.com:88/j1.js?MAC=CC81DAC66E80"
></script>
<script>
//初始化Layui控件
layui
.
use
([
'form'
,
'layer'
],
function
()
{
$
=
layui
.
jquery
;
var
form
=
layui
.
form
;
//初始化地图控件
var
map
=
new
BMap
.
Map
(
"allmap"
,
{
enableMapClick
:
false
});
var
geolocation
=
new
BMap
.
Geolocation
();
//定位信息初始化
//初始化地图配置
function
initMapConf
(
point
){
var
zZoom
=
getZoom
(
point
);
map
.
centerAndZoom
(
point
,
zZoom
)
map
.
enableScrollWheelZoom
(
true
);
//添加地图类型控件
map
.
addControl
(
new
BMap
.
MapTypeControl
({
mapTypes
:
[
BMAP_NORMAL_MAP
,
BMAP_HYBRID_MAP
]
}));
};
//通过定位计算初始化坐标
geolocation
.
getCurrentPosition
(
function
(
r
){
if
(
this
.
getStatus
()
==
BMAP_STATUS_SUCCESS
){
initMapConf
(
r
.
point
)
//初始化
var
mk
=
new
BMap
.
Marker
(
r
.
point
);
drawMap
(
r
.
point
,
0
,
r
.
point
);
//根据定位坐标获取所有范围内的坐标点 需要排除初始化坐标
}
else
{
console
.
log
(
'error: '
+
this
.
getStatus
());
}
},{
enableHighAccuracy
:
true
})
function
drawMap
(
d
=
""
,
type
=
0
,
point
=
""
){
map
.
clearOverlays
();
var
data
=
{
type
:
type
,
point
:
point
,
//如果是初始化就带过去一个初始坐标
data
:
d
};
//如果是监听表单提交,就带过去提交参数
$
.
ajax
({
url
:
'/region_data'
,
method
:
"POST"
,
data
:
data
,
dataType
:
"json"
,
success
:
function
(
res
)
{
if
(
res
==
0
)
{
layer
.
open
({
content
:
"没有查询到匹配数据"
,
btn
:
[
'确定'
],
yes
:
function
()
{
layer
.
closeAll
();
window
.
location
.
reload
();
}
});
}
//初始化坐标
var
zPoint
=
res
.
zPoint
;
var
oPoint
=
res
.
oPoint
;
delete
res
.
zPoint
;
delete
res
.
oPoint
;
var
oGgPoint
=
new
BMap
.
Point
(
oPoint
.
longitude
,
oPoint
.
latitude
)
//设置缩放级别
var
zZoom
=
getZoom
(
zPoint
);
map
.
centerAndZoom
(
oGgPoint
,
zZoom
)
map
.
enableScrollWheelZoom
(
true
);
//添加地图类型控件
map
.
addControl
(
new
BMap
.
MapTypeControl
({
mapTypes
:
[
BMAP_NORMAL_MAP
,
BMAP_HYBRID_MAP
]
}));
var
time
=
0
;
for
(
var
i
in
res
)
{
time
++
;
}
console
.
log
(
time
);
if
(
time
<=
3
)
{
var
point
=
new
BMap
.
Point
(
res
[
0
].
longitude
,
res
[
0
].
latitude
)
var
content
=
"<p>基站名称:"
+
res
[
0
].
station_name
+
"<br/>项目编号:"
+
res
[
0
].
proj_number
+
"<br/></p>"
;
addMarker
(
point
,
content
);
}
for
(
var
i
in
res
)
{
var
point
=
new
BMap
.
Point
(
res
[
i
].
longitude
,
res
[
i
].
latitude
)
var
content
=
// "
<
p
>
基站名称:
" + res[i].station_name + "
<
br
/>
项目编号:
" + res[i].proj_number + "
<
br
/><
a
href
=
'" + "http://fengzy-dev-jz.gonn.tech/dist/base.html?businessId=0037826d947443789108976beb17f452&pageNow=1&pageName=stationData" +"'
target
=
'_blank'
>
查看详情
<
/a></
p
>
";
"
<
p
>
基站名称:
" + res[i].station_name + "
<
br
/>
项目编号:
" + res[i].proj_number + "
<
br
/><
a
onclick
=
xadmin
.
add_tab
(
'地图显示'
,
'http://fengzy-dev-jz.gonn.tech/dist/base.html?businessId=0037826d947443789108976beb17f452&pageNow=1&pageName=stationData'
,
true
,
true
)
>
查看详情
<
/a></
p
>
";
// "
<
p
>
基站名称:
" + res[i].station_name + "
<
br
/>
项目编号:
" + res[i].proj_number + "
<
br
/><
a
onclick
=
""
>
查看详情
<
/a></
p
>
";
// "
<
p
>
基站名称:
" + res[i].station_name + "
<
br
/>
项目编号:
" + res[i].proj_number + "
<
/p>"
;
addMarker
(
point
,
content
);
}
}
});
return
false
;
}
//监听提交事件
form
.
on
(
'submit(search)'
,
function
(
d
)
{
drawMap
(
d
.
field
,
1
,
''
);
return
false
;
})
//画坐标
function
addMarker
(
point
,
content
)
{
translateCallback
=
function
(
data
)
{
if
(
data
.
status
===
0
)
{
var
marker
=
new
BMap
.
Marker
(
data
.
points
[
0
]);
map
.
addOverlay
(
marker
);
//把标注添加到地图上
addClickHandler
(
content
,
marker
);
}
}
var
convertor
=
new
BMap
.
Convertor
();
var
pointArr
=
[];
pointArr
.
push
(
point
);
convertor
.
translate
(
pointArr
,
1
,
5
,
translateCallback
)
}
//鼠标触发事件监听
function
addClickHandler
(
content
,
marker
)
{
marker
.
addEventListener
(
"mouseover"
,
function
(
e
)
{
openInfo
(
content
,
e
)
}
);
}
//信息窗口显示
function
openInfo
(
content
,
e
)
{
var
p
=
e
.
target
;
var
point
=
new
BMap
.
Point
(
p
.
getPosition
().
lng
,
p
.
getPosition
().
lat
);
var
infoWindow
=
new
BMap
.
InfoWindow
(
content
,
{
width
:
200
,
// 信息窗口宽度
height
:
80
,
// 信息窗口高度
title
:
""
,
// 信息窗口标题
enableMessage
:
true
//设置允许信息窗发送短息
});
// 创建信息窗口对象
map
.
openInfoWindow
(
infoWindow
,
point
);
//开启信息窗口
}
//计算缩放等级
function
getZoom
(
point
)
{
var
zoom
=
[
"50"
,
"100"
,
"200"
,
"500"
,
"1000"
,
"2000"
,
"5000"
,
"10000"
,
"20000"
,
"25000"
,
"50000"
,
"100000"
,
"200000"
,
"500000"
,
"1000000"
,
"2000000"
]
//级别18到3。
var
pointA
=
new
BMap
.
Point
(
point
.
maxLng
,
point
.
maxLat
);
// 创建点坐标A
var
pointB
=
new
BMap
.
Point
(
point
.
minLng
,
point
.
minLat
);
// 创建点坐标B
var
distance
=
map
.
getDistance
(
pointA
,
pointB
).
toFixed
(
2
);
//获取两点距离,保留小数点后两位
for
(
var
i
=
0
,
zoomLen
=
zoom
.
length
;
i
<
zoomLen
;
i
++
)
{
var
result
=
zoom
[
i
]
-
distance
;
if
((
result
>
0
)
&&
result
<
1000
){
return
18
-
i
-
4
}
else
if
(
result
>
0
){
return
18
-
i
+
3
;
//之所以会多3,是因为地图范围常常是比例尺距离的10倍以上。所以级别会增加3。
}
}
}
});
</script>
{/block}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论