xzqy.js
2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
layui.use('element', function () {
let element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
//监听导航点击
element.on('nav(demo)', function (elem) {
//console.log(elem)
layer.msg(elem.text());
});
});
//config的设置是全局的
layui.config({
base: './js/'
}).extend({ //设定模块别名
common: 'common'
});
layui.use(['form', 'common'], function () {
var common = layui.common,
form = layui.form;
//三级地址联动
common.showCity('province', 'city');
//区域选择
form.on('select(selectCity)', function (data) {
console.log(data)
return false;
});
//办事大厅
form.on('select(officehall)', function (data) {
let latitude= undefined
let longitude= undefined
let title= ''
if(data.value==1) {
latitude = 116.397469
longitude = 39.908821
title = '北京'
}else if(data.value==2){
latitude = 121.491119
longitude = 31.235172
title = '上海'
}else {
latitude = 120.21201
longitude = 30.2084
title = '杭州'
}
var point = new BMapGL.Point(latitude, longitude);
var infoWindow = new BMapGL.InfoWindow(title, opts);
map.openInfoWindow(infoWindow, point);
return false;
});
});
var geolocation = new BMap.Geolocation();
var gc = new BMap.Geocoder();
geolocation.getCurrentPosition(function (r) {
if (this.getStatus() == BMAP_STATUS_SUCCESS) {
var pt = r.point;
gc.getLocation(pt, function (rs) {
var addComp = rs.addressComponents;
var province = addComp.province;
var city = addComp.city;
$('.Pselected').attr('data-area', province)
$('.Cselected').attr('data-area', city)
layui.use(['form', 'common'], function () {
var common = layui.common,
form = layui.form;
//三级地址联动
common.showCity('province', 'city');
})
})
}
else {
alert("定位失败");
}
}, { enableHighAccuracy: true });
var map = new BMapGL.Map('container');
var point = new BMapGL.Point(108.95309828, 34.2777999);
map.centerAndZoom(point, 15);
var opts = {
width: 100,
height: 60,
title: '办事大厅'
};
var infoWindow = new BMapGL.InfoWindow('雁塔区南二环西段', opts);
map.openInfoWindow(infoWindow, point);