map.js
6.1 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/**
*
* @param data
* @param per_page
*/
function setList(data, per_page = 15)
{
let count = data.length;
let total_page = Math.ceil(count / per_page);
let ul = $("#ul-data");
$('.total').html(count)
let list = data.slice(0, per_page);
let html = createLi(list,1,count);
ul.html(html)
createPagination(total_page, count, per_page)
// $('.pagination').pagination({
// pageCount: total_page,
// totalData:count,
// showData:per_page,
// coping:true,
// // jump: true,
// callback: function (api) {
// search(api.getCurrent());
// }
// });
}
/**
* 查询
*
* @param page
* @param type
* @param per_page
* @param operate
*/
function search(page = 1, type = 'more', per_page = 15, operate)
{
if (operate === 'open') {
if ($('.total').text() > 0) {
return;
}
}
$("#ul-data").html('<li class="file-uploading" style="height: 50%;border: none"></li>');
if (type !== 'more') {
$(".pagination").html('');
}
let data = {
page: page,
per_page: per_page,
village:$("#village").val(),
group:$("#group").val(),
keyword:$("#keyword").val(),
};
$.getJSON(
'/admin/map/data-page',
data,
function (json) {
setListMore(json, type)
}
);
}
/**
* 查询
*
* @param res
* @param type
*/
function setListMore(res, type)
{
let code = res.code;
let data = res.data.data;
let per_page = res.data.per_page;
let current_page = res.data.current_page;
let total = res.data.total;
$('.total').html(total)
if (code === 0) {
if (type !== 'more') {
let last_page = res.data.last_page;
if (total > 0) {
if (current_page === 1) {
type = 'more';
}
createPagination(last_page, total, per_page, type)
}
}
let ul = $("#ul-data");
let html = createLi(data, current_page, total, type);
ul.html(html)
}
}
/**
* 创建 li
* @param data
* @param current_page
* @param total
* @param type
* @param per_page
* @returns {string}
*/
function createLi(data, current_page, total, type = 'more', per_page = 15)
{
let html = '';
if (total <= 0) {
html ='<li style="height: 50%;border: none;text-align: center;display: block">';
html += '<svg t="1562312016538" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"p-id="2076" width="128" height="128" style="fill: #e9e9e9;">';
html += '<path d="M512.8 198.5c12.2 0 22-9.8 22-22v-90c0-12.2-9.8-22-22-22s-22 9.8-22 22v90c0 12.2 9.9 22 22 22zM307 247.8c8.6 8.6 22.5 8.6 31.1 0 8.6-8.6 8.6-22.5 0-31.1L274.5 153c-8.6-8.6-22.5-8.6-31.1 0-8.6 8.6-8.6 22.5 0 31.1l63.6 63.7zM683.9 247.8c8.6 8.6 22.5 8.6 31.1 0l63.6-63.6c8.6-8.6 8.6-22.5 0-31.1-8.6-8.6-22.5-8.6-31.1 0l-63.6 63.6c-8.6 8.6-8.6 22.5 0 31.1zM927 679.9l-53.9-234.2c-2.8-9.9-4.9-20-6.9-30.1-3.7-18.2-19.9-31.9-39.2-31.9H197c-19.9 0-36.4 14.5-39.5 33.5-1 6.3-2.2 12.5-3.9 18.7L97 679.9v239.6c0 22.1 17.9 40 40 40h750c22.1 0 40-17.9 40-40V679.9z m-315-40c0 55.2-44.8 100-100 100s-100-44.8-100-100H149.6l42.5-193.3c2.4-8.5 3.8-16.7 4.8-22.9h630c2.2 11 4.5 21.8 7.6 32.7l39.8 183.5H612z"p-id="2077"></path> </svg>';
html +='</li>';
} else {
$(data).each(function (i,e) {
if (e.id ) {
let no = (i + 1) ;
if (type === 'more') {
no = (current_page - 1 ) * per_page;
no += (i + 1)
}
html += '<li class="li" data-id="'+e.id+'" onclick="panToPoint('+e.id+','+e.longitude+','+e.latitude+')"><div class="markL"><i class="iconfont dont"></i>';
html += '<span>' + no +'</span></div>';
html += '<div class="li-content"><div class="content-top"><h3>'+e.title+'</h3></div>';
html += '<div class="content-bottom">'+e.address+'</div>'
html += '<div class="content-bottom">经度:' + e.longitude + '</div>'
html += '<div class="content-bottom">纬度:' + e.latitude + '</div>'
html += '</div>';
html += '</div></li>';
}
})
}
return html;
}
/**
* 创建分页
*
* @param count
* @param total
* @param per_page
* @param type
*/
function createPagination(count, total, per_page, type)
{
$('.pagination').pagination({
pageCount: count,
totalData: total,
showData: per_page,
coping: true,
// jump: true,
callback: function (api) {
search(api.getCurrent(), type);
}
});
}
/**
*
* @param thisObj
*/
function toggleLeftCtr(thisObj)
{
if ($("#close-search-form").hasClass("expand")) {
$("#close-search-form").removeClass("expand");
$(thisObj).find("img").attr("src", "/assets/admin/img/map-close.png");
$("#search-container").show();
search(1, 'new', 15, 'open');
} else {
$("#close-search-form").addClass("expand");
$(thisObj).find("img").attr("src", "/assets/admin/img/map-right.png");
$("#search-container").hide();
}
// $(".ctr-box").toggle(100);
}
/**
* @param thisObj
*/
function toggleRightCtr(thisObj)
{
if ($("#close-ctr-box").hasClass("expand")) {
$("#close-ctr-box").removeClass("expand");
$(thisObj).find("img").attr("src", "/assets/admin/img/map-close.png");
$(".ctr-box").show();
} else {
$("#close-ctr-box").addClass("expand");
$(thisObj).find("img").attr("src", "/assets/admin/img/map-left.png");
$(".ctr-box").hide();
}
// $(".ctr-box").toggle(100);
}
function panToPoint(id,longitude,latitude)
{
if (longitude && latitude) {
setMarket(id);
const point = new BMap.Point(longitude,latitude);
// const marker = new BMap.Marker(point); // 创建标注
// map.addOverlay(marker); // 将标注添加到地图中
map.panTo(point); //转到该点位置
} else {
toastr.error("该楼栋还未设置经纬度!");
return false;
}
}