egovamap 0.18.2 → 0.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +16 -16
- package/egovamap/EGovaScene.js +196 -196
- package/egovamap/coordconvert/CoordConvConfig.js +5 -5
- package/egovamap/egovaBI.js +1098 -1079
- package/egovamap/egovagis.js +1300 -1300
- package/egovamap/egovaglobe.js +2203 -2203
- package/egovamap/egovamap.css +96 -96
- package/egovamap/egovamap.js +4345 -4345
- package/egovamap/egovamms.js +461 -461
- package/egovamap/globe.html +22 -22
- package/egovamap/globe.jsp +14 -14
- package/egovamap/map.html +26 -26
- package/egovamap/map.jsp +36 -36
- package/egovamap/mapUtils.js +467 -467
- package/egovamap/mapswich.css +159 -159
- package/egovamap/mapswich.js +152 -152
- package/egovamap/mms.jsp +57 -57
- package/index.js +2 -2
- package/map.html +60 -60
- package/package.json +24 -24
package/egovamap/egovaBI.js
CHANGED
|
@@ -1,1080 +1,1099 @@
|
|
|
1
|
-
var egovaBI = function(globeMap, gisMap, mapType){
|
|
2
|
-
|
|
3
|
-
function defaultValue(a, b) {
|
|
4
|
-
if (a !== undefined && a !== null) {
|
|
5
|
-
return a;
|
|
6
|
-
}
|
|
7
|
-
return b;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function getImgSize(url) {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
let img = new Image();
|
|
13
|
-
img.onload = function() {
|
|
14
|
-
resolve({ width: img.width, height: img.height });
|
|
15
|
-
img = null;
|
|
16
|
-
};
|
|
17
|
-
img.onerror = function() {
|
|
18
|
-
resolve({ width: 0, height: 0 });
|
|
19
|
-
img = null;
|
|
20
|
-
};
|
|
21
|
-
img.src = url;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function interpolateColor(startColor, endColor, count) {
|
|
26
|
-
if (count < 2) return [startColor, endColor];
|
|
27
|
-
|
|
28
|
-
var start = rgbToRgbArray(startColor);
|
|
29
|
-
var end = rgbToRgbArray(endColor);
|
|
30
|
-
var end0 = end[0];
|
|
31
|
-
var end1 = end[1];
|
|
32
|
-
var end2 = end[2];
|
|
33
|
-
var end3 = end[3];
|
|
34
|
-
var start0 = start[0];
|
|
35
|
-
var start1 = start[1];
|
|
36
|
-
var start2 = start[2];
|
|
37
|
-
var start3 = start[3];
|
|
38
|
-
|
|
39
|
-
var r = end0 - start0;
|
|
40
|
-
var g = end1 - start1;
|
|
41
|
-
var b = end2 - start2;
|
|
42
|
-
var opacity = end3 - start3;
|
|
43
|
-
var step = 1.0 / count;
|
|
44
|
-
var colors = [startColor];
|
|
45
|
-
var _count = count - 1;
|
|
46
|
-
for (var i = 1; i < _count; i++) {
|
|
47
|
-
var interval = step * i;
|
|
48
|
-
colors.push([
|
|
49
|
-
Math.round(start0 + interval * r),
|
|
50
|
-
Math.round(start1 + interval * g),
|
|
51
|
-
Math.round(start2 + interval * b),
|
|
52
|
-
(start3 + interval * opacity)
|
|
53
|
-
])
|
|
54
|
-
}
|
|
55
|
-
colors.push(endColor);
|
|
56
|
-
return colors;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function rgbToRgbArray(color) {
|
|
60
|
-
if (!color || typeof color !== 'string' || (typeof color == 'string'&&color.indexOf('rgb') == -1) ) return color;
|
|
61
|
-
|
|
62
|
-
var r, g, b, a;
|
|
63
|
-
var rgbaAttr = color.match(/[\d.]+/g);
|
|
64
|
-
if (rgbaAttr.length >= 3) {
|
|
65
|
-
r = parseInt(rgbaAttr[0]);
|
|
66
|
-
g = parseInt(rgbaAttr[1]);
|
|
67
|
-
b = parseInt(rgbaAttr[2]);
|
|
68
|
-
if (rgbaAttr.length > 3) a = parseFloat(rgbaAttr[3]);
|
|
69
|
-
else a = 1;
|
|
70
|
-
}
|
|
71
|
-
return [ r, g, b, a];
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// 查询idb是否存在表
|
|
75
|
-
function checkObjectStore (storeName) {
|
|
76
|
-
return new Promise((resolve, reject) => {
|
|
77
|
-
// 打开网格数据库
|
|
78
|
-
let idbRequest = window.indexedDB.open('regionDB');
|
|
79
|
-
idbRequest.onblocked = function(event) {
|
|
80
|
-
// 如果其他的一些页签加载了该数据库,在我们继续之前需要关闭它们
|
|
81
|
-
// alert("请关闭其他由该站点打开的页签!");
|
|
82
|
-
console.log("请关闭其他由该站点打开的页签!")
|
|
83
|
-
};
|
|
84
|
-
idbRequest.onerror = (event) => {
|
|
85
|
-
console.log('数据库打开报错(checkObjectStore)');
|
|
86
|
-
// resolve(undefined)
|
|
87
|
-
reject(event.target.error.message)
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
idbRequest.onsuccess = () => {
|
|
91
|
-
let db = idbRequest.result;
|
|
92
|
-
// console.log('数据库打开成功(hasObjectStore)')
|
|
93
|
-
resolve(db.objectStoreNames.contains(storeName))
|
|
94
|
-
db.close()
|
|
95
|
-
};
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function deal2DPoints(layerName, positions, options) {
|
|
100
|
-
let datalist = [];
|
|
101
|
-
let zoom = options.common.zoom;
|
|
102
|
-
let clear = options.common.clear;
|
|
103
|
-
let highLightType = -1;
|
|
104
|
-
let infoStyle = null;
|
|
105
|
-
let renderCanvas = null;
|
|
106
|
-
let tagName = layerName;
|
|
107
|
-
let clusterOption = null;
|
|
108
|
-
|
|
109
|
-
let hasHover = null;
|
|
110
|
-
let callback = null;
|
|
111
|
-
datalist = positions.map(function(p) {
|
|
112
|
-
if(options.textStyle.label) {
|
|
113
|
-
for (const key in p) {
|
|
114
|
-
if(key !== "id" && key !== "x" && key !== "y" && key !== "objectID"){
|
|
115
|
-
if(!p.label) p.label = [];
|
|
116
|
-
var labelItem = {};
|
|
117
|
-
labelItem[key] = p[key];
|
|
118
|
-
p.label.push(labelItem);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
p.minZoom = options.common.beginLevel;
|
|
123
|
-
p.maxZoom = options.common.endLevel;
|
|
124
|
-
p.symbolType = -1;
|
|
125
|
-
p.symbolUrl = options.textStyle.symbolUrl || "location.png";
|
|
126
|
-
p.scale = options.textStyle.scale;
|
|
127
|
-
p.angle = options.textStyle.angle;
|
|
128
|
-
//
|
|
129
|
-
if (options.textStyle.
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
* @
|
|
616
|
-
*
|
|
617
|
-
* @
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
* @
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1
|
+
var egovaBI = function(globeMap, gisMap, mapType){
|
|
2
|
+
|
|
3
|
+
function defaultValue(a, b) {
|
|
4
|
+
if (a !== undefined && a !== null) {
|
|
5
|
+
return a;
|
|
6
|
+
}
|
|
7
|
+
return b;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getImgSize(url) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
let img = new Image();
|
|
13
|
+
img.onload = function() {
|
|
14
|
+
resolve({ width: img.width, height: img.height });
|
|
15
|
+
img = null;
|
|
16
|
+
};
|
|
17
|
+
img.onerror = function() {
|
|
18
|
+
resolve({ width: 0, height: 0 });
|
|
19
|
+
img = null;
|
|
20
|
+
};
|
|
21
|
+
img.src = url;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function interpolateColor(startColor, endColor, count) {
|
|
26
|
+
if (count < 2) return [startColor, endColor];
|
|
27
|
+
|
|
28
|
+
var start = rgbToRgbArray(startColor);
|
|
29
|
+
var end = rgbToRgbArray(endColor);
|
|
30
|
+
var end0 = end[0];
|
|
31
|
+
var end1 = end[1];
|
|
32
|
+
var end2 = end[2];
|
|
33
|
+
var end3 = end[3];
|
|
34
|
+
var start0 = start[0];
|
|
35
|
+
var start1 = start[1];
|
|
36
|
+
var start2 = start[2];
|
|
37
|
+
var start3 = start[3];
|
|
38
|
+
|
|
39
|
+
var r = end0 - start0;
|
|
40
|
+
var g = end1 - start1;
|
|
41
|
+
var b = end2 - start2;
|
|
42
|
+
var opacity = end3 - start3;
|
|
43
|
+
var step = 1.0 / count;
|
|
44
|
+
var colors = [startColor];
|
|
45
|
+
var _count = count - 1;
|
|
46
|
+
for (var i = 1; i < _count; i++) {
|
|
47
|
+
var interval = step * i;
|
|
48
|
+
colors.push([
|
|
49
|
+
Math.round(start0 + interval * r),
|
|
50
|
+
Math.round(start1 + interval * g),
|
|
51
|
+
Math.round(start2 + interval * b),
|
|
52
|
+
(start3 + interval * opacity)
|
|
53
|
+
])
|
|
54
|
+
}
|
|
55
|
+
colors.push(endColor);
|
|
56
|
+
return colors;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function rgbToRgbArray(color) {
|
|
60
|
+
if (!color || typeof color !== 'string' || (typeof color == 'string'&&color.indexOf('rgb') == -1) ) return color;
|
|
61
|
+
|
|
62
|
+
var r, g, b, a;
|
|
63
|
+
var rgbaAttr = color.match(/[\d.]+/g);
|
|
64
|
+
if (rgbaAttr.length >= 3) {
|
|
65
|
+
r = parseInt(rgbaAttr[0]);
|
|
66
|
+
g = parseInt(rgbaAttr[1]);
|
|
67
|
+
b = parseInt(rgbaAttr[2]);
|
|
68
|
+
if (rgbaAttr.length > 3) a = parseFloat(rgbaAttr[3]);
|
|
69
|
+
else a = 1;
|
|
70
|
+
}
|
|
71
|
+
return [ r, g, b, a];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// 查询idb是否存在表
|
|
75
|
+
function checkObjectStore (storeName) {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
// 打开网格数据库
|
|
78
|
+
let idbRequest = window.indexedDB.open('regionDB');
|
|
79
|
+
idbRequest.onblocked = function(event) {
|
|
80
|
+
// 如果其他的一些页签加载了该数据库,在我们继续之前需要关闭它们
|
|
81
|
+
// alert("请关闭其他由该站点打开的页签!");
|
|
82
|
+
console.log("请关闭其他由该站点打开的页签!")
|
|
83
|
+
};
|
|
84
|
+
idbRequest.onerror = (event) => {
|
|
85
|
+
console.log('数据库打开报错(checkObjectStore)');
|
|
86
|
+
// resolve(undefined)
|
|
87
|
+
reject(event.target.error.message)
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
idbRequest.onsuccess = () => {
|
|
91
|
+
let db = idbRequest.result;
|
|
92
|
+
// console.log('数据库打开成功(hasObjectStore)')
|
|
93
|
+
resolve(db.objectStoreNames.contains(storeName))
|
|
94
|
+
db.close()
|
|
95
|
+
};
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function deal2DPoints(layerName, positions, options) {
|
|
100
|
+
let datalist = [];
|
|
101
|
+
let zoom = options.common.zoom;
|
|
102
|
+
let clear = options.common.clear;
|
|
103
|
+
let highLightType = -1;
|
|
104
|
+
let infoStyle = null;
|
|
105
|
+
let renderCanvas = null;
|
|
106
|
+
let tagName = layerName;
|
|
107
|
+
let clusterOption = null;
|
|
108
|
+
|
|
109
|
+
let hasHover = null;
|
|
110
|
+
let callback = null;
|
|
111
|
+
datalist = positions.map(function(p) {
|
|
112
|
+
if(options.textStyle.label) {
|
|
113
|
+
for (const key in p) {
|
|
114
|
+
if(key !== "id" && key !== "x" && key !== "y" && key !== "objectID"){
|
|
115
|
+
if(!p.label) p.label = [];
|
|
116
|
+
var labelItem = {};
|
|
117
|
+
labelItem[key] = p[key];
|
|
118
|
+
p.label.push(labelItem);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
p.minZoom = options.common.beginLevel;
|
|
123
|
+
p.maxZoom = options.common.endLevel;
|
|
124
|
+
p.symbolType = -1;
|
|
125
|
+
p.symbolUrl = options.textStyle.symbolUrl || "location.png";
|
|
126
|
+
p.scale = options.textStyle.scale;
|
|
127
|
+
p.angle = options.textStyle.angle;
|
|
128
|
+
//classify symbol
|
|
129
|
+
if (options.textStyle.enableClassify) {
|
|
130
|
+
const customScheme = options.textStyle.customScheme;
|
|
131
|
+
const classField = options.textStyle.classField;
|
|
132
|
+
if (p[classField] && Object.prototype.toString.call(customScheme)=="[object Array]" && customScheme.length) {
|
|
133
|
+
customScheme.forEach(scheme => {
|
|
134
|
+
if (scheme.type == p[classField]) {
|
|
135
|
+
scheme.imageUrl && (p.symbolUrl = scheme.imageUrl);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//textValue
|
|
141
|
+
if (options.textStyle.enableText) {
|
|
142
|
+
p.labelStyle = {
|
|
143
|
+
type: "text",
|
|
144
|
+
xoffset: options.textStyle.xoffset + "px",
|
|
145
|
+
yoffset: options.textStyle.yoffset + "px",
|
|
146
|
+
text: p.textValue,
|
|
147
|
+
color: options.textStyle.fillColor,
|
|
148
|
+
font: {
|
|
149
|
+
size: options.textStyle.fontSize + "px",
|
|
150
|
+
weight: options.textStyle.fontWeight,
|
|
151
|
+
family: options.textStyle.family || "microsoft-yahei"
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
p.useLabelBg = options.textStyle.textBackground;
|
|
156
|
+
if (p.useLabelBg) {
|
|
157
|
+
p.labelBgStyle = {
|
|
158
|
+
type: "picture-marker",
|
|
159
|
+
url: options.textStyle.textBackgroundUrl
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return p;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return new Promise((resolve, reject) => {
|
|
166
|
+
try {
|
|
167
|
+
let args = {
|
|
168
|
+
datalist: datalist,
|
|
169
|
+
zoom: zoom,
|
|
170
|
+
clear: clear,
|
|
171
|
+
highLightType: highLightType,
|
|
172
|
+
infoStyle: infoStyle,
|
|
173
|
+
renderCanvas: renderCanvas,
|
|
174
|
+
tagName: tagName,
|
|
175
|
+
clusterOption: null,
|
|
176
|
+
hasHover: hasHover,
|
|
177
|
+
callback: callback
|
|
178
|
+
};
|
|
179
|
+
if (options.clusterStyle.clusterEnabled) {
|
|
180
|
+
clusterOption = {
|
|
181
|
+
clusterType: options.clusterStyle.clusterType,
|
|
182
|
+
distance: options.clusterStyle.clusterDistance,
|
|
183
|
+
style: null,
|
|
184
|
+
labelStyle: {
|
|
185
|
+
type: "text",
|
|
186
|
+
color: options.clusterStyle.fillColor,
|
|
187
|
+
text: "",
|
|
188
|
+
xoffset: options.clusterStyle.xoffset + "px",
|
|
189
|
+
yoffset: options.clusterStyle.yoffset + "px",
|
|
190
|
+
font: {
|
|
191
|
+
size: options.clusterStyle.fontSize + "px",
|
|
192
|
+
weight: options.clusterStyle.fontWeight || "normal",
|
|
193
|
+
family: options.clusterStyle.family || "microsoft-yahei"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
let useCustomClusterStyle = options.clusterStyle.symbolUrl && options.clusterStyle.useCustomStyle;
|
|
199
|
+
let clusterStyle = {
|
|
200
|
+
type: "simple-marker",
|
|
201
|
+
style: "circle",
|
|
202
|
+
color: [255, 168, 0, 200],
|
|
203
|
+
size: 25 * options.clusterStyle.scale + "px",
|
|
204
|
+
outline: {
|
|
205
|
+
color: [255, 168, 0, 200],
|
|
206
|
+
width: 2
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
clusterOption.style = clusterStyle;
|
|
210
|
+
if (useCustomClusterStyle) {
|
|
211
|
+
getImgSize(options.clusterStyle.symbolUrl).then(szie => {
|
|
212
|
+
clusterStyle = {
|
|
213
|
+
type: "picture-marker",
|
|
214
|
+
url: options.clusterStyle.symbolUrl,
|
|
215
|
+
width: szie.width * options.clusterStyle.scale + "px",
|
|
216
|
+
height: szie.height * options.clusterStyle.scale + "px"
|
|
217
|
+
};
|
|
218
|
+
clusterOption.style = clusterStyle;
|
|
219
|
+
args.clusterOption = clusterOption;
|
|
220
|
+
resolve(args);
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
args.clusterOption = clusterOption;
|
|
224
|
+
resolve(args);
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
resolve(args);
|
|
228
|
+
}
|
|
229
|
+
} catch (err) {
|
|
230
|
+
reject(err);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/*
|
|
236
|
+
* @description:新参数格式的旧热力接口,主要用来做中间层参数格式转换
|
|
237
|
+
* @method showHeatImage3D_BI
|
|
238
|
+
* @param {String} layerName 热力参数数组
|
|
239
|
+
* @param {Array} data 热力值和坐标的数据数组
|
|
240
|
+
* @param {Object} options 配置项
|
|
241
|
+
* @param {Object} options.heatOpt 热力配置项
|
|
242
|
+
* @param {Object} options.commonOpt 通用配置项
|
|
243
|
+
*
|
|
244
|
+
* @return {Void}} 无返回
|
|
245
|
+
*
|
|
246
|
+
* @author: Hetianhong
|
|
247
|
+
* @date: 2021-08-31 14:13:42
|
|
248
|
+
*/
|
|
249
|
+
this.showHeatImage3D_BI = function (layerName, data, option) {
|
|
250
|
+
//data必须包含x y 和 value属性
|
|
251
|
+
if(
|
|
252
|
+
data.length === 0 ||
|
|
253
|
+
!data[0].hasOwnProperty('x') ||
|
|
254
|
+
!data[0].hasOwnProperty('y') ||
|
|
255
|
+
!data[0].hasOwnProperty('value')
|
|
256
|
+
) {
|
|
257
|
+
return
|
|
258
|
+
}
|
|
259
|
+
if (globeMap != null) {
|
|
260
|
+
//hth 此处进行参数转换
|
|
261
|
+
let commonOpt = option.commonOpt; // 通用配置项
|
|
262
|
+
let heatOpt = option.heatOpt; // 热力配置项
|
|
263
|
+
|
|
264
|
+
let info = {};
|
|
265
|
+
let zoom = defaultValue(commonOpt.zoom, false);
|
|
266
|
+
let clear = defaultValue(commonOpt.clear, true);
|
|
267
|
+
let options = {
|
|
268
|
+
heading: defaultValue(commonOpt.heading, 0),
|
|
269
|
+
pitch: defaultValue(commonOpt.pitch, -45),
|
|
270
|
+
range: defaultValue(commonOpt.range, 8000),
|
|
271
|
+
maxDataLength : defaultValue(commonOpt.maxDataLength, 5),
|
|
272
|
+
layerName: layerName
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// 开始组装info
|
|
276
|
+
//组装info.data,其实也没啥组装的
|
|
277
|
+
info.data = data
|
|
278
|
+
|
|
279
|
+
//组装info.options
|
|
280
|
+
info.options = {
|
|
281
|
+
clampStyle: (heatOpt.heatType === 0) ? 0 : 3, // 如果设置了为0,则为0,其余则全部为旧逻辑的3绘制方式,即贴地贴建筑
|
|
282
|
+
renderType: defaultValue(heatOpt.renderType, "line"),
|
|
283
|
+
dynamicGranularity: defaultValue(heatOpt.dynamicGranularity, false),
|
|
284
|
+
granularity: defaultValue(heatOpt.granularity, 500),
|
|
285
|
+
maxHeight: defaultValue(heatOpt.maxHeight, -1),
|
|
286
|
+
height: defaultValue(heatOpt.height, 10),
|
|
287
|
+
radiusScale: defaultValue(heatOpt.radiusScale, 1.0),
|
|
288
|
+
radius: defaultValue(heatOpt.radius, 40),
|
|
289
|
+
gradient: defaultValue(heatOpt.gradient, {
|
|
290
|
+
0.35: "rgb(136,218,104)",
|
|
291
|
+
0.7: "rgb(241,238,124)",
|
|
292
|
+
1.0: "rgb(243,118,116)"
|
|
293
|
+
}),
|
|
294
|
+
|
|
295
|
+
// 下面的部分不建议传,逐步舍弃
|
|
296
|
+
gridSize: defaultValue(heatOpt.gridSize, null),
|
|
297
|
+
blur: defaultValue(heatOpt.blur, 0.85),
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// 转换过后,使用旧的参数格式调用原热力接口
|
|
301
|
+
globeMap.showHeatImage3D(info, zoom, clear, options);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/*
|
|
306
|
+
* @description:打点和聚类接口进行整合后的新接口
|
|
307
|
+
* @method drawPoint
|
|
308
|
+
* @param {String} layerName 图层名
|
|
309
|
+
* @param {Array} positions 位置数组
|
|
310
|
+
* @param {Object} options 配置项
|
|
311
|
+
*
|
|
312
|
+
* @return {Void} 无返回
|
|
313
|
+
*
|
|
314
|
+
* @author: Hetianhong
|
|
315
|
+
* @date: 2021-09-09 14:49:49
|
|
316
|
+
*/
|
|
317
|
+
this.drawPoints = function (layerName, positions, options) {
|
|
318
|
+
let drawData = function (layerName, positions, options) {
|
|
319
|
+
if (globeMap && mapType == "globe") {
|
|
320
|
+
globeMap.drawPoints(layerName, positions, options);
|
|
321
|
+
}else if(gisMap && mapType == "map"){
|
|
322
|
+
deal2DPoints(layerName, positions, options).then(args => {
|
|
323
|
+
gisMap.showMultiObjectCurrentPosition(
|
|
324
|
+
args.datalist,
|
|
325
|
+
args.zoom,
|
|
326
|
+
args.clear,
|
|
327
|
+
args.highLightType,
|
|
328
|
+
args.infoStyle,
|
|
329
|
+
args.renderCanvas,
|
|
330
|
+
args.tagName,
|
|
331
|
+
options.clickCallback,
|
|
332
|
+
options.mouseOverCallback,
|
|
333
|
+
args.clusterOption,
|
|
334
|
+
args.hasHover,
|
|
335
|
+
layerName,
|
|
336
|
+
options.mouseOutCallback,
|
|
337
|
+
options.option
|
|
338
|
+
);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
if (!options.usageID) {
|
|
345
|
+
drawData(layerName, positions, options);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
let queryFeature = (queryParams) => {
|
|
349
|
+
return new Promise(function(resolve) {
|
|
350
|
+
let cb = function(result) {
|
|
351
|
+
resolve(result)
|
|
352
|
+
}
|
|
353
|
+
if(gisMap) {
|
|
354
|
+
gisMap.queryFeature(queryParams, cb);
|
|
355
|
+
}else{
|
|
356
|
+
return Promise.resolve(undefined)
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
}
|
|
361
|
+
let queryParams = {
|
|
362
|
+
layerID: options.usageID,
|
|
363
|
+
outGeometry: true,
|
|
364
|
+
}
|
|
365
|
+
queryFeature(queryParams)
|
|
366
|
+
.then(function(resultData) {
|
|
367
|
+
if(!resultData) {
|
|
368
|
+
console.log('没有查询到数据,请检查查询参数')
|
|
369
|
+
return
|
|
370
|
+
}
|
|
371
|
+
let dataCache=[];
|
|
372
|
+
let errorSize=0;
|
|
373
|
+
resultData.forEach(element => {
|
|
374
|
+
let x,y;
|
|
375
|
+
if(element.geometry){
|
|
376
|
+
x=element.geometry.x;
|
|
377
|
+
y=element.geometry.y;
|
|
378
|
+
}
|
|
379
|
+
if(x&&y){
|
|
380
|
+
let item={...element.attributes,x,y};
|
|
381
|
+
dataCache.push(item);
|
|
382
|
+
}else{
|
|
383
|
+
errorSize++;
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
if(errorSize>0){
|
|
387
|
+
console.error(`${errorSize}个点格式错误,无法正常加载`);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
drawData(layerName, dataCache, options);
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
}
|
|
394
|
+
this.getLabel = function (attributes) {
|
|
395
|
+
if (!attributes) return;
|
|
396
|
+
var label = [], field = {};
|
|
397
|
+
for (var key in attributes) {
|
|
398
|
+
field = {};
|
|
399
|
+
field[key] = attributes[key];
|
|
400
|
+
label.push(field);
|
|
401
|
+
}
|
|
402
|
+
return label;
|
|
403
|
+
};
|
|
404
|
+
this.drawParts = function (options, data, callback) {
|
|
405
|
+
var self = this;
|
|
406
|
+
function showParts(data) {
|
|
407
|
+
var drawParam = options.drawParam || {};
|
|
408
|
+
var ctrOption = drawParam.clusterOption;
|
|
409
|
+
var clusterOption = {
|
|
410
|
+
clusterType: ctrOption.clusterType,
|
|
411
|
+
level: ctrOption.level || 0,
|
|
412
|
+
style: {
|
|
413
|
+
"type": "simple-marker",
|
|
414
|
+
"style": "circle",
|
|
415
|
+
"color": ctrOption.color || [255, 0, 0, 0.6],
|
|
416
|
+
"size": ctrOption.size || 20,
|
|
417
|
+
"outline": { //if outline has been specified
|
|
418
|
+
"color": ctrOption.outlineColor || [255, 168, 0, 1],
|
|
419
|
+
"width": ctrOption.outlineWidth || 2
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
labelStyle: {
|
|
423
|
+
"type": "text",
|
|
424
|
+
"color": ctrOption.labelColor || [255, 255, 255, 1],
|
|
425
|
+
"text": "",
|
|
426
|
+
"zlevel": ctrOption.labelZlevel || 1,
|
|
427
|
+
"yoffset": 0,
|
|
428
|
+
"font": ctrOption.labelFont || {
|
|
429
|
+
"family": "Arial",
|
|
430
|
+
"size": 10
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
distance: ctrOption.distance || 50
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
var param = [data, true, false, null, null, false, drawParam.tagName, drawParam.clickCallback, drawParam.mouseOverCallback, clusterOption, false, drawParam.layerName, drawParam.callback, drawParam.drawOptions];
|
|
437
|
+
//三维聚类参数
|
|
438
|
+
var globeOptions = {
|
|
439
|
+
zoom:true,
|
|
440
|
+
scale: 0.9,
|
|
441
|
+
clear :true,
|
|
442
|
+
nearFarScalar:[8000, 1.0, 10000, 0.6],
|
|
443
|
+
clickCallBack: drawParam.clickCallback,
|
|
444
|
+
layerName: drawParam.layerName,
|
|
445
|
+
minSize:30,
|
|
446
|
+
clusterLimit: 20,
|
|
447
|
+
style:"default",
|
|
448
|
+
clusterImageInfo: {
|
|
449
|
+
horizontalOrigin: "center",
|
|
450
|
+
verticalOrigin: "bottom",
|
|
451
|
+
cssStyle: {
|
|
452
|
+
"borderRadius": 500,
|
|
453
|
+
"fillColor": "rgba(0,0,0,0.7)",
|
|
454
|
+
"borderLineWidth": 3,
|
|
455
|
+
"borderLineColor": "rgba(250,140,0,0.9)",
|
|
456
|
+
"paddingX": 15,
|
|
457
|
+
"paddingY": 6,
|
|
458
|
+
"marginBottom": 2
|
|
459
|
+
},
|
|
460
|
+
textStyle: {
|
|
461
|
+
"font": "60px Helvetica",
|
|
462
|
+
"fillColor": "rgba(220,220,220,1.0)",
|
|
463
|
+
"outlineColor": "black",
|
|
464
|
+
"outlineWidth": 1,
|
|
465
|
+
"padding": 1,
|
|
466
|
+
"textScale": 0.5,
|
|
467
|
+
"textStartX": 40,
|
|
468
|
+
"textStartY": 15
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (globeMap) {
|
|
473
|
+
globeMap.addClusterLayer({
|
|
474
|
+
data,
|
|
475
|
+
options:globeOptions
|
|
476
|
+
})
|
|
477
|
+
} else if (gisMap) {
|
|
478
|
+
gisMap.showMultiObjectCurrentPosition(...param );
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (data) {
|
|
483
|
+
showParts(data);
|
|
484
|
+
} else {
|
|
485
|
+
let queryFromGIS = () => {
|
|
486
|
+
let queryParam = options.queryParam;
|
|
487
|
+
var subTypeName = options.subTypeName;
|
|
488
|
+
var subUniqueCode = options.subUniqueCode;
|
|
489
|
+
let queryCallback = function (featureInfos) {
|
|
490
|
+
var features = featureInfos[queryParam.phyLayerIDs];
|
|
491
|
+
if (features.length == 0) {
|
|
492
|
+
callback && callback([]);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
if (!features || !features.length) return;
|
|
496
|
+
var symbolUrl = "";
|
|
497
|
+
if (subUniqueCode.indexOf("http") > -1) {
|
|
498
|
+
symbolUrl = subUniqueCode;
|
|
499
|
+
} else if (subUniqueCode.indexOf(".") > -1) {
|
|
500
|
+
symbolUrl = subUniqueCode;
|
|
501
|
+
} else {
|
|
502
|
+
symbolUrl = "".concat(subUniqueCode, ".png");
|
|
503
|
+
if(globeMap) symbolUrl = queryParam.gisServerURL ? `${queryParam.gisServerURL}/symbol/${symbolUrl}` : symbolUrl;
|
|
504
|
+
}
|
|
505
|
+
var dataList = features.map((function (feature) {
|
|
506
|
+
return Object.assign({}, { x: feature.geometry.x, y: feature.geometry.y }, {
|
|
507
|
+
attributes: feature.attributes,
|
|
508
|
+
// label:self.getLabel(feature.attributes), //去除内部弹框的可能性
|
|
509
|
+
symbolType: -1,
|
|
510
|
+
symbolUrl: symbolUrl,
|
|
511
|
+
scale: 0.5
|
|
512
|
+
});
|
|
513
|
+
}));
|
|
514
|
+
callback && callback(dataList);
|
|
515
|
+
showParts(dataList);
|
|
516
|
+
};
|
|
517
|
+
if (gisMap) {
|
|
518
|
+
gisMap.queryPhylayerFeatures(queryParam, queryCallback);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
queryFromGIS();
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
this.drawOtherParts = function (options, data) {
|
|
526
|
+
var self = this;
|
|
527
|
+
const geomType = options.geomType;
|
|
528
|
+
let queryParam = options.queryParam || {};
|
|
529
|
+
function showParts(data) {
|
|
530
|
+
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (data) {
|
|
534
|
+
showParts(data);
|
|
535
|
+
} else {
|
|
536
|
+
const layerID = queryParam.phyLayerIDs;
|
|
537
|
+
const layerName = queryParam.layerName;
|
|
538
|
+
const keyField = null;
|
|
539
|
+
const keyValue = null;
|
|
540
|
+
const clearMap = queryParam.clearMap || true;
|
|
541
|
+
let inStyle = queryParam.style || {
|
|
542
|
+
color: "blue"
|
|
543
|
+
};
|
|
544
|
+
let inHStyle = queryParam.hStyle || {
|
|
545
|
+
color: "blue"
|
|
546
|
+
};
|
|
547
|
+
let style = null, hStyle = null;
|
|
548
|
+
if (geomType == 1) {
|
|
549
|
+
} else if (geomType == 2) {
|
|
550
|
+
style = {
|
|
551
|
+
type: "simple-line", // autocasts as new SimpleLineSymbol()
|
|
552
|
+
color: inStyle.color || "blue",
|
|
553
|
+
width: inStyle.width || "2px",
|
|
554
|
+
style: inStyle.style || "solid",
|
|
555
|
+
cap: inStyle.cap || "round",
|
|
556
|
+
join: inStyle.join || "round",
|
|
557
|
+
};
|
|
558
|
+
hStyle = {
|
|
559
|
+
type: "simple-line", // autocasts as new SimpleLineSymbol()
|
|
560
|
+
color: inHStyle.color || "red",
|
|
561
|
+
width: inHStyle.width || inStyle.width || "2px",
|
|
562
|
+
style: inHStyle.style || inStyle.style || "solid",
|
|
563
|
+
cap: inHStyle.cap || inStyle.cap || "round",
|
|
564
|
+
join: inHStyle.join || inStyle.join || "round",
|
|
565
|
+
};
|
|
566
|
+
} else if (geomType == 3) {
|
|
567
|
+
style = {
|
|
568
|
+
type: "simple-fill", // autocasts as new SimpleFillSymbol()
|
|
569
|
+
color: inStyle.color || [51, 51, 204, 0.9],
|
|
570
|
+
style: inStyle.style || "solid",
|
|
571
|
+
outline: { // autocasts as new SimpleLineSymbol()
|
|
572
|
+
color: inStyle.outlineColor || "blue",
|
|
573
|
+
width: inStyle.outlineWidth || "1px",
|
|
574
|
+
style: inStyle.outlineStyle || "solid",
|
|
575
|
+
cap: inStyle.outlineCap || "round",
|
|
576
|
+
join: inStyle.outlineJoin || "round",
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
hStyle = {
|
|
580
|
+
type: "simple-fill", // autocasts as new SimpleFillSymbol()
|
|
581
|
+
color: inHStyle.color || [51, 51, 204, 0.9],
|
|
582
|
+
style: inHStyle.style || inStyle.style || "solid",
|
|
583
|
+
outline: { // autocasts as new SimpleLineSymbol()
|
|
584
|
+
color: inHStyle.outlineColor || "red",
|
|
585
|
+
width: inHStyle.outlineWidth || inStyle.outlineWidth || "1px",
|
|
586
|
+
style: inHStyle.outlineStyle || inStyle.outlineStyle || "solid",
|
|
587
|
+
cap: inHStyle.outlineCap || inStyle.outlineCap || "round",
|
|
588
|
+
join: inHStyle.outlineJoin || inStyle.outlineJoin || "round",
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
const bZoom = queryParam.bZoom || true;
|
|
593
|
+
const randomColor = null;
|
|
594
|
+
const labelField = null;
|
|
595
|
+
const labelstyle = null;
|
|
596
|
+
const geometry = null;
|
|
597
|
+
const where = queryParam.where || "1=1";
|
|
598
|
+
const opts = {
|
|
599
|
+
layerId: layerName,
|
|
600
|
+
mouseOverCallback: queryParam.mouseOverCallback
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
let param = [layerID, keyField, keyValue, clearMap, style, hStyle, bZoom, randomColor, labelField, labelstyle, geometry, where, null, null, opts, null, null, null, null, null, null, queryParam.clickCallback];
|
|
604
|
+
//let param = [layerID, keyField, keyValue, clearMap, style, hStyle, bZoom, randomColor, labelField, labelstyle, geometry, where, null, null, opts, null, null, null, null, queryParam.callback];
|
|
605
|
+
if (globeMap) {
|
|
606
|
+
gisMap.locateFeatureByIDs(...param);
|
|
607
|
+
} else if (gisMap) {
|
|
608
|
+
gisMap.locateFeatureByIDs(...param);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
/*
|
|
615
|
+
* @description:新的轨迹线接口
|
|
616
|
+
* @method traceOperation
|
|
617
|
+
* @param {Array} posArr 位置数组
|
|
618
|
+
* @param {Object} options 配置项
|
|
619
|
+
*
|
|
620
|
+
* @return {Void} 无返回
|
|
621
|
+
*
|
|
622
|
+
* @author: Hetianhong
|
|
623
|
+
* @date: 2021-09-09 14:49:49
|
|
624
|
+
*/
|
|
625
|
+
this.traceOperation = function (posArr, options) {
|
|
626
|
+
globeMap.traceOperation(posArr, options);
|
|
627
|
+
}
|
|
628
|
+
/*
|
|
629
|
+
* @description:网格接口
|
|
630
|
+
* 先查询idb的data,没有的话,再查询queryFeature的data
|
|
631
|
+
* @method regionOperation
|
|
632
|
+
* @param {Object} options 配置项
|
|
633
|
+
* @param {Array} data 数据,可不传
|
|
634
|
+
*
|
|
635
|
+
* @return {Void} 无返回
|
|
636
|
+
*
|
|
637
|
+
* @author: Hetianhong
|
|
638
|
+
* @date: 2021-10-19 17:27:02
|
|
639
|
+
*/
|
|
640
|
+
this.regionOperation = function (options, data, callback) {
|
|
641
|
+
|
|
642
|
+
function execOperation(data) {
|
|
643
|
+
if (globeMap) {
|
|
644
|
+
globeMap.regionOperation(options, data);
|
|
645
|
+
callback && callback();
|
|
646
|
+
} else if (gisMap) {
|
|
647
|
+
gridPolygon2dOperation(options, data, callback);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
if (data) {
|
|
652
|
+
execOperation(data);
|
|
653
|
+
} else {
|
|
654
|
+
if (!options.idbSetting.usageID) { return }
|
|
655
|
+
|
|
656
|
+
let storeName = !!globeMap ? "usageID" : "usage2D" + "_" + options.idbSetting.usageID;
|
|
657
|
+
let queryFromGIS = () => {
|
|
658
|
+
let filterString = options.idbSetting.filterString || "1=1";
|
|
659
|
+
let queryParam = {
|
|
660
|
+
layerID: options.idbSetting.usageID,
|
|
661
|
+
where: filterString,
|
|
662
|
+
geometry: '',
|
|
663
|
+
outGeometry: true,
|
|
664
|
+
options: {
|
|
665
|
+
originalData: true
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
//二维地图不获取原始数据
|
|
669
|
+
if(!globeMap) queryParam.options.originalData = false;
|
|
670
|
+
let queryCallback = function (featureInfos) {
|
|
671
|
+
execOperation(featureInfos);
|
|
672
|
+
}
|
|
673
|
+
if (gisMap) {
|
|
674
|
+
gisMap.queryFeature(queryParam, queryCallback)
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (!options.idbSetting.enabled) {
|
|
679
|
+
// 直接查询
|
|
680
|
+
queryFromGIS()
|
|
681
|
+
} else {
|
|
682
|
+
// 查询是否存在表
|
|
683
|
+
checkObjectStore(storeName)
|
|
684
|
+
.then(function (hasObjStore) {
|
|
685
|
+
if (hasObjStore) {
|
|
686
|
+
// 如果有,读取本地
|
|
687
|
+
execOperation();
|
|
688
|
+
} else {
|
|
689
|
+
// 如果没有,查询queryFeature
|
|
690
|
+
queryFromGIS()
|
|
691
|
+
}
|
|
692
|
+
})
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
/*
|
|
697
|
+
* @description:新参数格式的旧线接口,主要用来做中间层参数格式转换
|
|
698
|
+
* @method showPolyline_BI
|
|
699
|
+
* @param {参数类型} 参数名 参数说明
|
|
700
|
+
*
|
|
701
|
+
* @return {返回值类型} 返回值说明
|
|
702
|
+
*
|
|
703
|
+
* @author: Hetianhong
|
|
704
|
+
* @date: 2021-11-11 15:40:31
|
|
705
|
+
*/
|
|
706
|
+
this.showPolyline_BI = function (layerName, positions = [], options = {}) {
|
|
707
|
+
if (globeMap !== null) {
|
|
708
|
+
// 默认参数
|
|
709
|
+
let defaultOpt = {
|
|
710
|
+
// 样式类
|
|
711
|
+
styleOpt: {
|
|
712
|
+
period: 4, // 动画线段的周期,越短越快
|
|
713
|
+
image: 'road.png', // type为image时线段所使用的纹理图案,位置在data3d/polyline/目录下(type为image限定)
|
|
714
|
+
repeatX: 2, // 横向纹理重复,越大则越密(type为image限定)
|
|
715
|
+
repeatY: 1, //纵向纹理重复(type为image限定)
|
|
716
|
+
glowPower: 0, //中心亮度
|
|
717
|
+
intensity: 1.2, //纹理图片颜色强度
|
|
718
|
+
gapColor: 'rgba(0, 0, 0, 0)', //间隙颜色(type为dash限定)
|
|
719
|
+
dashLength: 15, //间隙宽(type为dash限定)
|
|
720
|
+
outlineWidth: 0, // 边框线宽(type为outline限定)
|
|
721
|
+
outlineColor: "rgba(0, 0, 0, 0)", // 边框颜色(type为outline限定)
|
|
722
|
+
type: 'color', // 线条类型,有 image color dash outline glow
|
|
723
|
+
width: 10,
|
|
724
|
+
color: "rgba(255,255,0,1)"
|
|
725
|
+
},
|
|
726
|
+
// 视角缩放类
|
|
727
|
+
zoomOpt: {
|
|
728
|
+
//zoom参数
|
|
729
|
+
heading: 0,
|
|
730
|
+
pitch: -90,
|
|
731
|
+
range: null,
|
|
732
|
+
//可视级别
|
|
733
|
+
minZoom: 0,
|
|
734
|
+
maxZoom: 24,
|
|
735
|
+
//泛光绘制
|
|
736
|
+
// 下面两项,不暴露,全部为false
|
|
737
|
+
bloom: false,
|
|
738
|
+
merge: false
|
|
739
|
+
},
|
|
740
|
+
// 交互类
|
|
741
|
+
interactOpt: {
|
|
742
|
+
//click相关
|
|
743
|
+
clickColor: "rgb(255, 255, 0.0)", // 点击后的颜色
|
|
744
|
+
clickWidth: 30, // 点击后的宽度
|
|
745
|
+
clickCallback: undefined, // function(e) {console.log('click polyline', e)},
|
|
746
|
+
mouseOverCallBack: undefined
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
let getMergedOptions = (options) => {
|
|
750
|
+
let mergedOptions = {};
|
|
751
|
+
mergedOptions.styleOpt = Object.assign({}, defaultOpt.styleOpt, options.styleOpt);
|
|
752
|
+
mergedOptions.zoomOpt = Object.assign({}, defaultOpt.zoomOpt, options.zoomOpt);
|
|
753
|
+
mergedOptions.interactOpt = Object.assign({}, defaultOpt.interactOpt, options.interactOpt);
|
|
754
|
+
return mergedOptions
|
|
755
|
+
}
|
|
756
|
+
let mergedOptions = getMergedOptions(options);
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
let opt = {}
|
|
760
|
+
// let styleOpt = options.styleOpt;
|
|
761
|
+
// let zoomOpt = options.zoomOpt;
|
|
762
|
+
// let interactOpt = options.interactOpt;
|
|
763
|
+
//hth 此处进行参数转换
|
|
764
|
+
switch (mergedOptions.styleOpt.type) {
|
|
765
|
+
case "image":
|
|
766
|
+
opt.period = defaultValue(mergedOptions.styleOpt.period, 4); // 纹理流动周期,越小越快
|
|
767
|
+
opt.image = defaultValue(mergedOptions.styleOpt.image, 'road.png'); //纹理图片,data3d/polyline/目录下
|
|
768
|
+
opt.repeatX = defaultValue(mergedOptions.styleOpt.repeatX, 2); //横向纹理重复,越大越密
|
|
769
|
+
opt.repeatY = defaultValue(mergedOptions.styleOpt.repeatY, 1); //纵向纹理重复
|
|
770
|
+
opt.glowPower = defaultValue(mergedOptions.styleOpt.glowPower, 0); //中心亮度
|
|
771
|
+
opt.intensity = defaultValue(mergedOptions.styleOpt.intensity, 1.2); //纹理图片颜色强度
|
|
772
|
+
break;
|
|
773
|
+
case "glow":
|
|
774
|
+
opt.glowPower = defaultValue(mergedOptions.styleOpt.glowPower, 0.2); //中心亮度
|
|
775
|
+
break;
|
|
776
|
+
case "dash":
|
|
777
|
+
opt.gapColor = defaultValue(mergedOptions.styleOpt.gapColor, 'rgba(0, 0, 0, 0)'); //间隙颜色
|
|
778
|
+
opt.dashLength = defaultValue(mergedOptions.styleOpt.dashLength, 15); //间隙宽
|
|
779
|
+
break;
|
|
780
|
+
case "outline":
|
|
781
|
+
opt.outlineWidth = defaultValue(mergedOptions.styleOpt.outlineWidth, 0);
|
|
782
|
+
opt.outlineColor = defaultValue(mergedOptions.styleOpt.outlineColor, "rgba(0, 0, 0, 0)");
|
|
783
|
+
break;
|
|
784
|
+
default:
|
|
785
|
+
// color
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
opt.type = mergedOptions.styleOpt.type;
|
|
789
|
+
opt.width = mergedOptions.styleOpt.width;
|
|
790
|
+
opt.color = mergedOptions.styleOpt.color;
|
|
791
|
+
|
|
792
|
+
// 遍历位置数组中的每一项
|
|
793
|
+
for(let pos of positions) {
|
|
794
|
+
// 遍历opt中每一个key赋值到每一个pos中
|
|
795
|
+
for(let k in opt) {
|
|
796
|
+
pos[k] = opt[k]
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
let zoom = mergedOptions.zoomOpt.zoom
|
|
802
|
+
let clear = mergedOptions.zoomOpt.clear
|
|
803
|
+
let clickCallback = mergedOptions.interactOpt.clickCallback
|
|
804
|
+
let mouseOverCallBack = mergedOptions.interactOpt.mouseOverCallBack
|
|
805
|
+
let commonOpt = {
|
|
806
|
+
//zoom参数
|
|
807
|
+
heading: mergedOptions.zoomOpt.heading,
|
|
808
|
+
pitch: mergedOptions.zoomOpt.pitch,
|
|
809
|
+
range: mergedOptions.zoomOpt.range,
|
|
810
|
+
//可视级别
|
|
811
|
+
minZoom: mergedOptions.zoomOpt.minZoom,
|
|
812
|
+
maxZoom: mergedOptions.zoomOpt.maxZoom,
|
|
813
|
+
//click相关
|
|
814
|
+
clickColor: mergedOptions.interactOpt.clickColor, // 点击后的颜色
|
|
815
|
+
clickWidth: mergedOptions.interactOpt.clickWidth, // 点击后的宽度
|
|
816
|
+
//泛光绘制
|
|
817
|
+
// 下面两项,不暴露,全部为false
|
|
818
|
+
bloom: false,
|
|
819
|
+
merge: false
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
globeMap.showPolyline(positions, zoom, clear, commonOpt, layerName, clickCallback, mouseOverCallBack);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
/*
|
|
827
|
+
* @description:被动触发图层类似点击效果,需要在图层内在单独定义Event
|
|
828
|
+
* @method activeLayer
|
|
829
|
+
* @param {String} layerName 图层名
|
|
830
|
+
* @param {Object} options 配置项
|
|
831
|
+
* @param {String} options.type 操作类型,'clear', 'active'
|
|
832
|
+
* @param {Boolean} options.zoom 是否缩放
|
|
833
|
+
* @param {Object} filter 过滤项
|
|
834
|
+
* @param {String} filter.keyFieldName 过滤键名
|
|
835
|
+
* @param {Array} filter.values 过滤值内容数组
|
|
836
|
+
*
|
|
837
|
+
* @return {返回值类型} 返回值说明
|
|
838
|
+
*
|
|
839
|
+
* @author: Hetianhong
|
|
840
|
+
* @date: 2021-11-26 09:49:16
|
|
841
|
+
*/
|
|
842
|
+
this.activeLayer = function (layerName, options, filter) {
|
|
843
|
+
if (globeMap != null && mapType == "globe") {
|
|
844
|
+
globeMap.activeLayer(layerName, options, filter);
|
|
845
|
+
}
|
|
846
|
+
if (gisMap != null && mapType == "map") {
|
|
847
|
+
gisMap.activeLayer(layerName, options, filter);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
function gridPolygon2dOperation(options, data, callback) {
|
|
852
|
+
var storeName = `usage2D_${options.idbSetting.usageID}`;
|
|
853
|
+
function showGrid(realData) {
|
|
854
|
+
// 转换一下
|
|
855
|
+
var geometries = [];
|
|
856
|
+
var extraGeometries = [];
|
|
857
|
+
var specialAreaS=options.specialAreaS;//玲珑平台分类设色
|
|
858
|
+
for (var i = 0; i < realData.length; i++) {
|
|
859
|
+
var feature = realData[i];
|
|
860
|
+
var geom = feature.geometry;
|
|
861
|
+
geom.attributes = feature.attributes; // attributes会导致id没用,使用自带的id
|
|
862
|
+
var hasPush=false;
|
|
863
|
+
if(specialAreaS&&specialAreaS.length>0){
|
|
864
|
+
for (var j = 0; j < specialAreaS.length; j++) {
|
|
865
|
+
var specialArea=specialAreaS[j];
|
|
866
|
+
if(!specialArea.geometries){
|
|
867
|
+
specialArea.geometries=[];
|
|
868
|
+
}
|
|
869
|
+
var attributes=JSON.parse(JSON.stringify(feature.attributes));
|
|
870
|
+
let filterResult=new Function(`return ${specialArea.statusControl.compiled}`)().call(null,attributes);
|
|
871
|
+
if(filterResult==true){
|
|
872
|
+
specialArea.geometries.push(geom);
|
|
873
|
+
hasPush=true;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
!hasPush&&(geometries.push(geom));
|
|
878
|
+
}
|
|
879
|
+
if (options.specialArea && options.selectedSetting.selected.length) {
|
|
880
|
+
var extraIds = options.selectedSetting.selected.map(s => s.selectID);
|
|
881
|
+
for (var i = geometries.length - 1; i > -1; i--) {
|
|
882
|
+
var geom = geometries[i];
|
|
883
|
+
if (extraIds.indexOf(geom.attributes[options.keyFieldName]) > -1) {
|
|
884
|
+
geometries.splice(i, 1);
|
|
885
|
+
extraGeometries.push(geom);
|
|
886
|
+
if (extraGeometries.length === extraIds.length) break;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
gisMap.locateFeatureByCoords(geometries, 'polygon',
|
|
891
|
+
options.layerName, // id,如果已经有attributes就没用了
|
|
892
|
+
options.style, // style
|
|
893
|
+
options.highlightStyle, // highlightStyle
|
|
894
|
+
options.commonSetting.zoom, // zoom
|
|
895
|
+
options.keyFieldName,
|
|
896
|
+
options.labelSetting.showLabel && options.labelFieldName, // keyField, labelField
|
|
897
|
+
options.labelStyle, // labelStyle
|
|
898
|
+
options.customColor ? interpolateColor(options.customColor[0], options.customColor[1], Math.min(geometries.length, 10)) : 10, // randomColor
|
|
899
|
+
false, // renderCanvas
|
|
900
|
+
true, // singleSelect
|
|
901
|
+
{
|
|
902
|
+
minZoom: options.visiblitySetting.beginLevel,
|
|
903
|
+
maxZoom: options.visiblitySetting.endLevel,
|
|
904
|
+
layerId: options.layerName,
|
|
905
|
+
comCallbak: callback
|
|
906
|
+
// hLabelStyle: options.hLabelStyle, // 选中文字时效果,没用
|
|
907
|
+
},
|
|
908
|
+
options.layerName, // layerTag
|
|
909
|
+
options.eventSetting.clickCallback
|
|
910
|
+
);
|
|
911
|
+
if (extraGeometries.length) {
|
|
912
|
+
gisMap.locateFeatureByCoords(extraGeometries, 'polygon',
|
|
913
|
+
options.layerName, // id,如果已经有attributes就没用了
|
|
914
|
+
options.specialAreaStyle, // style
|
|
915
|
+
options.highlightStyle, // highlightStyle
|
|
916
|
+
false, // zoom
|
|
917
|
+
options.keyFieldName,
|
|
918
|
+
options.selectedSetting.showLabel && options.labelFieldName, // keyField, labelField
|
|
919
|
+
options.specialAreaLabelStyle, // labelStyle
|
|
920
|
+
false, // randomColor
|
|
921
|
+
false, // renderCanvas
|
|
922
|
+
true, // singleSelect
|
|
923
|
+
{
|
|
924
|
+
minZoom: options.visiblitySetting.beginLevel,
|
|
925
|
+
maxZoom: options.visiblitySetting.endLevel,
|
|
926
|
+
layerId: options.layerName
|
|
927
|
+
// hLabelStyle: options.hLabelStyle, // 选中文字时效果,没用
|
|
928
|
+
},
|
|
929
|
+
options.layerName, // layerTag
|
|
930
|
+
options.eventSetting.clickCallback
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
if(specialAreaS&&specialAreaS.length>0){
|
|
934
|
+
for (var j = 0; j < specialAreaS.length; j++) {
|
|
935
|
+
var specialArea=specialAreaS[j];
|
|
936
|
+
if(specialArea.geometries.length>0){
|
|
937
|
+
gisMap.locateFeatureByCoords(specialArea.geometries, 'polygon',
|
|
938
|
+
options.layerName, // id,如果已经有attributes就没用了
|
|
939
|
+
specialArea.style, // style
|
|
940
|
+
options.highlightStyle, // highlightStyle
|
|
941
|
+
options.commonSetting.zoom, // zoom
|
|
942
|
+
options.keyFieldName,
|
|
943
|
+
specialArea.specialAreaStyle.textLabelShowEnabled&&specialArea.specialAreaStyle.labelFieldName, // keyField, labelField
|
|
944
|
+
specialArea.labelStyle, // labelStyle
|
|
945
|
+
false,// randomColor
|
|
946
|
+
false, // renderCanvas
|
|
947
|
+
true, // singleSelect
|
|
948
|
+
{
|
|
949
|
+
minZoom: options.visiblitySetting.beginLevel,
|
|
950
|
+
maxZoom: options.visiblitySetting.endLevel,
|
|
951
|
+
layerId: options.layerName,
|
|
952
|
+
comCallbak: callback
|
|
953
|
+
// hLabelStyle: options.hLabelStyle, // 选中文字时效果,没用
|
|
954
|
+
},
|
|
955
|
+
options.layerName, // layerTag
|
|
956
|
+
options.eventSetting.clickCallback
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
if (!data) {
|
|
965
|
+
// 数据来自本地
|
|
966
|
+
var dbOpenRequest = window.indexedDB.open('regionDB');
|
|
967
|
+
dbOpenRequest.onsuccess = function(event) {
|
|
968
|
+
var db = this.result;
|
|
969
|
+
var store = db.transaction(storeName).objectStore(storeName);
|
|
970
|
+
var request = store.getAll();
|
|
971
|
+
request.onsuccess = function() {
|
|
972
|
+
var features = this.result;
|
|
973
|
+
showGrid(features);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
} else {
|
|
977
|
+
var _data = JSON.parse(JSON.stringify(data[0]));
|
|
978
|
+
var newData = data[0];
|
|
979
|
+
if (newData && newData.geometry) {
|
|
980
|
+
_data = JSON.parse(JSON.stringify(data));
|
|
981
|
+
showGrid(data);
|
|
982
|
+
} else {
|
|
983
|
+
showGrid(data[0]);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
var dbRequest = window.indexedDB.open('regionDB');
|
|
987
|
+
dbRequest.onsuccess = function() {
|
|
988
|
+
addStore(this.result.version);
|
|
989
|
+
}
|
|
990
|
+
function addStore(version) {
|
|
991
|
+
var dbOpenRequest = window.indexedDB.open('regionDB', version + 1);
|
|
992
|
+
dbOpenRequest.onupgradeneeded = function(event) {
|
|
993
|
+
var db = event.target.result;
|
|
994
|
+
if (!db.objectStoreNames.contains(storeName)) {
|
|
995
|
+
var store = db.createObjectStore(storeName, { autoIncrement: true });
|
|
996
|
+
for (var i = 0; i < _data.length; i++) {
|
|
997
|
+
store.put(_data[i]);
|
|
998
|
+
}
|
|
999
|
+
store.transaction.oncomplete = function() {
|
|
1000
|
+
console.log("complete");
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
this.networkCloud = function (options, positions) {
|
|
1010
|
+
if(!globeMap) {return}
|
|
1011
|
+
globeMap.networkCloud(options, positions)
|
|
1012
|
+
}
|
|
1013
|
+
this.clearNetworkCloud = function (layerNames) {
|
|
1014
|
+
if(!globeMap) {return}
|
|
1015
|
+
globeMap.clearNetworkCloud(layerNames)
|
|
1016
|
+
}
|
|
1017
|
+
this.lineOperation = function(options, data) {
|
|
1018
|
+
if(!options || !options.layerName){
|
|
1019
|
+
console.log('图层名必须传递')
|
|
1020
|
+
return
|
|
1021
|
+
}
|
|
1022
|
+
// 数据获取
|
|
1023
|
+
let queryFeature = (queryParams) => {
|
|
1024
|
+
if(gisMap) {
|
|
1025
|
+
return new Promise(function(resolve) {
|
|
1026
|
+
let cb = function(result) {
|
|
1027
|
+
resolve(result)
|
|
1028
|
+
}
|
|
1029
|
+
gisMap.queryFeature(queryParams, cb)
|
|
1030
|
+
})
|
|
1031
|
+
} else {
|
|
1032
|
+
return Promise.resolve(undefined)
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
// 执行绘制
|
|
1036
|
+
let drawLine = (options, data) => {
|
|
1037
|
+
if (globeMap) globeMap.lineOperation(options, data);
|
|
1038
|
+
else if (gisMap) {
|
|
1039
|
+
let style = options.style || {};
|
|
1040
|
+
let hStyle = options.hStyle || {};
|
|
1041
|
+
let symbol = {
|
|
1042
|
+
type: "simple-line", // autocasts as new SimpleLineSymbol()
|
|
1043
|
+
color: style.color || "lightblue",
|
|
1044
|
+
width: (style.width || 2) + "px",
|
|
1045
|
+
style: style.style || "short-dot"
|
|
1046
|
+
};
|
|
1047
|
+
let hsymbol = {
|
|
1048
|
+
type: "simple-line", // autocasts as new SimpleLineSymbol()
|
|
1049
|
+
color: hStyle.color || "lightblue",
|
|
1050
|
+
width: (hStyle.width || 2) + "px",
|
|
1051
|
+
style: hStyle.style || "short-dot"
|
|
1052
|
+
};
|
|
1053
|
+
var opt = options.options || {};
|
|
1054
|
+
gisMap.locateFeatureByCoords(data, options.type, options.id, symbol, hsymbol, options.zoom, options.keyField,
|
|
1055
|
+
options.labelField,
|
|
1056
|
+
options.labelStyle,
|
|
1057
|
+
options.randomColor,
|
|
1058
|
+
options.renderCanvas,
|
|
1059
|
+
options.singleSelected,
|
|
1060
|
+
opt,
|
|
1061
|
+
options.layerTag,
|
|
1062
|
+
options.callback
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
// 主逻辑
|
|
1068
|
+
if(!!data&&data.length) {
|
|
1069
|
+
drawLine(options, data)
|
|
1070
|
+
} else {
|
|
1071
|
+
if(!options.usageID) {
|
|
1072
|
+
console.log('图层用途必须传递')
|
|
1073
|
+
return
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
let originalData = false;
|
|
1077
|
+
if (globeMap) originalData = true;
|
|
1078
|
+
let queryParams = {
|
|
1079
|
+
layerID: options.usageID,
|
|
1080
|
+
where: options.filterString || "1=1",
|
|
1081
|
+
geometry: '',
|
|
1082
|
+
outGeometry: true,
|
|
1083
|
+
options: { originalData: originalData }
|
|
1084
|
+
}
|
|
1085
|
+
queryFeature(queryParams)
|
|
1086
|
+
.then(function(resultData) {
|
|
1087
|
+
if(!resultData) {
|
|
1088
|
+
console.log('没有查询到数据,请检查查询参数')
|
|
1089
|
+
return
|
|
1090
|
+
}
|
|
1091
|
+
drawLine(options, resultData)
|
|
1092
|
+
})
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
|
|
1080
1099
|
export default egovaBI
|