egovamap 0.35.19 → 0.35.21
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/egovamap/egovaBI.js +1612 -1612
- package/egovamap/egovagis.js +2535 -2535
- package/egovamap/egovagisviewer.js +9 -1
- package/egovamap/egovaglobe.js +3787 -3787
- package/egovamap/egovamap.js +5745 -5731
- package/package.json +24 -24
package/egovamap/egovaBI.js
CHANGED
|
@@ -1,1612 +1,1612 @@
|
|
|
1
|
-
var egovaBI = function (globeMap, gisMap, mapType) {
|
|
2
|
-
function defaultValue(a, b) {
|
|
3
|
-
if (a !== undefined && a !== null) {
|
|
4
|
-
return a;
|
|
5
|
-
}
|
|
6
|
-
return b;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function getImgSize(url) {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
let img = new Image();
|
|
12
|
-
img.onload = function () {
|
|
13
|
-
resolve({ width: img.width, height: img.height });
|
|
14
|
-
img = null;
|
|
15
|
-
};
|
|
16
|
-
img.onerror = function () {
|
|
17
|
-
resolve({ width: 0, height: 0 });
|
|
18
|
-
img = null;
|
|
19
|
-
};
|
|
20
|
-
img.src = url;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function interpolateColor(startColor, endColor, count) {
|
|
25
|
-
if (count < 2) return [startColor, endColor];
|
|
26
|
-
|
|
27
|
-
var start = rgbToRgbArray(startColor);
|
|
28
|
-
var end = rgbToRgbArray(endColor);
|
|
29
|
-
var end0 = end[0];
|
|
30
|
-
var end1 = end[1];
|
|
31
|
-
var end2 = end[2];
|
|
32
|
-
var end3 = end[3];
|
|
33
|
-
var start0 = start[0];
|
|
34
|
-
var start1 = start[1];
|
|
35
|
-
var start2 = start[2];
|
|
36
|
-
var start3 = start[3];
|
|
37
|
-
|
|
38
|
-
var r = end0 - start0;
|
|
39
|
-
var g = end1 - start1;
|
|
40
|
-
var b = end2 - start2;
|
|
41
|
-
var opacity = end3 - start3;
|
|
42
|
-
var step = 1.0 / count;
|
|
43
|
-
var colors = [startColor];
|
|
44
|
-
var _count = count - 1;
|
|
45
|
-
for (var i = 1; i < _count; i++) {
|
|
46
|
-
var interval = step * i;
|
|
47
|
-
colors.push([
|
|
48
|
-
Math.round(start0 + interval * r),
|
|
49
|
-
Math.round(start1 + interval * g),
|
|
50
|
-
Math.round(start2 + interval * b),
|
|
51
|
-
start3 + interval * opacity,
|
|
52
|
-
]);
|
|
53
|
-
}
|
|
54
|
-
colors.push(endColor);
|
|
55
|
-
return colors;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function rgbToRgbArray(color) {
|
|
59
|
-
if (
|
|
60
|
-
!color ||
|
|
61
|
-
typeof color !== 'string' ||
|
|
62
|
-
(typeof color == 'string' && color.indexOf('rgb') == -1)
|
|
63
|
-
)
|
|
64
|
-
return color;
|
|
65
|
-
|
|
66
|
-
var r, g, b, a;
|
|
67
|
-
var rgbaAttr = color.match(/[\d.]+/g);
|
|
68
|
-
if (rgbaAttr.length >= 3) {
|
|
69
|
-
r = parseInt(rgbaAttr[0]);
|
|
70
|
-
g = parseInt(rgbaAttr[1]);
|
|
71
|
-
b = parseInt(rgbaAttr[2]);
|
|
72
|
-
if (rgbaAttr.length > 3) a = parseFloat(rgbaAttr[3]);
|
|
73
|
-
else a = 1;
|
|
74
|
-
}
|
|
75
|
-
return [r, g, b, a];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 查询idb是否存在表
|
|
79
|
-
function checkObjectStore(storeName) {
|
|
80
|
-
return new Promise((resolve, reject) => {
|
|
81
|
-
// 打开网格数据库
|
|
82
|
-
let idbRequest = window.indexedDB.open('regionDB');
|
|
83
|
-
idbRequest.onblocked = function (event) {
|
|
84
|
-
// 如果其他的一些页签加载了该数据库,在我们继续之前需要关闭它们
|
|
85
|
-
// alert("请关闭其他由该站点打开的页签!");
|
|
86
|
-
console.log('请关闭其他由该站点打开的页签!');
|
|
87
|
-
};
|
|
88
|
-
idbRequest.onerror = (event) => {
|
|
89
|
-
console.log('数据库打开报错(checkObjectStore)');
|
|
90
|
-
// resolve(undefined)
|
|
91
|
-
reject(event.target.error.message);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
idbRequest.onsuccess = () => {
|
|
95
|
-
let db = idbRequest.result;
|
|
96
|
-
// console.log('数据库打开成功(hasObjectStore)')
|
|
97
|
-
resolve(db.objectStoreNames.contains(storeName));
|
|
98
|
-
db.close();
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function deal2DPoints(layerName, positions, options) {
|
|
104
|
-
let datalist = [];
|
|
105
|
-
let zoom = options.common.zoom;
|
|
106
|
-
let clear = options.common.clear;
|
|
107
|
-
let highLightType = -1;
|
|
108
|
-
let infoStyle = null;
|
|
109
|
-
let renderCanvas = null;
|
|
110
|
-
if (options.option && options.option.renderCanvas !== undefined) {
|
|
111
|
-
renderCanvas = options.option.renderCanvas;
|
|
112
|
-
}
|
|
113
|
-
let tagName = layerName;
|
|
114
|
-
let clusterOption = null;
|
|
115
|
-
|
|
116
|
-
let hasHover = null;
|
|
117
|
-
let callback = null;
|
|
118
|
-
datalist = positions.map(function (p) {
|
|
119
|
-
if (options.textStyle.label) {
|
|
120
|
-
for (const key in p) {
|
|
121
|
-
if (
|
|
122
|
-
key !== 'id' &&
|
|
123
|
-
key !== 'x' &&
|
|
124
|
-
key !== 'y' &&
|
|
125
|
-
key !== 'objectID'
|
|
126
|
-
) {
|
|
127
|
-
if (!p.label) p.label = [];
|
|
128
|
-
var labelItem = {};
|
|
129
|
-
labelItem[key] = p[key];
|
|
130
|
-
p.label.push(labelItem);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
p.minZoom = options.common.beginLevel;
|
|
135
|
-
p.maxZoom = options.common.endLevel;
|
|
136
|
-
p.symbolType = -1;
|
|
137
|
-
p.symbolUrl = options.textStyle.symbolUrl || 'location.png';
|
|
138
|
-
if (options.selected && options.selected.hSymbolUrl)
|
|
139
|
-
p.hSymbolUrl = options.selected.hSymbolUrl;
|
|
140
|
-
p.scale = options.textStyle.scale;
|
|
141
|
-
p.angle = options.textStyle.angle;
|
|
142
|
-
// 适配选中效果的放大倍数和高亮图片
|
|
143
|
-
if (options.selectStyle && options.selectStyle.enable) {
|
|
144
|
-
if (options.selectStyle.scaleEnabled) {
|
|
145
|
-
p.hScale = options.selectStyle.scaleFactor;
|
|
146
|
-
}
|
|
147
|
-
if (options.selectStyle.imgUrl) {
|
|
148
|
-
p.hSymbolUrl = options.selectStyle.imgUrl;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
// 杭州现场,需要叠加图片和地图放大同时存在
|
|
152
|
-
if (options.developer) {
|
|
153
|
-
if (
|
|
154
|
-
options.developer.enableScaleAndOverImage &&
|
|
155
|
-
options.developer.scaleAndOverImageFactor
|
|
156
|
-
) {
|
|
157
|
-
p.aScale = options.developer.scaleAndOverImageFactor;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
//classify symbol
|
|
161
|
-
if (options.textStyle.enableClassify) {
|
|
162
|
-
const customScheme = options.textStyle.customScheme;
|
|
163
|
-
const classField = options.textStyle.classField;
|
|
164
|
-
if (
|
|
165
|
-
p[classField] &&
|
|
166
|
-
Object.prototype.toString.call(customScheme) ==
|
|
167
|
-
'[object Array]' &&
|
|
168
|
-
customScheme.length
|
|
169
|
-
) {
|
|
170
|
-
customScheme.forEach((scheme) => {
|
|
171
|
-
if (scheme.type == p[classField]) {
|
|
172
|
-
scheme.imageUrl && (p.symbolUrl = scheme.imageUrl);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
//textValue
|
|
178
|
-
if (options.textStyle.enableText) {
|
|
179
|
-
let labelMinZoom = options.common.beginLevel;
|
|
180
|
-
let labelMaxZoom = options.common.endLevel;
|
|
181
|
-
if (options.textStyle.labelZoomEnabled) {
|
|
182
|
-
labelMinZoom = options.textStyle.textBeginLevel;
|
|
183
|
-
labelMaxZoom = options.textStyle.textEndLevel;
|
|
184
|
-
}
|
|
185
|
-
p.labelStyle = {
|
|
186
|
-
type: 'text',
|
|
187
|
-
minZoom: labelMinZoom,
|
|
188
|
-
maxZoom: labelMaxZoom,
|
|
189
|
-
xoffset: options.textStyle.xoffset + 'px',
|
|
190
|
-
yoffset: options.textStyle.yoffset + 'px',
|
|
191
|
-
text: p.textValue,
|
|
192
|
-
color: options.textStyle.fillColor,
|
|
193
|
-
font: {
|
|
194
|
-
size: options.textStyle.fontSize + 'px',
|
|
195
|
-
weight: options.textStyle.fontWeight,
|
|
196
|
-
family: options.textStyle.family || 'microsoft-yahei',
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
p.useLabelBg = options.textStyle.textBackground;
|
|
201
|
-
if (p.useLabelBg) {
|
|
202
|
-
p.labelBgStyle = {
|
|
203
|
-
type: 'picture-marker',
|
|
204
|
-
url: options.textStyle.textBackgroundUrl,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
return p;
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
return new Promise((resolve, reject) => {
|
|
211
|
-
try {
|
|
212
|
-
let args = {
|
|
213
|
-
datalist: datalist,
|
|
214
|
-
zoom: zoom,
|
|
215
|
-
clear: clear,
|
|
216
|
-
highLightType: highLightType,
|
|
217
|
-
infoStyle: infoStyle,
|
|
218
|
-
renderCanvas: renderCanvas,
|
|
219
|
-
tagName: tagName,
|
|
220
|
-
clusterOption: null,
|
|
221
|
-
hasHover: hasHover,
|
|
222
|
-
callback: callback,
|
|
223
|
-
};
|
|
224
|
-
if (options.clusterStyle.clusterEnabled) {
|
|
225
|
-
clusterOption = {
|
|
226
|
-
clusterType: options.clusterStyle.clusterType,
|
|
227
|
-
distance: options.clusterStyle.clusterDistance,
|
|
228
|
-
style: null,
|
|
229
|
-
critical: options.clusterStyle.critical || 10,
|
|
230
|
-
level: options.clusterStyle.level,
|
|
231
|
-
clickShowSpiralPoint:
|
|
232
|
-
options.clusterStyle.clickShowSpiralPoint,
|
|
233
|
-
labelStyle: {
|
|
234
|
-
type: 'text',
|
|
235
|
-
color: options.clusterStyle.fillColor,
|
|
236
|
-
text: '',
|
|
237
|
-
xoffset: options.clusterStyle.xoffset + 'px',
|
|
238
|
-
yoffset: options.clusterStyle.yoffset + 'px',
|
|
239
|
-
font: {
|
|
240
|
-
size: options.clusterStyle.fontSize + 'px',
|
|
241
|
-
weight:
|
|
242
|
-
options.clusterStyle.fontWeight || 'normal',
|
|
243
|
-
family:
|
|
244
|
-
options.clusterStyle.family ||
|
|
245
|
-
'microsoft-yahei',
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
let useCustomClusterStyle =
|
|
251
|
-
options.clusterStyle.symbolUrl &&
|
|
252
|
-
options.clusterStyle.useCustomStyle;
|
|
253
|
-
let clusterStyle = {
|
|
254
|
-
type: 'simple-marker',
|
|
255
|
-
style: 'circle',
|
|
256
|
-
color: [255, 168, 0, 200],
|
|
257
|
-
size: 25 * options.clusterStyle.scale + 'px',
|
|
258
|
-
outline: {
|
|
259
|
-
color: [255, 168, 0, 200],
|
|
260
|
-
width: 2,
|
|
261
|
-
},
|
|
262
|
-
};
|
|
263
|
-
clusterOption.style = clusterStyle;
|
|
264
|
-
if (useCustomClusterStyle) {
|
|
265
|
-
getImgSize(options.clusterStyle.symbolUrl).then(
|
|
266
|
-
(szie) => {
|
|
267
|
-
clusterStyle = {
|
|
268
|
-
type: 'picture-marker',
|
|
269
|
-
url: options.clusterStyle.symbolUrl,
|
|
270
|
-
width:
|
|
271
|
-
szie.width *
|
|
272
|
-
options.clusterStyle.scale +
|
|
273
|
-
'px',
|
|
274
|
-
height:
|
|
275
|
-
szie.height *
|
|
276
|
-
options.clusterStyle.scale +
|
|
277
|
-
'px',
|
|
278
|
-
};
|
|
279
|
-
clusterOption.style = clusterStyle;
|
|
280
|
-
args.clusterOption = clusterOption;
|
|
281
|
-
resolve(args);
|
|
282
|
-
}
|
|
283
|
-
);
|
|
284
|
-
} else {
|
|
285
|
-
args.clusterOption = clusterOption;
|
|
286
|
-
resolve(args);
|
|
287
|
-
}
|
|
288
|
-
} else {
|
|
289
|
-
resolve(args);
|
|
290
|
-
}
|
|
291
|
-
} catch (err) {
|
|
292
|
-
reject(err);
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/*
|
|
298
|
-
* @description:新参数格式的旧热力接口,主要用来做中间层参数格式转换
|
|
299
|
-
* @method showHeatImage3D_BI
|
|
300
|
-
* @param {String} layerName 热力参数数组
|
|
301
|
-
* @param {Array} data 热力值和坐标的数据数组
|
|
302
|
-
* @param {Object} options 配置项
|
|
303
|
-
* @param {Object} options.heatOpt 热力配置项
|
|
304
|
-
* @param {Object} options.commonOpt 通用配置项
|
|
305
|
-
*
|
|
306
|
-
* @return {Void}} 无返回
|
|
307
|
-
*
|
|
308
|
-
* @author: Hetianhong
|
|
309
|
-
* @date: 2021-08-31 14:13:42
|
|
310
|
-
*/
|
|
311
|
-
this.showHeatImage3D_BI = function (layerName, data, option) {
|
|
312
|
-
//data必须包含x y 和 value属性
|
|
313
|
-
if (
|
|
314
|
-
data.length === 0 ||
|
|
315
|
-
!data[0].hasOwnProperty('x') ||
|
|
316
|
-
!data[0].hasOwnProperty('y') ||
|
|
317
|
-
!data[0].hasOwnProperty('value')
|
|
318
|
-
) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
if (globeMap != null) {
|
|
322
|
-
//hth 此处进行参数转换
|
|
323
|
-
let commonOpt = option.commonOpt; // 通用配置项
|
|
324
|
-
let heatOpt = option.heatOpt; // 热力配置项
|
|
325
|
-
|
|
326
|
-
let info = {};
|
|
327
|
-
let zoom = defaultValue(commonOpt.zoom, false);
|
|
328
|
-
let clear = defaultValue(commonOpt.clear, true);
|
|
329
|
-
let options = {
|
|
330
|
-
heading: defaultValue(commonOpt.heading, 0),
|
|
331
|
-
pitch: defaultValue(commonOpt.pitch, -45),
|
|
332
|
-
range: defaultValue(commonOpt.range, 8000),
|
|
333
|
-
maxDataLength: defaultValue(commonOpt.maxDataLength, 5),
|
|
334
|
-
layerName: layerName,
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
// 开始组装info
|
|
338
|
-
//组装info.data,其实也没啥组装的
|
|
339
|
-
info.data = data;
|
|
340
|
-
|
|
341
|
-
//组装info.options
|
|
342
|
-
info.options = {
|
|
343
|
-
clampStyle: heatOpt.heatType === 0 ? 0 : 3, // 如果设置了为0,则为0,其余则全部为旧逻辑的3绘制方式,即贴地贴建筑
|
|
344
|
-
renderType: defaultValue(heatOpt.renderType, 'line'),
|
|
345
|
-
dynamicGranularity: defaultValue(
|
|
346
|
-
heatOpt.dynamicGranularity,
|
|
347
|
-
false
|
|
348
|
-
),
|
|
349
|
-
granularity: defaultValue(heatOpt.granularity, 500),
|
|
350
|
-
maxHeight: defaultValue(heatOpt.maxHeight, -1),
|
|
351
|
-
height: defaultValue(heatOpt.height, 10),
|
|
352
|
-
radiusScale: defaultValue(heatOpt.radiusScale, 1.0),
|
|
353
|
-
radius: defaultValue(heatOpt.radius, 40),
|
|
354
|
-
gradient: defaultValue(heatOpt.gradient, {
|
|
355
|
-
0.35: 'rgb(136,218,104)',
|
|
356
|
-
0.7: 'rgb(241,238,124)',
|
|
357
|
-
1.0: 'rgb(243,118,116)',
|
|
358
|
-
}),
|
|
359
|
-
//动态改变热力半径
|
|
360
|
-
dynamicRadius: defaultValue(heatOpt.dynamicRadius, undefined),
|
|
361
|
-
dynamicLevel: defaultValue(heatOpt.dynamicLevel, undefined),
|
|
362
|
-
// 下面的部分不建议传,逐步舍弃
|
|
363
|
-
gridSize: defaultValue(heatOpt.gridSize, null),
|
|
364
|
-
blur: defaultValue(heatOpt.blur, 0.85),
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
// 转换过后,使用旧的参数格式调用原热力接口
|
|
368
|
-
globeMap.showHeatImage3D(info, zoom, clear, options);
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
/*
|
|
373
|
-
* @description:打点和聚类接口进行整合后的新接口
|
|
374
|
-
* @method drawPoint
|
|
375
|
-
* @param {String} layerName 图层名
|
|
376
|
-
* @param {Array} positions 位置数组
|
|
377
|
-
* @param {Object} options 配置项
|
|
378
|
-
*
|
|
379
|
-
* @return {Void} 无返回
|
|
380
|
-
*
|
|
381
|
-
* @author: Hetianhong
|
|
382
|
-
* @date: 2021-09-09 14:49:49
|
|
383
|
-
*/
|
|
384
|
-
this.drawPoints = function (layerName, positions, options) {
|
|
385
|
-
let drawData = function (layerName, positions, options) {
|
|
386
|
-
if (globeMap && mapType == 'globe') {
|
|
387
|
-
globeMap.drawPoints(layerName, positions, options);
|
|
388
|
-
} else if (gisMap && mapType == 'map') {
|
|
389
|
-
deal2DPoints(layerName, positions, options).then((args) => {
|
|
390
|
-
gisMap.showMultiObjectCurrentPosition(
|
|
391
|
-
args.datalist,
|
|
392
|
-
args.zoom,
|
|
393
|
-
args.clear,
|
|
394
|
-
args.highLightType,
|
|
395
|
-
args.infoStyle,
|
|
396
|
-
args.renderCanvas,
|
|
397
|
-
args.tagName,
|
|
398
|
-
options.clickCallback,
|
|
399
|
-
options.mouseOverCallback,
|
|
400
|
-
args.clusterOption,
|
|
401
|
-
args.hasHover,
|
|
402
|
-
layerName,
|
|
403
|
-
options.mouseOutCallback,
|
|
404
|
-
options.option
|
|
405
|
-
);
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
if (!options.usageID && !options.phyLayerID) {
|
|
411
|
-
drawData(layerName, positions, options);
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
let queryFeature = (queryParams) => {
|
|
415
|
-
return new Promise(function (resolve) {
|
|
416
|
-
let cb = function (result) {
|
|
417
|
-
resolve(result);
|
|
418
|
-
};
|
|
419
|
-
if (gisMap) {
|
|
420
|
-
gisMap.queryFeature(queryParams, cb);
|
|
421
|
-
} else {
|
|
422
|
-
return Promise.resolve(undefined);
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
};
|
|
426
|
-
var filterString = '1=1';
|
|
427
|
-
if (options.filterString) filterString = options.filterString + '';
|
|
428
|
-
let queryParams = {
|
|
429
|
-
layerID: options.usageID || options.phyLayerID,
|
|
430
|
-
where: filterString,
|
|
431
|
-
outGeometry: true,
|
|
432
|
-
};
|
|
433
|
-
queryFeature(queryParams).then(function (resultData) {
|
|
434
|
-
if (!resultData) {
|
|
435
|
-
console.log('没有查询到数据,请检查查询参数');
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
let dataCache = [];
|
|
439
|
-
let errorSize = 0;
|
|
440
|
-
resultData.forEach((element) => {
|
|
441
|
-
let x, y;
|
|
442
|
-
if (element.geometry) {
|
|
443
|
-
x = element.geometry.x;
|
|
444
|
-
y = element.geometry.y;
|
|
445
|
-
}
|
|
446
|
-
if (x && y) {
|
|
447
|
-
let item = { ...element.attributes, x, y };
|
|
448
|
-
if (globeMap && mapType == 'globe' && options.primaryKey) {
|
|
449
|
-
let primaryKeyValue = item[options.primaryKey];
|
|
450
|
-
primaryKeyValue != undefined &&
|
|
451
|
-
(item['attributes'] = {
|
|
452
|
-
objectID: primaryKeyValue,
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
dataCache.push(item);
|
|
456
|
-
} else {
|
|
457
|
-
errorSize++;
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
if (errorSize > 0) {
|
|
461
|
-
console.error(`${errorSize}个点格式错误,无法正常加载`);
|
|
462
|
-
}
|
|
463
|
-
if (options.callback && typeof options.callback === 'function') {
|
|
464
|
-
options.callback(dataCache);
|
|
465
|
-
}
|
|
466
|
-
drawData(layerName, dataCache, options);
|
|
467
|
-
});
|
|
468
|
-
};
|
|
469
|
-
this.getLabel = function (attributes) {
|
|
470
|
-
if (!attributes) return;
|
|
471
|
-
var label = [],
|
|
472
|
-
field = {};
|
|
473
|
-
for (var key in attributes) {
|
|
474
|
-
field = {};
|
|
475
|
-
field[key] = attributes[key];
|
|
476
|
-
label.push(field);
|
|
477
|
-
}
|
|
478
|
-
return label;
|
|
479
|
-
};
|
|
480
|
-
this.drawParts = function (options, data, callback) {
|
|
481
|
-
var self = this;
|
|
482
|
-
function showParts(data) {
|
|
483
|
-
var drawParam = options.drawParam || {};
|
|
484
|
-
var ctrOption = drawParam.clusterOption;
|
|
485
|
-
var zoom = options.zoom === undefined ? true : !!options.zoom;
|
|
486
|
-
var clusterOption = null;
|
|
487
|
-
if (ctrOption) {
|
|
488
|
-
clusterOption = {
|
|
489
|
-
clusterType: ctrOption.clusterType,
|
|
490
|
-
level: ctrOption.level || 0,
|
|
491
|
-
style: {
|
|
492
|
-
type: 'simple-marker',
|
|
493
|
-
style: 'circle',
|
|
494
|
-
color: ctrOption.color || [255, 0, 0, 0.6],
|
|
495
|
-
size: ctrOption.size || 20,
|
|
496
|
-
outline: {
|
|
497
|
-
//if outline has been specified
|
|
498
|
-
color: ctrOption.outlineColor || [255, 168, 0, 1],
|
|
499
|
-
width: ctrOption.outlineWidth || 2,
|
|
500
|
-
},
|
|
501
|
-
},
|
|
502
|
-
labelStyle: {
|
|
503
|
-
type: 'text',
|
|
504
|
-
color: ctrOption.labelColor || [255, 255, 255, 1],
|
|
505
|
-
text: '',
|
|
506
|
-
zlevel: ctrOption.labelZlevel || 1,
|
|
507
|
-
yoffset: 0,
|
|
508
|
-
font: ctrOption.labelFont || {
|
|
509
|
-
family: 'Arial',
|
|
510
|
-
size: 10,
|
|
511
|
-
},
|
|
512
|
-
},
|
|
513
|
-
distance: ctrOption.distance || 50,
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
var param = [
|
|
517
|
-
data,
|
|
518
|
-
zoom,
|
|
519
|
-
false,
|
|
520
|
-
null,
|
|
521
|
-
null,
|
|
522
|
-
false,
|
|
523
|
-
drawParam.tagName,
|
|
524
|
-
drawParam.clickCallback,
|
|
525
|
-
drawParam.mouseOverCallback,
|
|
526
|
-
clusterOption,
|
|
527
|
-
false,
|
|
528
|
-
drawParam.layerName,
|
|
529
|
-
drawParam.callback,
|
|
530
|
-
drawParam.drawOptions,
|
|
531
|
-
];
|
|
532
|
-
//三维聚类参数
|
|
533
|
-
var globeOptions = {
|
|
534
|
-
zoom: true,
|
|
535
|
-
scale: 0.9,
|
|
536
|
-
clear: true,
|
|
537
|
-
nearFarScalar: [8000, 1.0, 10000, 0.6],
|
|
538
|
-
clickCallBack: drawParam.clickCallback,
|
|
539
|
-
layerName: drawParam.layerName,
|
|
540
|
-
minSize: 30,
|
|
541
|
-
clusterLimit: 20,
|
|
542
|
-
style: 'default',
|
|
543
|
-
clusterImageInfo: {
|
|
544
|
-
horizontalOrigin: 'center',
|
|
545
|
-
verticalOrigin: 'bottom',
|
|
546
|
-
cssStyle: {
|
|
547
|
-
borderRadius: 500,
|
|
548
|
-
fillColor: 'rgba(0,0,0,0.7)',
|
|
549
|
-
borderLineWidth: 3,
|
|
550
|
-
borderLineColor: 'rgba(250,140,0,0.9)',
|
|
551
|
-
paddingX: 15,
|
|
552
|
-
paddingY: 6,
|
|
553
|
-
marginBottom: 2,
|
|
554
|
-
},
|
|
555
|
-
textStyle: {
|
|
556
|
-
font: '60px Helvetica',
|
|
557
|
-
fillColor: 'rgba(220,220,220,1.0)',
|
|
558
|
-
outlineColor: 'black',
|
|
559
|
-
outlineWidth: 1,
|
|
560
|
-
padding: 1,
|
|
561
|
-
textScale: 0.5,
|
|
562
|
-
textStartX: 40,
|
|
563
|
-
textStartY: 15,
|
|
564
|
-
},
|
|
565
|
-
},
|
|
566
|
-
};
|
|
567
|
-
if (globeMap) {
|
|
568
|
-
globeMap.addClusterLayer({
|
|
569
|
-
data,
|
|
570
|
-
options: globeOptions,
|
|
571
|
-
});
|
|
572
|
-
} else if (gisMap) {
|
|
573
|
-
gisMap.showMultiObjectCurrentPosition(...param);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
if (data) {
|
|
578
|
-
showParts(data);
|
|
579
|
-
} else {
|
|
580
|
-
let queryFromGIS = () => {
|
|
581
|
-
let queryParam = options.queryParam;
|
|
582
|
-
var subTypeName = options.subTypeName;
|
|
583
|
-
var subUniqueCode = options.subUniqueCode;
|
|
584
|
-
let queryCallback = function (featureInfos) {
|
|
585
|
-
var features = featureInfos[queryParam.phyLayerIDs];
|
|
586
|
-
if (features.length == 0) {
|
|
587
|
-
callback && callback([]);
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
if (!features || !features.length) return;
|
|
591
|
-
var symbolUrl = '';
|
|
592
|
-
if (subUniqueCode.indexOf('http') > -1) {
|
|
593
|
-
symbolUrl = subUniqueCode;
|
|
594
|
-
} else if (subUniqueCode.indexOf('.') > -1) {
|
|
595
|
-
symbolUrl = subUniqueCode;
|
|
596
|
-
} else {
|
|
597
|
-
symbolUrl = ''.concat(subUniqueCode, '.png');
|
|
598
|
-
if (globeMap)
|
|
599
|
-
symbolUrl = queryParam.gisServerURL
|
|
600
|
-
? `${queryParam.gisServerURL}/symbol/${symbolUrl}`
|
|
601
|
-
: symbolUrl;
|
|
602
|
-
}
|
|
603
|
-
var map = globeMap || gisMap;
|
|
604
|
-
//验证图标是否可查询
|
|
605
|
-
map.getMapConfig('serverURL', function (key, data) {
|
|
606
|
-
var symbolServiceURL = `${data}/symbol`;
|
|
607
|
-
var picUrl =
|
|
608
|
-
symbolUrl.indexOf('http') > -1 ||
|
|
609
|
-
symbolUrl.indexOf('https') > -1
|
|
610
|
-
? symbolUrl
|
|
611
|
-
: `${symbolServiceURL}/${symbolUrl}`;
|
|
612
|
-
getImgSize(picUrl).then((size) => {
|
|
613
|
-
var dataList = features.map(function (feature) {
|
|
614
|
-
return Object.assign(
|
|
615
|
-
{},
|
|
616
|
-
{
|
|
617
|
-
x: feature.geometry.x,
|
|
618
|
-
y: feature.geometry.y,
|
|
619
|
-
},
|
|
620
|
-
{
|
|
621
|
-
attributes: feature.attributes,
|
|
622
|
-
// label:self.getLabel(feature.attributes), //去除内部弹框的可能性
|
|
623
|
-
symbolType: -1,
|
|
624
|
-
symbolUrl:
|
|
625
|
-
size.width || size.height
|
|
626
|
-
? picUrl
|
|
627
|
-
: globeMap
|
|
628
|
-
? `${symbolServiceURL}/20100.png`
|
|
629
|
-
: `20100.png`,
|
|
630
|
-
scale: 0.5,
|
|
631
|
-
}
|
|
632
|
-
);
|
|
633
|
-
});
|
|
634
|
-
callback && callback(dataList);
|
|
635
|
-
if (!options.onlyGetData) {
|
|
636
|
-
showParts(dataList);
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
});
|
|
640
|
-
};
|
|
641
|
-
if (gisMap) {
|
|
642
|
-
gisMap.queryPhylayerFeatures(queryParam, queryCallback);
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
queryFromGIS();
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
this.drawOtherParts = function (options, data) {
|
|
650
|
-
const geomType = options.geomType;
|
|
651
|
-
if (globeMap && geomType != 1) {
|
|
652
|
-
this.drawOtherPartsGlobe(options, data);
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
var self = this;
|
|
657
|
-
let queryParam = options.queryParam || {};
|
|
658
|
-
function showParts(data) {}
|
|
659
|
-
|
|
660
|
-
if (data) {
|
|
661
|
-
showParts(data);
|
|
662
|
-
} else {
|
|
663
|
-
const layerID = queryParam.phyLayerIDs;
|
|
664
|
-
const layerName = queryParam.layerName;
|
|
665
|
-
const keyField = null;
|
|
666
|
-
const keyValue = null;
|
|
667
|
-
const clearMap = queryParam.clearMap;
|
|
668
|
-
let inStyle = queryParam.style || {
|
|
669
|
-
color: 'blue',
|
|
670
|
-
};
|
|
671
|
-
let inHStyle = queryParam.hStyle || {
|
|
672
|
-
color: 'blue',
|
|
673
|
-
};
|
|
674
|
-
let style = null,
|
|
675
|
-
hStyle = null;
|
|
676
|
-
if (geomType == 1) {
|
|
677
|
-
} else if (geomType == 2) {
|
|
678
|
-
style = {
|
|
679
|
-
type: 'simple-line', // autocasts as new SimpleLineSymbol()
|
|
680
|
-
color: inStyle.color || 'blue',
|
|
681
|
-
width: inStyle.width || '2px',
|
|
682
|
-
style: inStyle.style || 'solid',
|
|
683
|
-
cap: inStyle.cap || 'round',
|
|
684
|
-
join: inStyle.join || 'round',
|
|
685
|
-
};
|
|
686
|
-
hStyle = {
|
|
687
|
-
type: 'simple-line', // autocasts as new SimpleLineSymbol()
|
|
688
|
-
color: inHStyle.color || 'red',
|
|
689
|
-
width: inHStyle.width || inStyle.width || '2px',
|
|
690
|
-
style: inHStyle.style || inStyle.style || 'solid',
|
|
691
|
-
cap: inHStyle.cap || inStyle.cap || 'round',
|
|
692
|
-
join: inHStyle.join || inStyle.join || 'round',
|
|
693
|
-
};
|
|
694
|
-
} else if (geomType == 3) {
|
|
695
|
-
style = {
|
|
696
|
-
type: 'simple-fill', // autocasts as new SimpleFillSymbol()
|
|
697
|
-
color: inStyle.color || [51, 51, 204, 0.9],
|
|
698
|
-
style: inStyle.style || 'solid',
|
|
699
|
-
outline: {
|
|
700
|
-
// autocasts as new SimpleLineSymbol()
|
|
701
|
-
color: inStyle.outlineColor || 'blue',
|
|
702
|
-
width: inStyle.outlineWidth || '1px',
|
|
703
|
-
style: inStyle.outlineStyle || 'solid',
|
|
704
|
-
cap: inStyle.outlineCap || 'round',
|
|
705
|
-
join: inStyle.outlineJoin || 'round',
|
|
706
|
-
},
|
|
707
|
-
};
|
|
708
|
-
hStyle = {
|
|
709
|
-
type: 'simple-fill', // autocasts as new SimpleFillSymbol()
|
|
710
|
-
color: inHStyle.color || [51, 51, 204, 0.9],
|
|
711
|
-
style: inHStyle.style || inStyle.style || 'solid',
|
|
712
|
-
outline: {
|
|
713
|
-
// autocasts as new SimpleLineSymbol()
|
|
714
|
-
color: inHStyle.outlineColor || 'red',
|
|
715
|
-
width:
|
|
716
|
-
inHStyle.outlineWidth ||
|
|
717
|
-
inStyle.outlineWidth ||
|
|
718
|
-
'1px',
|
|
719
|
-
style:
|
|
720
|
-
inHStyle.outlineStyle ||
|
|
721
|
-
inStyle.outlineStyle ||
|
|
722
|
-
'solid',
|
|
723
|
-
cap:
|
|
724
|
-
inHStyle.outlineCap ||
|
|
725
|
-
inStyle.outlineCap ||
|
|
726
|
-
'round',
|
|
727
|
-
join:
|
|
728
|
-
inHStyle.outlineJoin ||
|
|
729
|
-
inStyle.outlineJoin ||
|
|
730
|
-
'round',
|
|
731
|
-
},
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
const bZoom = queryParam.bZoom || true;
|
|
735
|
-
const randomColor = null;
|
|
736
|
-
const labelField = null;
|
|
737
|
-
const labelstyle = null;
|
|
738
|
-
const geometry = null;
|
|
739
|
-
const where = queryParam.where || '1=1';
|
|
740
|
-
const opts = {
|
|
741
|
-
...queryParam.options,
|
|
742
|
-
layerId: layerName,
|
|
743
|
-
mouseOverCallback: queryParam.mouseOverCallback,
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
let param = [
|
|
747
|
-
layerID,
|
|
748
|
-
keyField,
|
|
749
|
-
keyValue,
|
|
750
|
-
clearMap,
|
|
751
|
-
style,
|
|
752
|
-
hStyle,
|
|
753
|
-
bZoom,
|
|
754
|
-
randomColor,
|
|
755
|
-
labelField,
|
|
756
|
-
labelstyle,
|
|
757
|
-
geometry,
|
|
758
|
-
where,
|
|
759
|
-
null,
|
|
760
|
-
null,
|
|
761
|
-
opts,
|
|
762
|
-
null,
|
|
763
|
-
null,
|
|
764
|
-
null,
|
|
765
|
-
null,
|
|
766
|
-
null,
|
|
767
|
-
null,
|
|
768
|
-
queryParam.clickCallback,
|
|
769
|
-
];
|
|
770
|
-
//let param = [layerID, keyField, keyValue, clearMap, style, hStyle, bZoom, randomColor, labelField, labelstyle, geometry, where, null, null, opts, null, null, null, null, queryParam.callback];
|
|
771
|
-
if (globeMap) {
|
|
772
|
-
gisMap.locateFeatureByIDs(...param);
|
|
773
|
-
} else if (gisMap) {
|
|
774
|
-
gisMap.locateFeatureByIDs(...param);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
|
|
779
|
-
this.drawOtherPartsGlobe = function (options, data) {
|
|
780
|
-
const geomType = options.geomType;
|
|
781
|
-
const drawParam = options.drawParam || {};
|
|
782
|
-
const color = drawParam.color || 'rgba(255, 0.0, 0.0, 0.8)';
|
|
783
|
-
const clickColor = drawParam.clickColor || 'rgba(255, 255, 0.0, 0.8)';
|
|
784
|
-
function showParts(features) {
|
|
785
|
-
if (!globeMap) {
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
if (geomType == 2) {
|
|
790
|
-
var infoJson = features.map((feature) => {
|
|
791
|
-
var paths = feature.geometry.paths[0];
|
|
792
|
-
var positions = paths.map((position) => {
|
|
793
|
-
return {
|
|
794
|
-
x: position[0],
|
|
795
|
-
y: position[1],
|
|
796
|
-
};
|
|
797
|
-
});
|
|
798
|
-
return {
|
|
799
|
-
positions,
|
|
800
|
-
type: 'color',
|
|
801
|
-
color: color,
|
|
802
|
-
width: 2,
|
|
803
|
-
attributes: feature.attributes,
|
|
804
|
-
};
|
|
805
|
-
});
|
|
806
|
-
|
|
807
|
-
var zoom = true;
|
|
808
|
-
var clear = true;
|
|
809
|
-
var layerName = drawParam.layerName;
|
|
810
|
-
var options = {
|
|
811
|
-
heading: 0,
|
|
812
|
-
pitch: -90,
|
|
813
|
-
range: null,
|
|
814
|
-
minZoom: 0,
|
|
815
|
-
maxZoom: 100,
|
|
816
|
-
clickColor: clickColor,
|
|
817
|
-
clickWidth: 5,
|
|
818
|
-
bloom: false,
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
globeMap.showPolyline(
|
|
822
|
-
infoJson,
|
|
823
|
-
zoom,
|
|
824
|
-
clear,
|
|
825
|
-
options,
|
|
826
|
-
layerName,
|
|
827
|
-
drawParam.clickCallback
|
|
828
|
-
);
|
|
829
|
-
} else if (geomType == 3) {
|
|
830
|
-
var infoJson = features.map((feature) => {
|
|
831
|
-
var rings = feature.geometry.rings[0];
|
|
832
|
-
var positions = rings.map((position) => {
|
|
833
|
-
return {
|
|
834
|
-
x: position[0],
|
|
835
|
-
y: position[1],
|
|
836
|
-
};
|
|
837
|
-
});
|
|
838
|
-
|
|
839
|
-
return {
|
|
840
|
-
positions,
|
|
841
|
-
type: 'polygon',
|
|
842
|
-
colorType: 'color',
|
|
843
|
-
color: color,
|
|
844
|
-
attributes: feature.attributes,
|
|
845
|
-
};
|
|
846
|
-
});
|
|
847
|
-
|
|
848
|
-
var zoom = true;
|
|
849
|
-
var clear = true;
|
|
850
|
-
var layerName = drawParam.layerName;
|
|
851
|
-
var drawWay = 'entityWay';
|
|
852
|
-
var options = {
|
|
853
|
-
heading: 0,
|
|
854
|
-
pitch: -90,
|
|
855
|
-
range: null,
|
|
856
|
-
minZoom: 0,
|
|
857
|
-
maxZoom: 24,
|
|
858
|
-
clickColor: clickColor,
|
|
859
|
-
clickWidth: 15,
|
|
860
|
-
heightAnimation: false,
|
|
861
|
-
};
|
|
862
|
-
globeMap.showPolygon(
|
|
863
|
-
infoJson,
|
|
864
|
-
drawWay,
|
|
865
|
-
zoom,
|
|
866
|
-
clear,
|
|
867
|
-
options,
|
|
868
|
-
layerName,
|
|
869
|
-
drawParam.clickCallback
|
|
870
|
-
);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
if (data) {
|
|
875
|
-
showParts(data);
|
|
876
|
-
} else {
|
|
877
|
-
let queryFromGIS = () => {
|
|
878
|
-
let queryParam = options.queryParam;
|
|
879
|
-
let queryCallback = function (featureInfos) {
|
|
880
|
-
var features = featureInfos[queryParam.phyLayerIDs];
|
|
881
|
-
if (!features || !features.length) return;
|
|
882
|
-
showParts(features);
|
|
883
|
-
};
|
|
884
|
-
if (gisMap) {
|
|
885
|
-
gisMap.queryPhylayerFeatures(queryParam, queryCallback);
|
|
886
|
-
}
|
|
887
|
-
};
|
|
888
|
-
queryFromGIS();
|
|
889
|
-
}
|
|
890
|
-
};
|
|
891
|
-
|
|
892
|
-
/*
|
|
893
|
-
* @description:新的轨迹线接口
|
|
894
|
-
* @method traceOperation
|
|
895
|
-
* @param {Array} posArr 位置数组
|
|
896
|
-
* @param {Object} options 配置项
|
|
897
|
-
*
|
|
898
|
-
* @return {Void} 无返回
|
|
899
|
-
*
|
|
900
|
-
* @author: Hetianhong
|
|
901
|
-
* @date: 2021-09-09 14:49:49
|
|
902
|
-
*/
|
|
903
|
-
this.traceOperation = function (posArr, options) {
|
|
904
|
-
globeMap.traceOperation(posArr, options);
|
|
905
|
-
};
|
|
906
|
-
/*
|
|
907
|
-
* @description:网格接口
|
|
908
|
-
* 先查询idb的data,没有的话,再查询queryFeature的data
|
|
909
|
-
* @method regionOperation
|
|
910
|
-
* @param {Object} options 配置项
|
|
911
|
-
* @param {Array} data 数据,可不传
|
|
912
|
-
*
|
|
913
|
-
* @return {Void} 无返回
|
|
914
|
-
*
|
|
915
|
-
* @author: Hetianhong
|
|
916
|
-
* @date: 2021-10-19 17:27:02
|
|
917
|
-
*/
|
|
918
|
-
this.regionOperation = function (options, data, callback, dataLoadCb) {
|
|
919
|
-
function execOperation(data) {
|
|
920
|
-
if (globeMap) {
|
|
921
|
-
globeMap.regionOperation(options, data);
|
|
922
|
-
callback && callback();
|
|
923
|
-
} else if (gisMap) {
|
|
924
|
-
gridPolygon2dOperation(options, data, callback, dataLoadCb);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
if (data) {
|
|
929
|
-
execOperation(data);
|
|
930
|
-
} else {
|
|
931
|
-
if (!options.idbSetting.usageID) {
|
|
932
|
-
return;
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
let storeName = !!globeMap
|
|
936
|
-
? 'usageID'
|
|
937
|
-
: 'usage2D' + '_' + options.idbSetting.usageID;
|
|
938
|
-
let queryFromGIS = () => {
|
|
939
|
-
let filterString = options.idbSetting.filterString || '1=1';
|
|
940
|
-
let queryParam = {
|
|
941
|
-
layerID: options.idbSetting.usageID,
|
|
942
|
-
where: filterString,
|
|
943
|
-
geometry: '',
|
|
944
|
-
outGeometry: true,
|
|
945
|
-
options: {
|
|
946
|
-
originalData: true,
|
|
947
|
-
},
|
|
948
|
-
};
|
|
949
|
-
//二维地图不获取原始数据
|
|
950
|
-
if (!globeMap) queryParam.options.originalData = false;
|
|
951
|
-
let queryCallback = function (featureInfos) {
|
|
952
|
-
execOperation(featureInfos);
|
|
953
|
-
};
|
|
954
|
-
if (gisMap) {
|
|
955
|
-
gisMap.queryFeature(queryParam, queryCallback);
|
|
956
|
-
}
|
|
957
|
-
};
|
|
958
|
-
|
|
959
|
-
if (!options.idbSetting.enabled) {
|
|
960
|
-
// 直接查询
|
|
961
|
-
queryFromGIS();
|
|
962
|
-
} else {
|
|
963
|
-
// 查询是否存在表
|
|
964
|
-
checkObjectStore(storeName).then(function (hasObjStore) {
|
|
965
|
-
if (hasObjStore) {
|
|
966
|
-
// 如果有,读取本地
|
|
967
|
-
execOperation();
|
|
968
|
-
} else {
|
|
969
|
-
// 如果没有,查询queryFeature
|
|
970
|
-
queryFromGIS();
|
|
971
|
-
}
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
};
|
|
976
|
-
this.cancelHighlightedRegion = function (layerName) {
|
|
977
|
-
globeMap.cancelHighlightedRegion(layerName);
|
|
978
|
-
};
|
|
979
|
-
/*
|
|
980
|
-
* @description:新参数格式的旧线接口,主要用来做中间层参数格式转换
|
|
981
|
-
* @method showPolyline_BI
|
|
982
|
-
* @param {参数类型} 参数名 参数说明
|
|
983
|
-
*
|
|
984
|
-
* @return {返回值类型} 返回值说明
|
|
985
|
-
*
|
|
986
|
-
* @author: Hetianhong
|
|
987
|
-
* @date: 2021-11-11 15:40:31
|
|
988
|
-
*/
|
|
989
|
-
this.showPolyline_BI = function (layerName, positions = [], options = {}) {
|
|
990
|
-
if (globeMap !== null) {
|
|
991
|
-
// 默认参数
|
|
992
|
-
let defaultOpt = {
|
|
993
|
-
// 样式类
|
|
994
|
-
styleOpt: {
|
|
995
|
-
period: 4, // 动画线段的周期,越短越快
|
|
996
|
-
image: 'road.png', // type为image时线段所使用的纹理图案,位置在data3d/polyline/目录下(type为image限定)
|
|
997
|
-
repeatX: 2, // 横向纹理重复,越大则越密(type为image限定)
|
|
998
|
-
repeatY: 1, //纵向纹理重复(type为image限定)
|
|
999
|
-
glowPower: 0, //中心亮度
|
|
1000
|
-
intensity: 1.2, //纹理图片颜色强度
|
|
1001
|
-
gapColor: 'rgba(0, 0, 0, 0)', //间隙颜色(type为dash限定)
|
|
1002
|
-
dashLength: 15, //间隙宽(type为dash限定)
|
|
1003
|
-
outlineWidth: 0, // 边框线宽(type为outline限定)
|
|
1004
|
-
outlineColor: 'rgba(0, 0, 0, 0)', // 边框颜色(type为outline限定)
|
|
1005
|
-
type: 'color', // 线条类型,有 image color dash outline glow
|
|
1006
|
-
width: 10,
|
|
1007
|
-
color: 'rgba(255,255,0,1)',
|
|
1008
|
-
},
|
|
1009
|
-
// 视角缩放类
|
|
1010
|
-
zoomOpt: {
|
|
1011
|
-
//zoom参数
|
|
1012
|
-
heading: 0,
|
|
1013
|
-
pitch: -90,
|
|
1014
|
-
range: null,
|
|
1015
|
-
//可视级别
|
|
1016
|
-
minZoom: 0,
|
|
1017
|
-
maxZoom: 24,
|
|
1018
|
-
//泛光绘制
|
|
1019
|
-
// 下面两项,不暴露,全部为false
|
|
1020
|
-
bloom: false,
|
|
1021
|
-
merge: false,
|
|
1022
|
-
},
|
|
1023
|
-
// 交互类
|
|
1024
|
-
interactOpt: {
|
|
1025
|
-
//click相关
|
|
1026
|
-
clickColor: 'rgb(255, 255, 0.0)', // 点击后的颜色
|
|
1027
|
-
clickWidth: 30, // 点击后的宽度
|
|
1028
|
-
clickCallback: undefined, // function(e) {console.log('click polyline', e)},
|
|
1029
|
-
mouseOverCallBack: undefined,
|
|
1030
|
-
},
|
|
1031
|
-
};
|
|
1032
|
-
let getMergedOptions = (options) => {
|
|
1033
|
-
let mergedOptions = {};
|
|
1034
|
-
mergedOptions.styleOpt = Object.assign(
|
|
1035
|
-
{},
|
|
1036
|
-
defaultOpt.styleOpt,
|
|
1037
|
-
options.styleOpt
|
|
1038
|
-
);
|
|
1039
|
-
mergedOptions.zoomOpt = Object.assign(
|
|
1040
|
-
{},
|
|
1041
|
-
defaultOpt.zoomOpt,
|
|
1042
|
-
options.zoomOpt
|
|
1043
|
-
);
|
|
1044
|
-
mergedOptions.interactOpt = Object.assign(
|
|
1045
|
-
{},
|
|
1046
|
-
defaultOpt.interactOpt,
|
|
1047
|
-
options.interactOpt
|
|
1048
|
-
);
|
|
1049
|
-
return mergedOptions;
|
|
1050
|
-
};
|
|
1051
|
-
let mergedOptions = getMergedOptions(options);
|
|
1052
|
-
|
|
1053
|
-
let opt = {};
|
|
1054
|
-
// let styleOpt = options.styleOpt;
|
|
1055
|
-
// let zoomOpt = options.zoomOpt;
|
|
1056
|
-
// let interactOpt = options.interactOpt;
|
|
1057
|
-
//hth 此处进行参数转换
|
|
1058
|
-
switch (mergedOptions.styleOpt.type) {
|
|
1059
|
-
case 'image':
|
|
1060
|
-
opt.period = defaultValue(mergedOptions.styleOpt.period, 4); // 纹理流动周期,越小越快
|
|
1061
|
-
opt.image = defaultValue(
|
|
1062
|
-
mergedOptions.styleOpt.image,
|
|
1063
|
-
'road.png'
|
|
1064
|
-
); //纹理图片,data3d/polyline/目录下
|
|
1065
|
-
opt.repeatX = defaultValue(
|
|
1066
|
-
mergedOptions.styleOpt.repeatX,
|
|
1067
|
-
2
|
|
1068
|
-
); //横向纹理重复,越大越密
|
|
1069
|
-
opt.repeatY = defaultValue(
|
|
1070
|
-
mergedOptions.styleOpt.repeatY,
|
|
1071
|
-
1
|
|
1072
|
-
); //纵向纹理重复
|
|
1073
|
-
opt.glowPower = defaultValue(
|
|
1074
|
-
mergedOptions.styleOpt.glowPower,
|
|
1075
|
-
0
|
|
1076
|
-
); //中心亮度
|
|
1077
|
-
opt.intensity = defaultValue(
|
|
1078
|
-
mergedOptions.styleOpt.intensity,
|
|
1079
|
-
1.2
|
|
1080
|
-
); //纹理图片颜色强度
|
|
1081
|
-
break;
|
|
1082
|
-
case 'glow':
|
|
1083
|
-
opt.glowPower = defaultValue(
|
|
1084
|
-
mergedOptions.styleOpt.glowPower,
|
|
1085
|
-
0.2
|
|
1086
|
-
); //中心亮度
|
|
1087
|
-
break;
|
|
1088
|
-
case 'dash':
|
|
1089
|
-
opt.gapColor = defaultValue(
|
|
1090
|
-
mergedOptions.styleOpt.gapColor,
|
|
1091
|
-
'rgba(0, 0, 0, 0)'
|
|
1092
|
-
); //间隙颜色
|
|
1093
|
-
opt.dashLength = defaultValue(
|
|
1094
|
-
mergedOptions.styleOpt.dashLength,
|
|
1095
|
-
15
|
|
1096
|
-
); //间隙宽
|
|
1097
|
-
break;
|
|
1098
|
-
case 'outline':
|
|
1099
|
-
opt.outlineWidth = defaultValue(
|
|
1100
|
-
mergedOptions.styleOpt.outlineWidth,
|
|
1101
|
-
0
|
|
1102
|
-
);
|
|
1103
|
-
opt.outlineColor = defaultValue(
|
|
1104
|
-
mergedOptions.styleOpt.outlineColor,
|
|
1105
|
-
'rgba(0, 0, 0, 0)'
|
|
1106
|
-
);
|
|
1107
|
-
break;
|
|
1108
|
-
default:
|
|
1109
|
-
// color
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
opt.type = mergedOptions.styleOpt.type;
|
|
1113
|
-
opt.width = mergedOptions.styleOpt.width;
|
|
1114
|
-
opt.color = mergedOptions.styleOpt.color;
|
|
1115
|
-
|
|
1116
|
-
// 遍历位置数组中的每一项
|
|
1117
|
-
for (let pos of positions) {
|
|
1118
|
-
// 遍历opt中每一个key赋值到每一个pos中
|
|
1119
|
-
for (let k in opt) {
|
|
1120
|
-
pos[k] = opt[k];
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
let zoom = mergedOptions.zoomOpt.zoom;
|
|
1125
|
-
let clear = mergedOptions.zoomOpt.clear;
|
|
1126
|
-
let clickCallback = mergedOptions.interactOpt.clickCallback;
|
|
1127
|
-
let mouseOverCallBack = mergedOptions.interactOpt.mouseOverCallBack;
|
|
1128
|
-
let commonOpt = {
|
|
1129
|
-
//zoom参数
|
|
1130
|
-
heading: mergedOptions.zoomOpt.heading,
|
|
1131
|
-
pitch: mergedOptions.zoomOpt.pitch,
|
|
1132
|
-
range: mergedOptions.zoomOpt.range,
|
|
1133
|
-
//可视级别
|
|
1134
|
-
minZoom: mergedOptions.zoomOpt.minZoom,
|
|
1135
|
-
maxZoom: mergedOptions.zoomOpt.maxZoom,
|
|
1136
|
-
//click相关
|
|
1137
|
-
clickColor: mergedOptions.interactOpt.clickColor, // 点击后的颜色
|
|
1138
|
-
clickWidth: mergedOptions.interactOpt.clickWidth, // 点击后的宽度
|
|
1139
|
-
//泛光绘制
|
|
1140
|
-
// 下面两项,不暴露,全部为false
|
|
1141
|
-
bloom: false,
|
|
1142
|
-
merge: false,
|
|
1143
|
-
};
|
|
1144
|
-
|
|
1145
|
-
globeMap.showPolyline(
|
|
1146
|
-
positions,
|
|
1147
|
-
zoom,
|
|
1148
|
-
clear,
|
|
1149
|
-
commonOpt,
|
|
1150
|
-
layerName,
|
|
1151
|
-
clickCallback,
|
|
1152
|
-
mouseOverCallBack
|
|
1153
|
-
);
|
|
1154
|
-
}
|
|
1155
|
-
};
|
|
1156
|
-
/*
|
|
1157
|
-
* @description:被动触发图层类似点击效果,需要在图层内在单独定义Event
|
|
1158
|
-
* @method activeLayer
|
|
1159
|
-
* @param {String} layerName 图层名
|
|
1160
|
-
* @param {Object} options 配置项
|
|
1161
|
-
* @param {String} options.type 操作类型,'clear', 'active'
|
|
1162
|
-
* @param {Boolean} options.zoom 是否缩放
|
|
1163
|
-
* @param {Object} filter 过滤项
|
|
1164
|
-
* @param {String} filter.keyFieldName 过滤键名
|
|
1165
|
-
* @param {Array} filter.values 过滤值内容数组
|
|
1166
|
-
*
|
|
1167
|
-
* @return {返回值类型} 返回值说明
|
|
1168
|
-
*dataLoadCb:加载状态函数
|
|
1169
|
-
* @author: Hetianhong
|
|
1170
|
-
* @date: 2021-11-26 09:49:16
|
|
1171
|
-
*/
|
|
1172
|
-
this.activeLayer = function (layerName, options, filter) {
|
|
1173
|
-
if (globeMap != null && mapType == 'globe') {
|
|
1174
|
-
globeMap.activeLayer(layerName, options, filter);
|
|
1175
|
-
}
|
|
1176
|
-
if (gisMap != null && mapType == 'map') {
|
|
1177
|
-
gisMap.activeLayer(layerName, options, filter);
|
|
1178
|
-
}
|
|
1179
|
-
};
|
|
1180
|
-
|
|
1181
|
-
this.deActiveLayer = function (layerName, filter) {
|
|
1182
|
-
if (gisMap != null && mapType == 'map') {
|
|
1183
|
-
gisMap.deActiveLayer(layerName, filter);
|
|
1184
|
-
}
|
|
1185
|
-
};
|
|
1186
|
-
|
|
1187
|
-
function gridPolygon2dOperation(options, data, callback, dataLoadCb) {
|
|
1188
|
-
var storeName = `usage2D_${options.idbSetting.usageID}`;
|
|
1189
|
-
function showGrid(realData) {
|
|
1190
|
-
// 转换一下
|
|
1191
|
-
var geometries = [];
|
|
1192
|
-
var extraGeometries = [];
|
|
1193
|
-
var specialAreaS = options.specialAreaS; //玲珑平台分类设色
|
|
1194
|
-
for (var i = 0; i < realData.length; i++) {
|
|
1195
|
-
var feature = realData[i];
|
|
1196
|
-
var geom = feature.geometry;
|
|
1197
|
-
geom.attributes = feature.attributes; // attributes会导致id没用,使用自带的id
|
|
1198
|
-
var hasPush = false;
|
|
1199
|
-
if (specialAreaS && specialAreaS.length > 0) {
|
|
1200
|
-
for (var j = 0; j < specialAreaS.length; j++) {
|
|
1201
|
-
var specialArea = specialAreaS[j];
|
|
1202
|
-
if (!specialArea.geometries) {
|
|
1203
|
-
specialArea.geometries = [];
|
|
1204
|
-
}
|
|
1205
|
-
var attributes = JSON.parse(
|
|
1206
|
-
JSON.stringify(feature.attributes)
|
|
1207
|
-
);
|
|
1208
|
-
let filterResult = new Function(
|
|
1209
|
-
`return ${specialArea.statusControl.compiled}`
|
|
1210
|
-
)().call(null, attributes);
|
|
1211
|
-
if (filterResult == true) {
|
|
1212
|
-
specialArea.geometries.push(geom);
|
|
1213
|
-
hasPush = true;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
!hasPush && geometries.push(geom);
|
|
1218
|
-
}
|
|
1219
|
-
if (
|
|
1220
|
-
options.specialArea &&
|
|
1221
|
-
options.selectedSetting.selected.length
|
|
1222
|
-
) {
|
|
1223
|
-
var extraIds = options.selectedSetting.selected.map(
|
|
1224
|
-
(s) => s.selectID
|
|
1225
|
-
);
|
|
1226
|
-
for (var i = geometries.length - 1; i > -1; i--) {
|
|
1227
|
-
var geom = geometries[i];
|
|
1228
|
-
if (
|
|
1229
|
-
extraIds.indexOf(
|
|
1230
|
-
geom.attributes[options.keyFieldName]
|
|
1231
|
-
) > -1
|
|
1232
|
-
) {
|
|
1233
|
-
geometries.splice(i, 1);
|
|
1234
|
-
extraGeometries.push(geom);
|
|
1235
|
-
if (extraGeometries.length === extraIds.length) break;
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
var color = options.customColor
|
|
1240
|
-
? interpolateColor(
|
|
1241
|
-
options.customColor[0],
|
|
1242
|
-
options.customColor[1],
|
|
1243
|
-
Math.min(geometries.length, 10)
|
|
1244
|
-
)
|
|
1245
|
-
: 10;
|
|
1246
|
-
if (options.setFieldColor && options.layeredColor) {
|
|
1247
|
-
var colorConfig = options.layeredColor(geometries);
|
|
1248
|
-
geometries = colorConfig.data;
|
|
1249
|
-
color = colorConfig.color;
|
|
1250
|
-
}
|
|
1251
|
-
var lfcOpt = {
|
|
1252
|
-
minZoom: options.visiblitySetting.beginLevel,
|
|
1253
|
-
maxZoom: options.visiblitySetting.endLevel,
|
|
1254
|
-
layerId: options.layerName,
|
|
1255
|
-
comCallbak: callback,
|
|
1256
|
-
order: options.order,
|
|
1257
|
-
inverse: options.inverse,
|
|
1258
|
-
...options.option, // option的其他参数
|
|
1259
|
-
};
|
|
1260
|
-
if (options.labelSetting.labelZoomEnabled == 'show') {
|
|
1261
|
-
lfcOpt.labelMinZoom = options.labelSetting.labelMinZoom;
|
|
1262
|
-
lfcOpt.labelMaxZoom = options.labelSetting.labelMaxZoom;
|
|
1263
|
-
}
|
|
1264
|
-
gisMap.locateFeatureByCoords(
|
|
1265
|
-
geometries,
|
|
1266
|
-
'polygon',
|
|
1267
|
-
options.layerName, // id,如果已经有attributes就没用了
|
|
1268
|
-
options.style, // style
|
|
1269
|
-
options.highlightStyle, // highlightStyle
|
|
1270
|
-
options.commonSetting.zoom, // zoom
|
|
1271
|
-
options.keyFieldName,
|
|
1272
|
-
options.labelSetting.showLabel && options.labelFieldName, // keyField, labelField
|
|
1273
|
-
options.labelStyle, // labelStyle
|
|
1274
|
-
color,
|
|
1275
|
-
false, // renderCanvas
|
|
1276
|
-
true, // singleSelect
|
|
1277
|
-
lfcOpt,
|
|
1278
|
-
options.layerName, // layerTag
|
|
1279
|
-
options.eventSetting.clickCallback,
|
|
1280
|
-
options.eventSetting.mouseMoveCallback
|
|
1281
|
-
);
|
|
1282
|
-
if (extraGeometries.length) {
|
|
1283
|
-
var lfceOpt = {
|
|
1284
|
-
minZoom: options.visiblitySetting.beginLevel,
|
|
1285
|
-
maxZoom: options.visiblitySetting.endLevel,
|
|
1286
|
-
layerId: options.layerName,
|
|
1287
|
-
order: options.order,
|
|
1288
|
-
// hLabelStyle: options.hLabelStyle, // 选中文字时效果,没用
|
|
1289
|
-
};
|
|
1290
|
-
if (options.labelSetting.labelZoomEnabled == 'show') {
|
|
1291
|
-
lfceOpt.labelMinZoom = options.labelSetting.labelMinZoom;
|
|
1292
|
-
lfceOpt.labelMaxZoom = options.labelSetting.labelMaxZoom;
|
|
1293
|
-
}
|
|
1294
|
-
gisMap.locateFeatureByCoords(
|
|
1295
|
-
extraGeometries,
|
|
1296
|
-
'polygon',
|
|
1297
|
-
options.layerName, // id,如果已经有attributes就没用了
|
|
1298
|
-
options.specialAreaStyle, // style
|
|
1299
|
-
options.highlightStyle, // highlightStyle
|
|
1300
|
-
false, // zoom
|
|
1301
|
-
options.keyFieldName,
|
|
1302
|
-
options.selectedSetting.showLabel && options.labelFieldName, // keyField, labelField
|
|
1303
|
-
options.specialAreaLabelStyle, // labelStyle
|
|
1304
|
-
false, // randomColor
|
|
1305
|
-
false, // renderCanvas
|
|
1306
|
-
true, // singleSelect
|
|
1307
|
-
lfceOpt,
|
|
1308
|
-
options.layerName, // layerTag
|
|
1309
|
-
options.eventSetting.clickCallback,
|
|
1310
|
-
options.eventSetting.mouseMoveCallback
|
|
1311
|
-
);
|
|
1312
|
-
}
|
|
1313
|
-
if (specialAreaS && specialAreaS.length > 0) {
|
|
1314
|
-
var lfcsOpt = {
|
|
1315
|
-
minZoom: options.visiblitySetting.beginLevel,
|
|
1316
|
-
maxZoom: options.visiblitySetting.endLevel,
|
|
1317
|
-
layerId: options.layerName,
|
|
1318
|
-
comCallbak: callback,
|
|
1319
|
-
order: options.order,
|
|
1320
|
-
// hLabelStyle: options.hLabelStyle, // 选中文字时效果,没用
|
|
1321
|
-
};
|
|
1322
|
-
if (options.labelSetting.labelZoomEnabled == 'show') {
|
|
1323
|
-
lfcsOpt.labelMinZoom = options.labelSetting.labelMinZoom;
|
|
1324
|
-
lfcsOpt.labelMaxZoom = options.labelSetting.labelMaxZoom;
|
|
1325
|
-
}
|
|
1326
|
-
for (var j = 0; j < specialAreaS.length; j++) {
|
|
1327
|
-
var specialArea = specialAreaS[j];
|
|
1328
|
-
if (specialArea.geometries.length > 0) {
|
|
1329
|
-
gisMap.locateFeatureByCoords(
|
|
1330
|
-
specialArea.geometries,
|
|
1331
|
-
'polygon',
|
|
1332
|
-
options.layerName, // id,如果已经有attributes就没用了
|
|
1333
|
-
specialArea.style, // style
|
|
1334
|
-
options.highlightStyle, // highlightStyle
|
|
1335
|
-
options.commonSetting.zoom, // zoom
|
|
1336
|
-
options.keyFieldName,
|
|
1337
|
-
specialArea.specialAreaStyle.textLabelShowEnabled &&
|
|
1338
|
-
specialArea.specialAreaStyle.labelFieldName, // keyField, labelField
|
|
1339
|
-
specialArea.labelStyle, // labelStyle
|
|
1340
|
-
false, // randomColor
|
|
1341
|
-
false, // renderCanvas
|
|
1342
|
-
true, // singleSelect
|
|
1343
|
-
lfcsOpt,
|
|
1344
|
-
options.layerName, // layerTag
|
|
1345
|
-
options.eventSetting.clickCallback,
|
|
1346
|
-
options.eventSetting.mouseMoveCallback
|
|
1347
|
-
);
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
if (dataLoadCb) {
|
|
1352
|
-
dataLoadCb(true);
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
if (!data) {
|
|
1357
|
-
// 数据来自本地
|
|
1358
|
-
var dbOpenRequest = window.indexedDB.open('regionDB');
|
|
1359
|
-
dbOpenRequest.onsuccess = function (event) {
|
|
1360
|
-
var db = this.result;
|
|
1361
|
-
var store = db.transaction(storeName).objectStore(storeName);
|
|
1362
|
-
var request = store.getAll();
|
|
1363
|
-
request.onsuccess = function () {
|
|
1364
|
-
var features = this.result;
|
|
1365
|
-
showGrid(features);
|
|
1366
|
-
};
|
|
1367
|
-
};
|
|
1368
|
-
} else {
|
|
1369
|
-
if (data.length == 0) {
|
|
1370
|
-
if (dataLoadCb) {
|
|
1371
|
-
dataLoadCb(false);
|
|
1372
|
-
}
|
|
1373
|
-
return;
|
|
1374
|
-
}
|
|
1375
|
-
var _data = JSON.parse(JSON.stringify(data[0]));
|
|
1376
|
-
var newData = data[0];
|
|
1377
|
-
if (newData && newData.geometry) {
|
|
1378
|
-
_data = JSON.parse(JSON.stringify(data));
|
|
1379
|
-
showGrid(data);
|
|
1380
|
-
} else {
|
|
1381
|
-
showGrid(data[0]);
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
var dbRequest = window.indexedDB.open('regionDB');
|
|
1385
|
-
dbRequest.onsuccess = function () {
|
|
1386
|
-
addStore(this.result.version);
|
|
1387
|
-
};
|
|
1388
|
-
function addStore(version) {
|
|
1389
|
-
var dbOpenRequest = window.indexedDB.open(
|
|
1390
|
-
'regionDB',
|
|
1391
|
-
version + 1
|
|
1392
|
-
);
|
|
1393
|
-
dbOpenRequest.onupgradeneeded = function (event) {
|
|
1394
|
-
var db = event.target.result;
|
|
1395
|
-
if (!db.objectStoreNames.contains(storeName)) {
|
|
1396
|
-
var store = db.createObjectStore(storeName, {
|
|
1397
|
-
autoIncrement: true,
|
|
1398
|
-
});
|
|
1399
|
-
for (var i = 0; i < _data.length; i++) {
|
|
1400
|
-
store.put(_data[i]);
|
|
1401
|
-
}
|
|
1402
|
-
store.transaction.oncomplete = function () {
|
|
1403
|
-
console.log('complete');
|
|
1404
|
-
};
|
|
1405
|
-
}
|
|
1406
|
-
};
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
this.networkCloud = function (options, positions) {
|
|
1412
|
-
if (!globeMap) {
|
|
1413
|
-
return;
|
|
1414
|
-
}
|
|
1415
|
-
globeMap.networkCloud(options, positions);
|
|
1416
|
-
};
|
|
1417
|
-
this.clearNetworkCloud = function (layerNames) {
|
|
1418
|
-
if (!globeMap) {
|
|
1419
|
-
return;
|
|
1420
|
-
}
|
|
1421
|
-
globeMap.clearNetworkCloud(layerNames);
|
|
1422
|
-
};
|
|
1423
|
-
this.lineOperation = function (options, data, dataLoadCb) {
|
|
1424
|
-
if (!options || !options.layerName) {
|
|
1425
|
-
console.log('图层名必须传递');
|
|
1426
|
-
return;
|
|
1427
|
-
}
|
|
1428
|
-
// 数据获取
|
|
1429
|
-
let queryFeature = (queryParams) => {
|
|
1430
|
-
if (gisMap) {
|
|
1431
|
-
return new Promise(function (resolve) {
|
|
1432
|
-
let cb = function (result) {
|
|
1433
|
-
resolve(result);
|
|
1434
|
-
};
|
|
1435
|
-
gisMap.queryFeature(queryParams, cb);
|
|
1436
|
-
});
|
|
1437
|
-
} else {
|
|
1438
|
-
return Promise.resolve(undefined);
|
|
1439
|
-
}
|
|
1440
|
-
};
|
|
1441
|
-
// 执行绘制
|
|
1442
|
-
let drawLine = (options, data) => {
|
|
1443
|
-
if (globeMap) globeMap.lineOperation(options, data);
|
|
1444
|
-
else if (gisMap) {
|
|
1445
|
-
let style = options.style || {};
|
|
1446
|
-
let hStyle = options.hStyle || {};
|
|
1447
|
-
let symbol = {
|
|
1448
|
-
type: 'simple-line', // autocasts as new SimpleLineSymbol()
|
|
1449
|
-
color: style.color || 'lightblue',
|
|
1450
|
-
width: (style.width || 2) + 'px',
|
|
1451
|
-
style: style.style || 'short-dot',
|
|
1452
|
-
};
|
|
1453
|
-
let hsymbol = {
|
|
1454
|
-
type: 'simple-line', // autocasts as new SimpleLineSymbol()
|
|
1455
|
-
color: hStyle.color || 'lightblue',
|
|
1456
|
-
width: (hStyle.width || 2) + 'px',
|
|
1457
|
-
style: hStyle.style || 'short-dot',
|
|
1458
|
-
};
|
|
1459
|
-
var opt = options.options || {};
|
|
1460
|
-
gisMap.locateFeatureByCoords(
|
|
1461
|
-
data,
|
|
1462
|
-
options.type,
|
|
1463
|
-
options.id,
|
|
1464
|
-
symbol,
|
|
1465
|
-
hsymbol,
|
|
1466
|
-
options.zoom,
|
|
1467
|
-
options.keyField,
|
|
1468
|
-
options.labelField,
|
|
1469
|
-
options.labelStyle,
|
|
1470
|
-
options.randomColor,
|
|
1471
|
-
options.renderCanvas,
|
|
1472
|
-
options.singleSelected,
|
|
1473
|
-
opt,
|
|
1474
|
-
options.layerTag,
|
|
1475
|
-
options.callback
|
|
1476
|
-
);
|
|
1477
|
-
}
|
|
1478
|
-
};
|
|
1479
|
-
|
|
1480
|
-
// 主逻辑
|
|
1481
|
-
if (!!data && data.length) {
|
|
1482
|
-
drawLine(options, data);
|
|
1483
|
-
} else {
|
|
1484
|
-
if (!options.usageID) {
|
|
1485
|
-
console.log('图层用途必须传递');
|
|
1486
|
-
return;
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
let originalData = false;
|
|
1490
|
-
if (globeMap) originalData = true;
|
|
1491
|
-
let queryParams = {
|
|
1492
|
-
layerID: options.usageID,
|
|
1493
|
-
where: options.filterString || '1=1',
|
|
1494
|
-
geometry: '',
|
|
1495
|
-
outGeometry: true,
|
|
1496
|
-
options: { originalData: originalData },
|
|
1497
|
-
};
|
|
1498
|
-
queryFeature(queryParams).then(function (resultData) {
|
|
1499
|
-
if (dataLoadCb && typeof dataLoadCb === 'function') {
|
|
1500
|
-
dataLoadCb(resultData);
|
|
1501
|
-
}
|
|
1502
|
-
if (!resultData) {
|
|
1503
|
-
console.log('没有查询到数据,请检查查询参数');
|
|
1504
|
-
return;
|
|
1505
|
-
}
|
|
1506
|
-
drawLine(options, resultData);
|
|
1507
|
-
});
|
|
1508
|
-
}
|
|
1509
|
-
};
|
|
1510
|
-
this.enableMapEvents = function (enablePan, enableZoom, callbackArray) {
|
|
1511
|
-
if (gisMap != null && mapType == 'map') {
|
|
1512
|
-
gisMap.enableMapEvents(enablePan, enableZoom, callbackArray);
|
|
1513
|
-
}
|
|
1514
|
-
};
|
|
1515
|
-
this.setMapOpacity = function (opacity) {
|
|
1516
|
-
if (gisMap != null && mapType == 'map') {
|
|
1517
|
-
gisMap.setMapOpacity(opacity);
|
|
1518
|
-
}
|
|
1519
|
-
};
|
|
1520
|
-
|
|
1521
|
-
//地理坐标转屏幕坐标
|
|
1522
|
-
this.convertMapToScreen = function (list) {
|
|
1523
|
-
if (gisMap != null) {
|
|
1524
|
-
return gisMap.convertMapToScreen(list);
|
|
1525
|
-
}
|
|
1526
|
-
return list;
|
|
1527
|
-
};
|
|
1528
|
-
|
|
1529
|
-
// 屏幕坐标转地理坐标
|
|
1530
|
-
this.convertScreenToMap = function (list) {
|
|
1531
|
-
if (gisMap != null) {
|
|
1532
|
-
return gisMap.convertScreenToMap(list);
|
|
1533
|
-
}
|
|
1534
|
-
return list;
|
|
1535
|
-
};
|
|
1536
|
-
|
|
1537
|
-
//设置地下模式悟空
|
|
1538
|
-
this.SetTerrainAlpha = function (alpha) {
|
|
1539
|
-
if (globeMap != null) {
|
|
1540
|
-
globeMap.onUndergroundModel(alpha);
|
|
1541
|
-
}
|
|
1542
|
-
};
|
|
1543
|
-
|
|
1544
|
-
// 二维引擎下加载图层目录树中的图层接口
|
|
1545
|
-
this.setTreeLayerShow = function (options, cb) {
|
|
1546
|
-
let mapInstance;
|
|
1547
|
-
if (gisMap != null && mapType == 'map') {
|
|
1548
|
-
mapInstance = gisMap;
|
|
1549
|
-
}
|
|
1550
|
-
mapInstance.setTreeLayerShow(options, cb);
|
|
1551
|
-
};
|
|
1552
|
-
|
|
1553
|
-
// 新版通用接口
|
|
1554
|
-
// 适配热力图,具体参数转换等逻辑在引擎层面实现,确保后续接口平替时只需要修改引擎层面即可
|
|
1555
|
-
this.heatMap = function (options, cb) {
|
|
1556
|
-
let mapInstance;
|
|
1557
|
-
if (globeMap != null && mapType == 'globe') {
|
|
1558
|
-
mapInstance = globeMap;
|
|
1559
|
-
} else if (gisMap != null && mapType == 'map') {
|
|
1560
|
-
mapInstance = gisMap;
|
|
1561
|
-
}
|
|
1562
|
-
mapInstance.heatMap(options, cb);
|
|
1563
|
-
};
|
|
1564
|
-
// 新版通用接口
|
|
1565
|
-
// 适配网格
|
|
1566
|
-
this.area = function (options, cb) {
|
|
1567
|
-
let mapInstance;
|
|
1568
|
-
if (globeMap != null && mapType == 'globe') {
|
|
1569
|
-
mapInstance = globeMap;
|
|
1570
|
-
} else if (gisMap != null && mapType == 'map') {
|
|
1571
|
-
mapInstance = gisMap;
|
|
1572
|
-
}
|
|
1573
|
-
mapInstance.area(options, cb);
|
|
1574
|
-
};
|
|
1575
|
-
// 新版通用接口
|
|
1576
|
-
// 适配网格
|
|
1577
|
-
this.line = function (options, cb) {
|
|
1578
|
-
let mapInstance;
|
|
1579
|
-
if (globeMap != null && mapType == 'globe') {
|
|
1580
|
-
mapInstance = globeMap;
|
|
1581
|
-
} else if (gisMap != null && mapType == 'map') {
|
|
1582
|
-
mapInstance = gisMap;
|
|
1583
|
-
}
|
|
1584
|
-
mapInstance.line(options, cb);
|
|
1585
|
-
};
|
|
1586
|
-
// webgl无人机机场接口
|
|
1587
|
-
this.addDock = function (options) {
|
|
1588
|
-
if (globeMap != null && mapType == 'globe') {
|
|
1589
|
-
globeMap.addDock(options);
|
|
1590
|
-
}
|
|
1591
|
-
};
|
|
1592
|
-
// webgl十字聚焦特效
|
|
1593
|
-
this.lockOnPoint = function (options) {
|
|
1594
|
-
if (globeMap !== null && mapType === 'globe') {
|
|
1595
|
-
globeMap.lockOnPoint(options);
|
|
1596
|
-
}
|
|
1597
|
-
};
|
|
1598
|
-
// 视锥体特效
|
|
1599
|
-
this.frustumOperation = function (options) {
|
|
1600
|
-
if (globeMap !== null && mapType === 'globe') {
|
|
1601
|
-
globeMap.frustumOperation(options);
|
|
1602
|
-
}
|
|
1603
|
-
};
|
|
1604
|
-
// 新的机场区域效果
|
|
1605
|
-
this.globeImageryFocus = function (options) {
|
|
1606
|
-
if (globeMap !== null && mapType === 'globe') {
|
|
1607
|
-
globeMap.globeImageryFocus(options);
|
|
1608
|
-
}
|
|
1609
|
-
};
|
|
1610
|
-
};
|
|
1611
|
-
|
|
1612
|
-
export default egovaBI;
|
|
1
|
+
var egovaBI = function (globeMap, gisMap, mapType) {
|
|
2
|
+
function defaultValue(a, b) {
|
|
3
|
+
if (a !== undefined && a !== null) {
|
|
4
|
+
return a;
|
|
5
|
+
}
|
|
6
|
+
return b;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function getImgSize(url) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
let img = new Image();
|
|
12
|
+
img.onload = function () {
|
|
13
|
+
resolve({ width: img.width, height: img.height });
|
|
14
|
+
img = null;
|
|
15
|
+
};
|
|
16
|
+
img.onerror = function () {
|
|
17
|
+
resolve({ width: 0, height: 0 });
|
|
18
|
+
img = null;
|
|
19
|
+
};
|
|
20
|
+
img.src = url;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function interpolateColor(startColor, endColor, count) {
|
|
25
|
+
if (count < 2) return [startColor, endColor];
|
|
26
|
+
|
|
27
|
+
var start = rgbToRgbArray(startColor);
|
|
28
|
+
var end = rgbToRgbArray(endColor);
|
|
29
|
+
var end0 = end[0];
|
|
30
|
+
var end1 = end[1];
|
|
31
|
+
var end2 = end[2];
|
|
32
|
+
var end3 = end[3];
|
|
33
|
+
var start0 = start[0];
|
|
34
|
+
var start1 = start[1];
|
|
35
|
+
var start2 = start[2];
|
|
36
|
+
var start3 = start[3];
|
|
37
|
+
|
|
38
|
+
var r = end0 - start0;
|
|
39
|
+
var g = end1 - start1;
|
|
40
|
+
var b = end2 - start2;
|
|
41
|
+
var opacity = end3 - start3;
|
|
42
|
+
var step = 1.0 / count;
|
|
43
|
+
var colors = [startColor];
|
|
44
|
+
var _count = count - 1;
|
|
45
|
+
for (var i = 1; i < _count; i++) {
|
|
46
|
+
var interval = step * i;
|
|
47
|
+
colors.push([
|
|
48
|
+
Math.round(start0 + interval * r),
|
|
49
|
+
Math.round(start1 + interval * g),
|
|
50
|
+
Math.round(start2 + interval * b),
|
|
51
|
+
start3 + interval * opacity,
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
colors.push(endColor);
|
|
55
|
+
return colors;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function rgbToRgbArray(color) {
|
|
59
|
+
if (
|
|
60
|
+
!color ||
|
|
61
|
+
typeof color !== 'string' ||
|
|
62
|
+
(typeof color == 'string' && color.indexOf('rgb') == -1)
|
|
63
|
+
)
|
|
64
|
+
return color;
|
|
65
|
+
|
|
66
|
+
var r, g, b, a;
|
|
67
|
+
var rgbaAttr = color.match(/[\d.]+/g);
|
|
68
|
+
if (rgbaAttr.length >= 3) {
|
|
69
|
+
r = parseInt(rgbaAttr[0]);
|
|
70
|
+
g = parseInt(rgbaAttr[1]);
|
|
71
|
+
b = parseInt(rgbaAttr[2]);
|
|
72
|
+
if (rgbaAttr.length > 3) a = parseFloat(rgbaAttr[3]);
|
|
73
|
+
else a = 1;
|
|
74
|
+
}
|
|
75
|
+
return [r, g, b, a];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 查询idb是否存在表
|
|
79
|
+
function checkObjectStore(storeName) {
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
// 打开网格数据库
|
|
82
|
+
let idbRequest = window.indexedDB.open('regionDB');
|
|
83
|
+
idbRequest.onblocked = function (event) {
|
|
84
|
+
// 如果其他的一些页签加载了该数据库,在我们继续之前需要关闭它们
|
|
85
|
+
// alert("请关闭其他由该站点打开的页签!");
|
|
86
|
+
console.log('请关闭其他由该站点打开的页签!');
|
|
87
|
+
};
|
|
88
|
+
idbRequest.onerror = (event) => {
|
|
89
|
+
console.log('数据库打开报错(checkObjectStore)');
|
|
90
|
+
// resolve(undefined)
|
|
91
|
+
reject(event.target.error.message);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
idbRequest.onsuccess = () => {
|
|
95
|
+
let db = idbRequest.result;
|
|
96
|
+
// console.log('数据库打开成功(hasObjectStore)')
|
|
97
|
+
resolve(db.objectStoreNames.contains(storeName));
|
|
98
|
+
db.close();
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function deal2DPoints(layerName, positions, options) {
|
|
104
|
+
let datalist = [];
|
|
105
|
+
let zoom = options.common.zoom;
|
|
106
|
+
let clear = options.common.clear;
|
|
107
|
+
let highLightType = -1;
|
|
108
|
+
let infoStyle = null;
|
|
109
|
+
let renderCanvas = null;
|
|
110
|
+
if (options.option && options.option.renderCanvas !== undefined) {
|
|
111
|
+
renderCanvas = options.option.renderCanvas;
|
|
112
|
+
}
|
|
113
|
+
let tagName = layerName;
|
|
114
|
+
let clusterOption = null;
|
|
115
|
+
|
|
116
|
+
let hasHover = null;
|
|
117
|
+
let callback = null;
|
|
118
|
+
datalist = positions.map(function (p) {
|
|
119
|
+
if (options.textStyle.label) {
|
|
120
|
+
for (const key in p) {
|
|
121
|
+
if (
|
|
122
|
+
key !== 'id' &&
|
|
123
|
+
key !== 'x' &&
|
|
124
|
+
key !== 'y' &&
|
|
125
|
+
key !== 'objectID'
|
|
126
|
+
) {
|
|
127
|
+
if (!p.label) p.label = [];
|
|
128
|
+
var labelItem = {};
|
|
129
|
+
labelItem[key] = p[key];
|
|
130
|
+
p.label.push(labelItem);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
p.minZoom = options.common.beginLevel;
|
|
135
|
+
p.maxZoom = options.common.endLevel;
|
|
136
|
+
p.symbolType = -1;
|
|
137
|
+
p.symbolUrl = options.textStyle.symbolUrl || 'location.png';
|
|
138
|
+
if (options.selected && options.selected.hSymbolUrl)
|
|
139
|
+
p.hSymbolUrl = options.selected.hSymbolUrl;
|
|
140
|
+
p.scale = options.textStyle.scale;
|
|
141
|
+
p.angle = options.textStyle.angle;
|
|
142
|
+
// 适配选中效果的放大倍数和高亮图片
|
|
143
|
+
if (options.selectStyle && options.selectStyle.enable) {
|
|
144
|
+
if (options.selectStyle.scaleEnabled) {
|
|
145
|
+
p.hScale = options.selectStyle.scaleFactor;
|
|
146
|
+
}
|
|
147
|
+
if (options.selectStyle.imgUrl) {
|
|
148
|
+
p.hSymbolUrl = options.selectStyle.imgUrl;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// 杭州现场,需要叠加图片和地图放大同时存在
|
|
152
|
+
if (options.developer) {
|
|
153
|
+
if (
|
|
154
|
+
options.developer.enableScaleAndOverImage &&
|
|
155
|
+
options.developer.scaleAndOverImageFactor
|
|
156
|
+
) {
|
|
157
|
+
p.aScale = options.developer.scaleAndOverImageFactor;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
//classify symbol
|
|
161
|
+
if (options.textStyle.enableClassify) {
|
|
162
|
+
const customScheme = options.textStyle.customScheme;
|
|
163
|
+
const classField = options.textStyle.classField;
|
|
164
|
+
if (
|
|
165
|
+
p[classField] &&
|
|
166
|
+
Object.prototype.toString.call(customScheme) ==
|
|
167
|
+
'[object Array]' &&
|
|
168
|
+
customScheme.length
|
|
169
|
+
) {
|
|
170
|
+
customScheme.forEach((scheme) => {
|
|
171
|
+
if (scheme.type == p[classField]) {
|
|
172
|
+
scheme.imageUrl && (p.symbolUrl = scheme.imageUrl);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//textValue
|
|
178
|
+
if (options.textStyle.enableText) {
|
|
179
|
+
let labelMinZoom = options.common.beginLevel;
|
|
180
|
+
let labelMaxZoom = options.common.endLevel;
|
|
181
|
+
if (options.textStyle.labelZoomEnabled) {
|
|
182
|
+
labelMinZoom = options.textStyle.textBeginLevel;
|
|
183
|
+
labelMaxZoom = options.textStyle.textEndLevel;
|
|
184
|
+
}
|
|
185
|
+
p.labelStyle = {
|
|
186
|
+
type: 'text',
|
|
187
|
+
minZoom: labelMinZoom,
|
|
188
|
+
maxZoom: labelMaxZoom,
|
|
189
|
+
xoffset: options.textStyle.xoffset + 'px',
|
|
190
|
+
yoffset: options.textStyle.yoffset + 'px',
|
|
191
|
+
text: p.textValue,
|
|
192
|
+
color: options.textStyle.fillColor,
|
|
193
|
+
font: {
|
|
194
|
+
size: options.textStyle.fontSize + 'px',
|
|
195
|
+
weight: options.textStyle.fontWeight,
|
|
196
|
+
family: options.textStyle.family || 'microsoft-yahei',
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
p.useLabelBg = options.textStyle.textBackground;
|
|
201
|
+
if (p.useLabelBg) {
|
|
202
|
+
p.labelBgStyle = {
|
|
203
|
+
type: 'picture-marker',
|
|
204
|
+
url: options.textStyle.textBackgroundUrl,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return p;
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
return new Promise((resolve, reject) => {
|
|
211
|
+
try {
|
|
212
|
+
let args = {
|
|
213
|
+
datalist: datalist,
|
|
214
|
+
zoom: zoom,
|
|
215
|
+
clear: clear,
|
|
216
|
+
highLightType: highLightType,
|
|
217
|
+
infoStyle: infoStyle,
|
|
218
|
+
renderCanvas: renderCanvas,
|
|
219
|
+
tagName: tagName,
|
|
220
|
+
clusterOption: null,
|
|
221
|
+
hasHover: hasHover,
|
|
222
|
+
callback: callback,
|
|
223
|
+
};
|
|
224
|
+
if (options.clusterStyle.clusterEnabled) {
|
|
225
|
+
clusterOption = {
|
|
226
|
+
clusterType: options.clusterStyle.clusterType,
|
|
227
|
+
distance: options.clusterStyle.clusterDistance,
|
|
228
|
+
style: null,
|
|
229
|
+
critical: options.clusterStyle.critical || 10,
|
|
230
|
+
level: options.clusterStyle.level,
|
|
231
|
+
clickShowSpiralPoint:
|
|
232
|
+
options.clusterStyle.clickShowSpiralPoint,
|
|
233
|
+
labelStyle: {
|
|
234
|
+
type: 'text',
|
|
235
|
+
color: options.clusterStyle.fillColor,
|
|
236
|
+
text: '',
|
|
237
|
+
xoffset: options.clusterStyle.xoffset + 'px',
|
|
238
|
+
yoffset: options.clusterStyle.yoffset + 'px',
|
|
239
|
+
font: {
|
|
240
|
+
size: options.clusterStyle.fontSize + 'px',
|
|
241
|
+
weight:
|
|
242
|
+
options.clusterStyle.fontWeight || 'normal',
|
|
243
|
+
family:
|
|
244
|
+
options.clusterStyle.family ||
|
|
245
|
+
'microsoft-yahei',
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
let useCustomClusterStyle =
|
|
251
|
+
options.clusterStyle.symbolUrl &&
|
|
252
|
+
options.clusterStyle.useCustomStyle;
|
|
253
|
+
let clusterStyle = {
|
|
254
|
+
type: 'simple-marker',
|
|
255
|
+
style: 'circle',
|
|
256
|
+
color: [255, 168, 0, 200],
|
|
257
|
+
size: 25 * options.clusterStyle.scale + 'px',
|
|
258
|
+
outline: {
|
|
259
|
+
color: [255, 168, 0, 200],
|
|
260
|
+
width: 2,
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
clusterOption.style = clusterStyle;
|
|
264
|
+
if (useCustomClusterStyle) {
|
|
265
|
+
getImgSize(options.clusterStyle.symbolUrl).then(
|
|
266
|
+
(szie) => {
|
|
267
|
+
clusterStyle = {
|
|
268
|
+
type: 'picture-marker',
|
|
269
|
+
url: options.clusterStyle.symbolUrl,
|
|
270
|
+
width:
|
|
271
|
+
szie.width *
|
|
272
|
+
options.clusterStyle.scale +
|
|
273
|
+
'px',
|
|
274
|
+
height:
|
|
275
|
+
szie.height *
|
|
276
|
+
options.clusterStyle.scale +
|
|
277
|
+
'px',
|
|
278
|
+
};
|
|
279
|
+
clusterOption.style = clusterStyle;
|
|
280
|
+
args.clusterOption = clusterOption;
|
|
281
|
+
resolve(args);
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
} else {
|
|
285
|
+
args.clusterOption = clusterOption;
|
|
286
|
+
resolve(args);
|
|
287
|
+
}
|
|
288
|
+
} else {
|
|
289
|
+
resolve(args);
|
|
290
|
+
}
|
|
291
|
+
} catch (err) {
|
|
292
|
+
reject(err);
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/*
|
|
298
|
+
* @description:新参数格式的旧热力接口,主要用来做中间层参数格式转换
|
|
299
|
+
* @method showHeatImage3D_BI
|
|
300
|
+
* @param {String} layerName 热力参数数组
|
|
301
|
+
* @param {Array} data 热力值和坐标的数据数组
|
|
302
|
+
* @param {Object} options 配置项
|
|
303
|
+
* @param {Object} options.heatOpt 热力配置项
|
|
304
|
+
* @param {Object} options.commonOpt 通用配置项
|
|
305
|
+
*
|
|
306
|
+
* @return {Void}} 无返回
|
|
307
|
+
*
|
|
308
|
+
* @author: Hetianhong
|
|
309
|
+
* @date: 2021-08-31 14:13:42
|
|
310
|
+
*/
|
|
311
|
+
this.showHeatImage3D_BI = function (layerName, data, option) {
|
|
312
|
+
//data必须包含x y 和 value属性
|
|
313
|
+
if (
|
|
314
|
+
data.length === 0 ||
|
|
315
|
+
!data[0].hasOwnProperty('x') ||
|
|
316
|
+
!data[0].hasOwnProperty('y') ||
|
|
317
|
+
!data[0].hasOwnProperty('value')
|
|
318
|
+
) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (globeMap != null) {
|
|
322
|
+
//hth 此处进行参数转换
|
|
323
|
+
let commonOpt = option.commonOpt; // 通用配置项
|
|
324
|
+
let heatOpt = option.heatOpt; // 热力配置项
|
|
325
|
+
|
|
326
|
+
let info = {};
|
|
327
|
+
let zoom = defaultValue(commonOpt.zoom, false);
|
|
328
|
+
let clear = defaultValue(commonOpt.clear, true);
|
|
329
|
+
let options = {
|
|
330
|
+
heading: defaultValue(commonOpt.heading, 0),
|
|
331
|
+
pitch: defaultValue(commonOpt.pitch, -45),
|
|
332
|
+
range: defaultValue(commonOpt.range, 8000),
|
|
333
|
+
maxDataLength: defaultValue(commonOpt.maxDataLength, 5),
|
|
334
|
+
layerName: layerName,
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// 开始组装info
|
|
338
|
+
//组装info.data,其实也没啥组装的
|
|
339
|
+
info.data = data;
|
|
340
|
+
|
|
341
|
+
//组装info.options
|
|
342
|
+
info.options = {
|
|
343
|
+
clampStyle: heatOpt.heatType === 0 ? 0 : 3, // 如果设置了为0,则为0,其余则全部为旧逻辑的3绘制方式,即贴地贴建筑
|
|
344
|
+
renderType: defaultValue(heatOpt.renderType, 'line'),
|
|
345
|
+
dynamicGranularity: defaultValue(
|
|
346
|
+
heatOpt.dynamicGranularity,
|
|
347
|
+
false
|
|
348
|
+
),
|
|
349
|
+
granularity: defaultValue(heatOpt.granularity, 500),
|
|
350
|
+
maxHeight: defaultValue(heatOpt.maxHeight, -1),
|
|
351
|
+
height: defaultValue(heatOpt.height, 10),
|
|
352
|
+
radiusScale: defaultValue(heatOpt.radiusScale, 1.0),
|
|
353
|
+
radius: defaultValue(heatOpt.radius, 40),
|
|
354
|
+
gradient: defaultValue(heatOpt.gradient, {
|
|
355
|
+
0.35: 'rgb(136,218,104)',
|
|
356
|
+
0.7: 'rgb(241,238,124)',
|
|
357
|
+
1.0: 'rgb(243,118,116)',
|
|
358
|
+
}),
|
|
359
|
+
//动态改变热力半径
|
|
360
|
+
dynamicRadius: defaultValue(heatOpt.dynamicRadius, undefined),
|
|
361
|
+
dynamicLevel: defaultValue(heatOpt.dynamicLevel, undefined),
|
|
362
|
+
// 下面的部分不建议传,逐步舍弃
|
|
363
|
+
gridSize: defaultValue(heatOpt.gridSize, null),
|
|
364
|
+
blur: defaultValue(heatOpt.blur, 0.85),
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// 转换过后,使用旧的参数格式调用原热力接口
|
|
368
|
+
globeMap.showHeatImage3D(info, zoom, clear, options);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
/*
|
|
373
|
+
* @description:打点和聚类接口进行整合后的新接口
|
|
374
|
+
* @method drawPoint
|
|
375
|
+
* @param {String} layerName 图层名
|
|
376
|
+
* @param {Array} positions 位置数组
|
|
377
|
+
* @param {Object} options 配置项
|
|
378
|
+
*
|
|
379
|
+
* @return {Void} 无返回
|
|
380
|
+
*
|
|
381
|
+
* @author: Hetianhong
|
|
382
|
+
* @date: 2021-09-09 14:49:49
|
|
383
|
+
*/
|
|
384
|
+
this.drawPoints = function (layerName, positions, options) {
|
|
385
|
+
let drawData = function (layerName, positions, options) {
|
|
386
|
+
if (globeMap && mapType == 'globe') {
|
|
387
|
+
globeMap.drawPoints(layerName, positions, options);
|
|
388
|
+
} else if (gisMap && mapType == 'map') {
|
|
389
|
+
deal2DPoints(layerName, positions, options).then((args) => {
|
|
390
|
+
gisMap.showMultiObjectCurrentPosition(
|
|
391
|
+
args.datalist,
|
|
392
|
+
args.zoom,
|
|
393
|
+
args.clear,
|
|
394
|
+
args.highLightType,
|
|
395
|
+
args.infoStyle,
|
|
396
|
+
args.renderCanvas,
|
|
397
|
+
args.tagName,
|
|
398
|
+
options.clickCallback,
|
|
399
|
+
options.mouseOverCallback,
|
|
400
|
+
args.clusterOption,
|
|
401
|
+
args.hasHover,
|
|
402
|
+
layerName,
|
|
403
|
+
options.mouseOutCallback,
|
|
404
|
+
options.option
|
|
405
|
+
);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
if (!options.usageID && !options.phyLayerID) {
|
|
411
|
+
drawData(layerName, positions, options);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
let queryFeature = (queryParams) => {
|
|
415
|
+
return new Promise(function (resolve) {
|
|
416
|
+
let cb = function (result) {
|
|
417
|
+
resolve(result);
|
|
418
|
+
};
|
|
419
|
+
if (gisMap) {
|
|
420
|
+
gisMap.queryFeature(queryParams, cb);
|
|
421
|
+
} else {
|
|
422
|
+
return Promise.resolve(undefined);
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
};
|
|
426
|
+
var filterString = '1=1';
|
|
427
|
+
if (options.filterString) filterString = options.filterString + '';
|
|
428
|
+
let queryParams = {
|
|
429
|
+
layerID: options.usageID || options.phyLayerID,
|
|
430
|
+
where: filterString,
|
|
431
|
+
outGeometry: true,
|
|
432
|
+
};
|
|
433
|
+
queryFeature(queryParams).then(function (resultData) {
|
|
434
|
+
if (!resultData) {
|
|
435
|
+
console.log('没有查询到数据,请检查查询参数');
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
let dataCache = [];
|
|
439
|
+
let errorSize = 0;
|
|
440
|
+
resultData.forEach((element) => {
|
|
441
|
+
let x, y;
|
|
442
|
+
if (element.geometry) {
|
|
443
|
+
x = element.geometry.x;
|
|
444
|
+
y = element.geometry.y;
|
|
445
|
+
}
|
|
446
|
+
if (x && y) {
|
|
447
|
+
let item = { ...element.attributes, x, y };
|
|
448
|
+
if (globeMap && mapType == 'globe' && options.primaryKey) {
|
|
449
|
+
let primaryKeyValue = item[options.primaryKey];
|
|
450
|
+
primaryKeyValue != undefined &&
|
|
451
|
+
(item['attributes'] = {
|
|
452
|
+
objectID: primaryKeyValue,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
dataCache.push(item);
|
|
456
|
+
} else {
|
|
457
|
+
errorSize++;
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
if (errorSize > 0) {
|
|
461
|
+
console.error(`${errorSize}个点格式错误,无法正常加载`);
|
|
462
|
+
}
|
|
463
|
+
if (options.callback && typeof options.callback === 'function') {
|
|
464
|
+
options.callback(dataCache);
|
|
465
|
+
}
|
|
466
|
+
drawData(layerName, dataCache, options);
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
this.getLabel = function (attributes) {
|
|
470
|
+
if (!attributes) return;
|
|
471
|
+
var label = [],
|
|
472
|
+
field = {};
|
|
473
|
+
for (var key in attributes) {
|
|
474
|
+
field = {};
|
|
475
|
+
field[key] = attributes[key];
|
|
476
|
+
label.push(field);
|
|
477
|
+
}
|
|
478
|
+
return label;
|
|
479
|
+
};
|
|
480
|
+
this.drawParts = function (options, data, callback) {
|
|
481
|
+
var self = this;
|
|
482
|
+
function showParts(data) {
|
|
483
|
+
var drawParam = options.drawParam || {};
|
|
484
|
+
var ctrOption = drawParam.clusterOption;
|
|
485
|
+
var zoom = options.zoom === undefined ? true : !!options.zoom;
|
|
486
|
+
var clusterOption = null;
|
|
487
|
+
if (ctrOption) {
|
|
488
|
+
clusterOption = {
|
|
489
|
+
clusterType: ctrOption.clusterType,
|
|
490
|
+
level: ctrOption.level || 0,
|
|
491
|
+
style: {
|
|
492
|
+
type: 'simple-marker',
|
|
493
|
+
style: 'circle',
|
|
494
|
+
color: ctrOption.color || [255, 0, 0, 0.6],
|
|
495
|
+
size: ctrOption.size || 20,
|
|
496
|
+
outline: {
|
|
497
|
+
//if outline has been specified
|
|
498
|
+
color: ctrOption.outlineColor || [255, 168, 0, 1],
|
|
499
|
+
width: ctrOption.outlineWidth || 2,
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
labelStyle: {
|
|
503
|
+
type: 'text',
|
|
504
|
+
color: ctrOption.labelColor || [255, 255, 255, 1],
|
|
505
|
+
text: '',
|
|
506
|
+
zlevel: ctrOption.labelZlevel || 1,
|
|
507
|
+
yoffset: 0,
|
|
508
|
+
font: ctrOption.labelFont || {
|
|
509
|
+
family: 'Arial',
|
|
510
|
+
size: 10,
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
distance: ctrOption.distance || 50,
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
var param = [
|
|
517
|
+
data,
|
|
518
|
+
zoom,
|
|
519
|
+
false,
|
|
520
|
+
null,
|
|
521
|
+
null,
|
|
522
|
+
false,
|
|
523
|
+
drawParam.tagName,
|
|
524
|
+
drawParam.clickCallback,
|
|
525
|
+
drawParam.mouseOverCallback,
|
|
526
|
+
clusterOption,
|
|
527
|
+
false,
|
|
528
|
+
drawParam.layerName,
|
|
529
|
+
drawParam.callback,
|
|
530
|
+
drawParam.drawOptions,
|
|
531
|
+
];
|
|
532
|
+
//三维聚类参数
|
|
533
|
+
var globeOptions = {
|
|
534
|
+
zoom: true,
|
|
535
|
+
scale: 0.9,
|
|
536
|
+
clear: true,
|
|
537
|
+
nearFarScalar: [8000, 1.0, 10000, 0.6],
|
|
538
|
+
clickCallBack: drawParam.clickCallback,
|
|
539
|
+
layerName: drawParam.layerName,
|
|
540
|
+
minSize: 30,
|
|
541
|
+
clusterLimit: 20,
|
|
542
|
+
style: 'default',
|
|
543
|
+
clusterImageInfo: {
|
|
544
|
+
horizontalOrigin: 'center',
|
|
545
|
+
verticalOrigin: 'bottom',
|
|
546
|
+
cssStyle: {
|
|
547
|
+
borderRadius: 500,
|
|
548
|
+
fillColor: 'rgba(0,0,0,0.7)',
|
|
549
|
+
borderLineWidth: 3,
|
|
550
|
+
borderLineColor: 'rgba(250,140,0,0.9)',
|
|
551
|
+
paddingX: 15,
|
|
552
|
+
paddingY: 6,
|
|
553
|
+
marginBottom: 2,
|
|
554
|
+
},
|
|
555
|
+
textStyle: {
|
|
556
|
+
font: '60px Helvetica',
|
|
557
|
+
fillColor: 'rgba(220,220,220,1.0)',
|
|
558
|
+
outlineColor: 'black',
|
|
559
|
+
outlineWidth: 1,
|
|
560
|
+
padding: 1,
|
|
561
|
+
textScale: 0.5,
|
|
562
|
+
textStartX: 40,
|
|
563
|
+
textStartY: 15,
|
|
564
|
+
},
|
|
565
|
+
},
|
|
566
|
+
};
|
|
567
|
+
if (globeMap) {
|
|
568
|
+
globeMap.addClusterLayer({
|
|
569
|
+
data,
|
|
570
|
+
options: globeOptions,
|
|
571
|
+
});
|
|
572
|
+
} else if (gisMap) {
|
|
573
|
+
gisMap.showMultiObjectCurrentPosition(...param);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (data) {
|
|
578
|
+
showParts(data);
|
|
579
|
+
} else {
|
|
580
|
+
let queryFromGIS = () => {
|
|
581
|
+
let queryParam = options.queryParam;
|
|
582
|
+
var subTypeName = options.subTypeName;
|
|
583
|
+
var subUniqueCode = options.subUniqueCode;
|
|
584
|
+
let queryCallback = function (featureInfos) {
|
|
585
|
+
var features = featureInfos[queryParam.phyLayerIDs];
|
|
586
|
+
if (features.length == 0) {
|
|
587
|
+
callback && callback([]);
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
if (!features || !features.length) return;
|
|
591
|
+
var symbolUrl = '';
|
|
592
|
+
if (subUniqueCode.indexOf('http') > -1) {
|
|
593
|
+
symbolUrl = subUniqueCode;
|
|
594
|
+
} else if (subUniqueCode.indexOf('.') > -1) {
|
|
595
|
+
symbolUrl = subUniqueCode;
|
|
596
|
+
} else {
|
|
597
|
+
symbolUrl = ''.concat(subUniqueCode, '.png');
|
|
598
|
+
if (globeMap)
|
|
599
|
+
symbolUrl = queryParam.gisServerURL
|
|
600
|
+
? `${queryParam.gisServerURL}/symbol/${symbolUrl}`
|
|
601
|
+
: symbolUrl;
|
|
602
|
+
}
|
|
603
|
+
var map = globeMap || gisMap;
|
|
604
|
+
//验证图标是否可查询
|
|
605
|
+
map.getMapConfig('serverURL', function (key, data) {
|
|
606
|
+
var symbolServiceURL = `${data}/symbol`;
|
|
607
|
+
var picUrl =
|
|
608
|
+
symbolUrl.indexOf('http') > -1 ||
|
|
609
|
+
symbolUrl.indexOf('https') > -1
|
|
610
|
+
? symbolUrl
|
|
611
|
+
: `${symbolServiceURL}/${symbolUrl}`;
|
|
612
|
+
getImgSize(picUrl).then((size) => {
|
|
613
|
+
var dataList = features.map(function (feature) {
|
|
614
|
+
return Object.assign(
|
|
615
|
+
{},
|
|
616
|
+
{
|
|
617
|
+
x: feature.geometry.x,
|
|
618
|
+
y: feature.geometry.y,
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
attributes: feature.attributes,
|
|
622
|
+
// label:self.getLabel(feature.attributes), //去除内部弹框的可能性
|
|
623
|
+
symbolType: -1,
|
|
624
|
+
symbolUrl:
|
|
625
|
+
size.width || size.height
|
|
626
|
+
? picUrl
|
|
627
|
+
: globeMap
|
|
628
|
+
? `${symbolServiceURL}/20100.png`
|
|
629
|
+
: `20100.png`,
|
|
630
|
+
scale: 0.5,
|
|
631
|
+
}
|
|
632
|
+
);
|
|
633
|
+
});
|
|
634
|
+
callback && callback(dataList);
|
|
635
|
+
if (!options.onlyGetData) {
|
|
636
|
+
showParts(dataList);
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
};
|
|
641
|
+
if (gisMap) {
|
|
642
|
+
gisMap.queryPhylayerFeatures(queryParam, queryCallback);
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
queryFromGIS();
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
this.drawOtherParts = function (options, data) {
|
|
650
|
+
const geomType = options.geomType;
|
|
651
|
+
if (globeMap && geomType != 1) {
|
|
652
|
+
this.drawOtherPartsGlobe(options, data);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
var self = this;
|
|
657
|
+
let queryParam = options.queryParam || {};
|
|
658
|
+
function showParts(data) {}
|
|
659
|
+
|
|
660
|
+
if (data) {
|
|
661
|
+
showParts(data);
|
|
662
|
+
} else {
|
|
663
|
+
const layerID = queryParam.phyLayerIDs;
|
|
664
|
+
const layerName = queryParam.layerName;
|
|
665
|
+
const keyField = null;
|
|
666
|
+
const keyValue = null;
|
|
667
|
+
const clearMap = queryParam.clearMap;
|
|
668
|
+
let inStyle = queryParam.style || {
|
|
669
|
+
color: 'blue',
|
|
670
|
+
};
|
|
671
|
+
let inHStyle = queryParam.hStyle || {
|
|
672
|
+
color: 'blue',
|
|
673
|
+
};
|
|
674
|
+
let style = null,
|
|
675
|
+
hStyle = null;
|
|
676
|
+
if (geomType == 1) {
|
|
677
|
+
} else if (geomType == 2) {
|
|
678
|
+
style = {
|
|
679
|
+
type: 'simple-line', // autocasts as new SimpleLineSymbol()
|
|
680
|
+
color: inStyle.color || 'blue',
|
|
681
|
+
width: inStyle.width || '2px',
|
|
682
|
+
style: inStyle.style || 'solid',
|
|
683
|
+
cap: inStyle.cap || 'round',
|
|
684
|
+
join: inStyle.join || 'round',
|
|
685
|
+
};
|
|
686
|
+
hStyle = {
|
|
687
|
+
type: 'simple-line', // autocasts as new SimpleLineSymbol()
|
|
688
|
+
color: inHStyle.color || 'red',
|
|
689
|
+
width: inHStyle.width || inStyle.width || '2px',
|
|
690
|
+
style: inHStyle.style || inStyle.style || 'solid',
|
|
691
|
+
cap: inHStyle.cap || inStyle.cap || 'round',
|
|
692
|
+
join: inHStyle.join || inStyle.join || 'round',
|
|
693
|
+
};
|
|
694
|
+
} else if (geomType == 3) {
|
|
695
|
+
style = {
|
|
696
|
+
type: 'simple-fill', // autocasts as new SimpleFillSymbol()
|
|
697
|
+
color: inStyle.color || [51, 51, 204, 0.9],
|
|
698
|
+
style: inStyle.style || 'solid',
|
|
699
|
+
outline: {
|
|
700
|
+
// autocasts as new SimpleLineSymbol()
|
|
701
|
+
color: inStyle.outlineColor || 'blue',
|
|
702
|
+
width: inStyle.outlineWidth || '1px',
|
|
703
|
+
style: inStyle.outlineStyle || 'solid',
|
|
704
|
+
cap: inStyle.outlineCap || 'round',
|
|
705
|
+
join: inStyle.outlineJoin || 'round',
|
|
706
|
+
},
|
|
707
|
+
};
|
|
708
|
+
hStyle = {
|
|
709
|
+
type: 'simple-fill', // autocasts as new SimpleFillSymbol()
|
|
710
|
+
color: inHStyle.color || [51, 51, 204, 0.9],
|
|
711
|
+
style: inHStyle.style || inStyle.style || 'solid',
|
|
712
|
+
outline: {
|
|
713
|
+
// autocasts as new SimpleLineSymbol()
|
|
714
|
+
color: inHStyle.outlineColor || 'red',
|
|
715
|
+
width:
|
|
716
|
+
inHStyle.outlineWidth ||
|
|
717
|
+
inStyle.outlineWidth ||
|
|
718
|
+
'1px',
|
|
719
|
+
style:
|
|
720
|
+
inHStyle.outlineStyle ||
|
|
721
|
+
inStyle.outlineStyle ||
|
|
722
|
+
'solid',
|
|
723
|
+
cap:
|
|
724
|
+
inHStyle.outlineCap ||
|
|
725
|
+
inStyle.outlineCap ||
|
|
726
|
+
'round',
|
|
727
|
+
join:
|
|
728
|
+
inHStyle.outlineJoin ||
|
|
729
|
+
inStyle.outlineJoin ||
|
|
730
|
+
'round',
|
|
731
|
+
},
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
const bZoom = queryParam.bZoom || true;
|
|
735
|
+
const randomColor = null;
|
|
736
|
+
const labelField = null;
|
|
737
|
+
const labelstyle = null;
|
|
738
|
+
const geometry = null;
|
|
739
|
+
const where = queryParam.where || '1=1';
|
|
740
|
+
const opts = {
|
|
741
|
+
...queryParam.options,
|
|
742
|
+
layerId: layerName,
|
|
743
|
+
mouseOverCallback: queryParam.mouseOverCallback,
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
let param = [
|
|
747
|
+
layerID,
|
|
748
|
+
keyField,
|
|
749
|
+
keyValue,
|
|
750
|
+
clearMap,
|
|
751
|
+
style,
|
|
752
|
+
hStyle,
|
|
753
|
+
bZoom,
|
|
754
|
+
randomColor,
|
|
755
|
+
labelField,
|
|
756
|
+
labelstyle,
|
|
757
|
+
geometry,
|
|
758
|
+
where,
|
|
759
|
+
null,
|
|
760
|
+
null,
|
|
761
|
+
opts,
|
|
762
|
+
null,
|
|
763
|
+
null,
|
|
764
|
+
null,
|
|
765
|
+
null,
|
|
766
|
+
null,
|
|
767
|
+
null,
|
|
768
|
+
queryParam.clickCallback,
|
|
769
|
+
];
|
|
770
|
+
//let param = [layerID, keyField, keyValue, clearMap, style, hStyle, bZoom, randomColor, labelField, labelstyle, geometry, where, null, null, opts, null, null, null, null, queryParam.callback];
|
|
771
|
+
if (globeMap) {
|
|
772
|
+
gisMap.locateFeatureByIDs(...param);
|
|
773
|
+
} else if (gisMap) {
|
|
774
|
+
gisMap.locateFeatureByIDs(...param);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
this.drawOtherPartsGlobe = function (options, data) {
|
|
780
|
+
const geomType = options.geomType;
|
|
781
|
+
const drawParam = options.drawParam || {};
|
|
782
|
+
const color = drawParam.color || 'rgba(255, 0.0, 0.0, 0.8)';
|
|
783
|
+
const clickColor = drawParam.clickColor || 'rgba(255, 255, 0.0, 0.8)';
|
|
784
|
+
function showParts(features) {
|
|
785
|
+
if (!globeMap) {
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
if (geomType == 2) {
|
|
790
|
+
var infoJson = features.map((feature) => {
|
|
791
|
+
var paths = feature.geometry.paths[0];
|
|
792
|
+
var positions = paths.map((position) => {
|
|
793
|
+
return {
|
|
794
|
+
x: position[0],
|
|
795
|
+
y: position[1],
|
|
796
|
+
};
|
|
797
|
+
});
|
|
798
|
+
return {
|
|
799
|
+
positions,
|
|
800
|
+
type: 'color',
|
|
801
|
+
color: color,
|
|
802
|
+
width: 2,
|
|
803
|
+
attributes: feature.attributes,
|
|
804
|
+
};
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
var zoom = true;
|
|
808
|
+
var clear = true;
|
|
809
|
+
var layerName = drawParam.layerName;
|
|
810
|
+
var options = {
|
|
811
|
+
heading: 0,
|
|
812
|
+
pitch: -90,
|
|
813
|
+
range: null,
|
|
814
|
+
minZoom: 0,
|
|
815
|
+
maxZoom: 100,
|
|
816
|
+
clickColor: clickColor,
|
|
817
|
+
clickWidth: 5,
|
|
818
|
+
bloom: false,
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
globeMap.showPolyline(
|
|
822
|
+
infoJson,
|
|
823
|
+
zoom,
|
|
824
|
+
clear,
|
|
825
|
+
options,
|
|
826
|
+
layerName,
|
|
827
|
+
drawParam.clickCallback
|
|
828
|
+
);
|
|
829
|
+
} else if (geomType == 3) {
|
|
830
|
+
var infoJson = features.map((feature) => {
|
|
831
|
+
var rings = feature.geometry.rings[0];
|
|
832
|
+
var positions = rings.map((position) => {
|
|
833
|
+
return {
|
|
834
|
+
x: position[0],
|
|
835
|
+
y: position[1],
|
|
836
|
+
};
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
return {
|
|
840
|
+
positions,
|
|
841
|
+
type: 'polygon',
|
|
842
|
+
colorType: 'color',
|
|
843
|
+
color: color,
|
|
844
|
+
attributes: feature.attributes,
|
|
845
|
+
};
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
var zoom = true;
|
|
849
|
+
var clear = true;
|
|
850
|
+
var layerName = drawParam.layerName;
|
|
851
|
+
var drawWay = 'entityWay';
|
|
852
|
+
var options = {
|
|
853
|
+
heading: 0,
|
|
854
|
+
pitch: -90,
|
|
855
|
+
range: null,
|
|
856
|
+
minZoom: 0,
|
|
857
|
+
maxZoom: 24,
|
|
858
|
+
clickColor: clickColor,
|
|
859
|
+
clickWidth: 15,
|
|
860
|
+
heightAnimation: false,
|
|
861
|
+
};
|
|
862
|
+
globeMap.showPolygon(
|
|
863
|
+
infoJson,
|
|
864
|
+
drawWay,
|
|
865
|
+
zoom,
|
|
866
|
+
clear,
|
|
867
|
+
options,
|
|
868
|
+
layerName,
|
|
869
|
+
drawParam.clickCallback
|
|
870
|
+
);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
if (data) {
|
|
875
|
+
showParts(data);
|
|
876
|
+
} else {
|
|
877
|
+
let queryFromGIS = () => {
|
|
878
|
+
let queryParam = options.queryParam;
|
|
879
|
+
let queryCallback = function (featureInfos) {
|
|
880
|
+
var features = featureInfos[queryParam.phyLayerIDs];
|
|
881
|
+
if (!features || !features.length) return;
|
|
882
|
+
showParts(features);
|
|
883
|
+
};
|
|
884
|
+
if (gisMap) {
|
|
885
|
+
gisMap.queryPhylayerFeatures(queryParam, queryCallback);
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
queryFromGIS();
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
/*
|
|
893
|
+
* @description:新的轨迹线接口
|
|
894
|
+
* @method traceOperation
|
|
895
|
+
* @param {Array} posArr 位置数组
|
|
896
|
+
* @param {Object} options 配置项
|
|
897
|
+
*
|
|
898
|
+
* @return {Void} 无返回
|
|
899
|
+
*
|
|
900
|
+
* @author: Hetianhong
|
|
901
|
+
* @date: 2021-09-09 14:49:49
|
|
902
|
+
*/
|
|
903
|
+
this.traceOperation = function (posArr, options) {
|
|
904
|
+
globeMap.traceOperation(posArr, options);
|
|
905
|
+
};
|
|
906
|
+
/*
|
|
907
|
+
* @description:网格接口
|
|
908
|
+
* 先查询idb的data,没有的话,再查询queryFeature的data
|
|
909
|
+
* @method regionOperation
|
|
910
|
+
* @param {Object} options 配置项
|
|
911
|
+
* @param {Array} data 数据,可不传
|
|
912
|
+
*
|
|
913
|
+
* @return {Void} 无返回
|
|
914
|
+
*
|
|
915
|
+
* @author: Hetianhong
|
|
916
|
+
* @date: 2021-10-19 17:27:02
|
|
917
|
+
*/
|
|
918
|
+
this.regionOperation = function (options, data, callback, dataLoadCb) {
|
|
919
|
+
function execOperation(data) {
|
|
920
|
+
if (globeMap) {
|
|
921
|
+
globeMap.regionOperation(options, data);
|
|
922
|
+
callback && callback();
|
|
923
|
+
} else if (gisMap) {
|
|
924
|
+
gridPolygon2dOperation(options, data, callback, dataLoadCb);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
if (data) {
|
|
929
|
+
execOperation(data);
|
|
930
|
+
} else {
|
|
931
|
+
if (!options.idbSetting.usageID) {
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
let storeName = !!globeMap
|
|
936
|
+
? 'usageID'
|
|
937
|
+
: 'usage2D' + '_' + options.idbSetting.usageID;
|
|
938
|
+
let queryFromGIS = () => {
|
|
939
|
+
let filterString = options.idbSetting.filterString || '1=1';
|
|
940
|
+
let queryParam = {
|
|
941
|
+
layerID: options.idbSetting.usageID,
|
|
942
|
+
where: filterString,
|
|
943
|
+
geometry: '',
|
|
944
|
+
outGeometry: true,
|
|
945
|
+
options: {
|
|
946
|
+
originalData: true,
|
|
947
|
+
},
|
|
948
|
+
};
|
|
949
|
+
//二维地图不获取原始数据
|
|
950
|
+
if (!globeMap) queryParam.options.originalData = false;
|
|
951
|
+
let queryCallback = function (featureInfos) {
|
|
952
|
+
execOperation(featureInfos);
|
|
953
|
+
};
|
|
954
|
+
if (gisMap) {
|
|
955
|
+
gisMap.queryFeature(queryParam, queryCallback);
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
if (!options.idbSetting.enabled) {
|
|
960
|
+
// 直接查询
|
|
961
|
+
queryFromGIS();
|
|
962
|
+
} else {
|
|
963
|
+
// 查询是否存在表
|
|
964
|
+
checkObjectStore(storeName).then(function (hasObjStore) {
|
|
965
|
+
if (hasObjStore) {
|
|
966
|
+
// 如果有,读取本地
|
|
967
|
+
execOperation();
|
|
968
|
+
} else {
|
|
969
|
+
// 如果没有,查询queryFeature
|
|
970
|
+
queryFromGIS();
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
this.cancelHighlightedRegion = function (layerName) {
|
|
977
|
+
globeMap.cancelHighlightedRegion(layerName);
|
|
978
|
+
};
|
|
979
|
+
/*
|
|
980
|
+
* @description:新参数格式的旧线接口,主要用来做中间层参数格式转换
|
|
981
|
+
* @method showPolyline_BI
|
|
982
|
+
* @param {参数类型} 参数名 参数说明
|
|
983
|
+
*
|
|
984
|
+
* @return {返回值类型} 返回值说明
|
|
985
|
+
*
|
|
986
|
+
* @author: Hetianhong
|
|
987
|
+
* @date: 2021-11-11 15:40:31
|
|
988
|
+
*/
|
|
989
|
+
this.showPolyline_BI = function (layerName, positions = [], options = {}) {
|
|
990
|
+
if (globeMap !== null) {
|
|
991
|
+
// 默认参数
|
|
992
|
+
let defaultOpt = {
|
|
993
|
+
// 样式类
|
|
994
|
+
styleOpt: {
|
|
995
|
+
period: 4, // 动画线段的周期,越短越快
|
|
996
|
+
image: 'road.png', // type为image时线段所使用的纹理图案,位置在data3d/polyline/目录下(type为image限定)
|
|
997
|
+
repeatX: 2, // 横向纹理重复,越大则越密(type为image限定)
|
|
998
|
+
repeatY: 1, //纵向纹理重复(type为image限定)
|
|
999
|
+
glowPower: 0, //中心亮度
|
|
1000
|
+
intensity: 1.2, //纹理图片颜色强度
|
|
1001
|
+
gapColor: 'rgba(0, 0, 0, 0)', //间隙颜色(type为dash限定)
|
|
1002
|
+
dashLength: 15, //间隙宽(type为dash限定)
|
|
1003
|
+
outlineWidth: 0, // 边框线宽(type为outline限定)
|
|
1004
|
+
outlineColor: 'rgba(0, 0, 0, 0)', // 边框颜色(type为outline限定)
|
|
1005
|
+
type: 'color', // 线条类型,有 image color dash outline glow
|
|
1006
|
+
width: 10,
|
|
1007
|
+
color: 'rgba(255,255,0,1)',
|
|
1008
|
+
},
|
|
1009
|
+
// 视角缩放类
|
|
1010
|
+
zoomOpt: {
|
|
1011
|
+
//zoom参数
|
|
1012
|
+
heading: 0,
|
|
1013
|
+
pitch: -90,
|
|
1014
|
+
range: null,
|
|
1015
|
+
//可视级别
|
|
1016
|
+
minZoom: 0,
|
|
1017
|
+
maxZoom: 24,
|
|
1018
|
+
//泛光绘制
|
|
1019
|
+
// 下面两项,不暴露,全部为false
|
|
1020
|
+
bloom: false,
|
|
1021
|
+
merge: false,
|
|
1022
|
+
},
|
|
1023
|
+
// 交互类
|
|
1024
|
+
interactOpt: {
|
|
1025
|
+
//click相关
|
|
1026
|
+
clickColor: 'rgb(255, 255, 0.0)', // 点击后的颜色
|
|
1027
|
+
clickWidth: 30, // 点击后的宽度
|
|
1028
|
+
clickCallback: undefined, // function(e) {console.log('click polyline', e)},
|
|
1029
|
+
mouseOverCallBack: undefined,
|
|
1030
|
+
},
|
|
1031
|
+
};
|
|
1032
|
+
let getMergedOptions = (options) => {
|
|
1033
|
+
let mergedOptions = {};
|
|
1034
|
+
mergedOptions.styleOpt = Object.assign(
|
|
1035
|
+
{},
|
|
1036
|
+
defaultOpt.styleOpt,
|
|
1037
|
+
options.styleOpt
|
|
1038
|
+
);
|
|
1039
|
+
mergedOptions.zoomOpt = Object.assign(
|
|
1040
|
+
{},
|
|
1041
|
+
defaultOpt.zoomOpt,
|
|
1042
|
+
options.zoomOpt
|
|
1043
|
+
);
|
|
1044
|
+
mergedOptions.interactOpt = Object.assign(
|
|
1045
|
+
{},
|
|
1046
|
+
defaultOpt.interactOpt,
|
|
1047
|
+
options.interactOpt
|
|
1048
|
+
);
|
|
1049
|
+
return mergedOptions;
|
|
1050
|
+
};
|
|
1051
|
+
let mergedOptions = getMergedOptions(options);
|
|
1052
|
+
|
|
1053
|
+
let opt = {};
|
|
1054
|
+
// let styleOpt = options.styleOpt;
|
|
1055
|
+
// let zoomOpt = options.zoomOpt;
|
|
1056
|
+
// let interactOpt = options.interactOpt;
|
|
1057
|
+
//hth 此处进行参数转换
|
|
1058
|
+
switch (mergedOptions.styleOpt.type) {
|
|
1059
|
+
case 'image':
|
|
1060
|
+
opt.period = defaultValue(mergedOptions.styleOpt.period, 4); // 纹理流动周期,越小越快
|
|
1061
|
+
opt.image = defaultValue(
|
|
1062
|
+
mergedOptions.styleOpt.image,
|
|
1063
|
+
'road.png'
|
|
1064
|
+
); //纹理图片,data3d/polyline/目录下
|
|
1065
|
+
opt.repeatX = defaultValue(
|
|
1066
|
+
mergedOptions.styleOpt.repeatX,
|
|
1067
|
+
2
|
|
1068
|
+
); //横向纹理重复,越大越密
|
|
1069
|
+
opt.repeatY = defaultValue(
|
|
1070
|
+
mergedOptions.styleOpt.repeatY,
|
|
1071
|
+
1
|
|
1072
|
+
); //纵向纹理重复
|
|
1073
|
+
opt.glowPower = defaultValue(
|
|
1074
|
+
mergedOptions.styleOpt.glowPower,
|
|
1075
|
+
0
|
|
1076
|
+
); //中心亮度
|
|
1077
|
+
opt.intensity = defaultValue(
|
|
1078
|
+
mergedOptions.styleOpt.intensity,
|
|
1079
|
+
1.2
|
|
1080
|
+
); //纹理图片颜色强度
|
|
1081
|
+
break;
|
|
1082
|
+
case 'glow':
|
|
1083
|
+
opt.glowPower = defaultValue(
|
|
1084
|
+
mergedOptions.styleOpt.glowPower,
|
|
1085
|
+
0.2
|
|
1086
|
+
); //中心亮度
|
|
1087
|
+
break;
|
|
1088
|
+
case 'dash':
|
|
1089
|
+
opt.gapColor = defaultValue(
|
|
1090
|
+
mergedOptions.styleOpt.gapColor,
|
|
1091
|
+
'rgba(0, 0, 0, 0)'
|
|
1092
|
+
); //间隙颜色
|
|
1093
|
+
opt.dashLength = defaultValue(
|
|
1094
|
+
mergedOptions.styleOpt.dashLength,
|
|
1095
|
+
15
|
|
1096
|
+
); //间隙宽
|
|
1097
|
+
break;
|
|
1098
|
+
case 'outline':
|
|
1099
|
+
opt.outlineWidth = defaultValue(
|
|
1100
|
+
mergedOptions.styleOpt.outlineWidth,
|
|
1101
|
+
0
|
|
1102
|
+
);
|
|
1103
|
+
opt.outlineColor = defaultValue(
|
|
1104
|
+
mergedOptions.styleOpt.outlineColor,
|
|
1105
|
+
'rgba(0, 0, 0, 0)'
|
|
1106
|
+
);
|
|
1107
|
+
break;
|
|
1108
|
+
default:
|
|
1109
|
+
// color
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
opt.type = mergedOptions.styleOpt.type;
|
|
1113
|
+
opt.width = mergedOptions.styleOpt.width;
|
|
1114
|
+
opt.color = mergedOptions.styleOpt.color;
|
|
1115
|
+
|
|
1116
|
+
// 遍历位置数组中的每一项
|
|
1117
|
+
for (let pos of positions) {
|
|
1118
|
+
// 遍历opt中每一个key赋值到每一个pos中
|
|
1119
|
+
for (let k in opt) {
|
|
1120
|
+
pos[k] = opt[k];
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
let zoom = mergedOptions.zoomOpt.zoom;
|
|
1125
|
+
let clear = mergedOptions.zoomOpt.clear;
|
|
1126
|
+
let clickCallback = mergedOptions.interactOpt.clickCallback;
|
|
1127
|
+
let mouseOverCallBack = mergedOptions.interactOpt.mouseOverCallBack;
|
|
1128
|
+
let commonOpt = {
|
|
1129
|
+
//zoom参数
|
|
1130
|
+
heading: mergedOptions.zoomOpt.heading,
|
|
1131
|
+
pitch: mergedOptions.zoomOpt.pitch,
|
|
1132
|
+
range: mergedOptions.zoomOpt.range,
|
|
1133
|
+
//可视级别
|
|
1134
|
+
minZoom: mergedOptions.zoomOpt.minZoom,
|
|
1135
|
+
maxZoom: mergedOptions.zoomOpt.maxZoom,
|
|
1136
|
+
//click相关
|
|
1137
|
+
clickColor: mergedOptions.interactOpt.clickColor, // 点击后的颜色
|
|
1138
|
+
clickWidth: mergedOptions.interactOpt.clickWidth, // 点击后的宽度
|
|
1139
|
+
//泛光绘制
|
|
1140
|
+
// 下面两项,不暴露,全部为false
|
|
1141
|
+
bloom: false,
|
|
1142
|
+
merge: false,
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
globeMap.showPolyline(
|
|
1146
|
+
positions,
|
|
1147
|
+
zoom,
|
|
1148
|
+
clear,
|
|
1149
|
+
commonOpt,
|
|
1150
|
+
layerName,
|
|
1151
|
+
clickCallback,
|
|
1152
|
+
mouseOverCallBack
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
/*
|
|
1157
|
+
* @description:被动触发图层类似点击效果,需要在图层内在单独定义Event
|
|
1158
|
+
* @method activeLayer
|
|
1159
|
+
* @param {String} layerName 图层名
|
|
1160
|
+
* @param {Object} options 配置项
|
|
1161
|
+
* @param {String} options.type 操作类型,'clear', 'active'
|
|
1162
|
+
* @param {Boolean} options.zoom 是否缩放
|
|
1163
|
+
* @param {Object} filter 过滤项
|
|
1164
|
+
* @param {String} filter.keyFieldName 过滤键名
|
|
1165
|
+
* @param {Array} filter.values 过滤值内容数组
|
|
1166
|
+
*
|
|
1167
|
+
* @return {返回值类型} 返回值说明
|
|
1168
|
+
*dataLoadCb:加载状态函数
|
|
1169
|
+
* @author: Hetianhong
|
|
1170
|
+
* @date: 2021-11-26 09:49:16
|
|
1171
|
+
*/
|
|
1172
|
+
this.activeLayer = function (layerName, options, filter) {
|
|
1173
|
+
if (globeMap != null && mapType == 'globe') {
|
|
1174
|
+
globeMap.activeLayer(layerName, options, filter);
|
|
1175
|
+
}
|
|
1176
|
+
if (gisMap != null && mapType == 'map') {
|
|
1177
|
+
gisMap.activeLayer(layerName, options, filter);
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
this.deActiveLayer = function (layerName, filter) {
|
|
1182
|
+
if (gisMap != null && mapType == 'map') {
|
|
1183
|
+
gisMap.deActiveLayer(layerName, filter);
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
|
|
1187
|
+
function gridPolygon2dOperation(options, data, callback, dataLoadCb) {
|
|
1188
|
+
var storeName = `usage2D_${options.idbSetting.usageID}`;
|
|
1189
|
+
function showGrid(realData) {
|
|
1190
|
+
// 转换一下
|
|
1191
|
+
var geometries = [];
|
|
1192
|
+
var extraGeometries = [];
|
|
1193
|
+
var specialAreaS = options.specialAreaS; //玲珑平台分类设色
|
|
1194
|
+
for (var i = 0; i < realData.length; i++) {
|
|
1195
|
+
var feature = realData[i];
|
|
1196
|
+
var geom = feature.geometry;
|
|
1197
|
+
geom.attributes = feature.attributes; // attributes会导致id没用,使用自带的id
|
|
1198
|
+
var hasPush = false;
|
|
1199
|
+
if (specialAreaS && specialAreaS.length > 0) {
|
|
1200
|
+
for (var j = 0; j < specialAreaS.length; j++) {
|
|
1201
|
+
var specialArea = specialAreaS[j];
|
|
1202
|
+
if (!specialArea.geometries) {
|
|
1203
|
+
specialArea.geometries = [];
|
|
1204
|
+
}
|
|
1205
|
+
var attributes = JSON.parse(
|
|
1206
|
+
JSON.stringify(feature.attributes)
|
|
1207
|
+
);
|
|
1208
|
+
let filterResult = new Function(
|
|
1209
|
+
`return ${specialArea.statusControl.compiled}`
|
|
1210
|
+
)().call(null, attributes);
|
|
1211
|
+
if (filterResult == true) {
|
|
1212
|
+
specialArea.geometries.push(geom);
|
|
1213
|
+
hasPush = true;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
!hasPush && geometries.push(geom);
|
|
1218
|
+
}
|
|
1219
|
+
if (
|
|
1220
|
+
options.specialArea &&
|
|
1221
|
+
options.selectedSetting.selected.length
|
|
1222
|
+
) {
|
|
1223
|
+
var extraIds = options.selectedSetting.selected.map(
|
|
1224
|
+
(s) => s.selectID
|
|
1225
|
+
);
|
|
1226
|
+
for (var i = geometries.length - 1; i > -1; i--) {
|
|
1227
|
+
var geom = geometries[i];
|
|
1228
|
+
if (
|
|
1229
|
+
extraIds.indexOf(
|
|
1230
|
+
geom.attributes[options.keyFieldName]
|
|
1231
|
+
) > -1
|
|
1232
|
+
) {
|
|
1233
|
+
geometries.splice(i, 1);
|
|
1234
|
+
extraGeometries.push(geom);
|
|
1235
|
+
if (extraGeometries.length === extraIds.length) break;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
var color = options.customColor
|
|
1240
|
+
? interpolateColor(
|
|
1241
|
+
options.customColor[0],
|
|
1242
|
+
options.customColor[1],
|
|
1243
|
+
Math.min(geometries.length, 10)
|
|
1244
|
+
)
|
|
1245
|
+
: 10;
|
|
1246
|
+
if (options.setFieldColor && options.layeredColor) {
|
|
1247
|
+
var colorConfig = options.layeredColor(geometries);
|
|
1248
|
+
geometries = colorConfig.data;
|
|
1249
|
+
color = colorConfig.color;
|
|
1250
|
+
}
|
|
1251
|
+
var lfcOpt = {
|
|
1252
|
+
minZoom: options.visiblitySetting.beginLevel,
|
|
1253
|
+
maxZoom: options.visiblitySetting.endLevel,
|
|
1254
|
+
layerId: options.layerName,
|
|
1255
|
+
comCallbak: callback,
|
|
1256
|
+
order: options.order,
|
|
1257
|
+
inverse: options.inverse,
|
|
1258
|
+
...options.option, // option的其他参数
|
|
1259
|
+
};
|
|
1260
|
+
if (options.labelSetting.labelZoomEnabled == 'show') {
|
|
1261
|
+
lfcOpt.labelMinZoom = options.labelSetting.labelMinZoom;
|
|
1262
|
+
lfcOpt.labelMaxZoom = options.labelSetting.labelMaxZoom;
|
|
1263
|
+
}
|
|
1264
|
+
gisMap.locateFeatureByCoords(
|
|
1265
|
+
geometries,
|
|
1266
|
+
'polygon',
|
|
1267
|
+
options.layerName, // id,如果已经有attributes就没用了
|
|
1268
|
+
options.style, // style
|
|
1269
|
+
options.highlightStyle, // highlightStyle
|
|
1270
|
+
options.commonSetting.zoom, // zoom
|
|
1271
|
+
options.keyFieldName,
|
|
1272
|
+
options.labelSetting.showLabel && options.labelFieldName, // keyField, labelField
|
|
1273
|
+
options.labelStyle, // labelStyle
|
|
1274
|
+
color,
|
|
1275
|
+
false, // renderCanvas
|
|
1276
|
+
true, // singleSelect
|
|
1277
|
+
lfcOpt,
|
|
1278
|
+
options.layerName, // layerTag
|
|
1279
|
+
options.eventSetting.clickCallback,
|
|
1280
|
+
options.eventSetting.mouseMoveCallback
|
|
1281
|
+
);
|
|
1282
|
+
if (extraGeometries.length) {
|
|
1283
|
+
var lfceOpt = {
|
|
1284
|
+
minZoom: options.visiblitySetting.beginLevel,
|
|
1285
|
+
maxZoom: options.visiblitySetting.endLevel,
|
|
1286
|
+
layerId: options.layerName,
|
|
1287
|
+
order: options.order,
|
|
1288
|
+
// hLabelStyle: options.hLabelStyle, // 选中文字时效果,没用
|
|
1289
|
+
};
|
|
1290
|
+
if (options.labelSetting.labelZoomEnabled == 'show') {
|
|
1291
|
+
lfceOpt.labelMinZoom = options.labelSetting.labelMinZoom;
|
|
1292
|
+
lfceOpt.labelMaxZoom = options.labelSetting.labelMaxZoom;
|
|
1293
|
+
}
|
|
1294
|
+
gisMap.locateFeatureByCoords(
|
|
1295
|
+
extraGeometries,
|
|
1296
|
+
'polygon',
|
|
1297
|
+
options.layerName, // id,如果已经有attributes就没用了
|
|
1298
|
+
options.specialAreaStyle, // style
|
|
1299
|
+
options.highlightStyle, // highlightStyle
|
|
1300
|
+
false, // zoom
|
|
1301
|
+
options.keyFieldName,
|
|
1302
|
+
options.selectedSetting.showLabel && options.labelFieldName, // keyField, labelField
|
|
1303
|
+
options.specialAreaLabelStyle, // labelStyle
|
|
1304
|
+
false, // randomColor
|
|
1305
|
+
false, // renderCanvas
|
|
1306
|
+
true, // singleSelect
|
|
1307
|
+
lfceOpt,
|
|
1308
|
+
options.layerName, // layerTag
|
|
1309
|
+
options.eventSetting.clickCallback,
|
|
1310
|
+
options.eventSetting.mouseMoveCallback
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
if (specialAreaS && specialAreaS.length > 0) {
|
|
1314
|
+
var lfcsOpt = {
|
|
1315
|
+
minZoom: options.visiblitySetting.beginLevel,
|
|
1316
|
+
maxZoom: options.visiblitySetting.endLevel,
|
|
1317
|
+
layerId: options.layerName,
|
|
1318
|
+
comCallbak: callback,
|
|
1319
|
+
order: options.order,
|
|
1320
|
+
// hLabelStyle: options.hLabelStyle, // 选中文字时效果,没用
|
|
1321
|
+
};
|
|
1322
|
+
if (options.labelSetting.labelZoomEnabled == 'show') {
|
|
1323
|
+
lfcsOpt.labelMinZoom = options.labelSetting.labelMinZoom;
|
|
1324
|
+
lfcsOpt.labelMaxZoom = options.labelSetting.labelMaxZoom;
|
|
1325
|
+
}
|
|
1326
|
+
for (var j = 0; j < specialAreaS.length; j++) {
|
|
1327
|
+
var specialArea = specialAreaS[j];
|
|
1328
|
+
if (specialArea.geometries.length > 0) {
|
|
1329
|
+
gisMap.locateFeatureByCoords(
|
|
1330
|
+
specialArea.geometries,
|
|
1331
|
+
'polygon',
|
|
1332
|
+
options.layerName, // id,如果已经有attributes就没用了
|
|
1333
|
+
specialArea.style, // style
|
|
1334
|
+
options.highlightStyle, // highlightStyle
|
|
1335
|
+
options.commonSetting.zoom, // zoom
|
|
1336
|
+
options.keyFieldName,
|
|
1337
|
+
specialArea.specialAreaStyle.textLabelShowEnabled &&
|
|
1338
|
+
specialArea.specialAreaStyle.labelFieldName, // keyField, labelField
|
|
1339
|
+
specialArea.labelStyle, // labelStyle
|
|
1340
|
+
false, // randomColor
|
|
1341
|
+
false, // renderCanvas
|
|
1342
|
+
true, // singleSelect
|
|
1343
|
+
lfcsOpt,
|
|
1344
|
+
options.layerName, // layerTag
|
|
1345
|
+
options.eventSetting.clickCallback,
|
|
1346
|
+
options.eventSetting.mouseMoveCallback
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
if (dataLoadCb) {
|
|
1352
|
+
dataLoadCb(true);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
if (!data) {
|
|
1357
|
+
// 数据来自本地
|
|
1358
|
+
var dbOpenRequest = window.indexedDB.open('regionDB');
|
|
1359
|
+
dbOpenRequest.onsuccess = function (event) {
|
|
1360
|
+
var db = this.result;
|
|
1361
|
+
var store = db.transaction(storeName).objectStore(storeName);
|
|
1362
|
+
var request = store.getAll();
|
|
1363
|
+
request.onsuccess = function () {
|
|
1364
|
+
var features = this.result;
|
|
1365
|
+
showGrid(features);
|
|
1366
|
+
};
|
|
1367
|
+
};
|
|
1368
|
+
} else {
|
|
1369
|
+
if (data.length == 0) {
|
|
1370
|
+
if (dataLoadCb) {
|
|
1371
|
+
dataLoadCb(false);
|
|
1372
|
+
}
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
var _data = JSON.parse(JSON.stringify(data[0]));
|
|
1376
|
+
var newData = data[0];
|
|
1377
|
+
if (newData && newData.geometry) {
|
|
1378
|
+
_data = JSON.parse(JSON.stringify(data));
|
|
1379
|
+
showGrid(data);
|
|
1380
|
+
} else {
|
|
1381
|
+
showGrid(data[0]);
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
var dbRequest = window.indexedDB.open('regionDB');
|
|
1385
|
+
dbRequest.onsuccess = function () {
|
|
1386
|
+
addStore(this.result.version);
|
|
1387
|
+
};
|
|
1388
|
+
function addStore(version) {
|
|
1389
|
+
var dbOpenRequest = window.indexedDB.open(
|
|
1390
|
+
'regionDB',
|
|
1391
|
+
version + 1
|
|
1392
|
+
);
|
|
1393
|
+
dbOpenRequest.onupgradeneeded = function (event) {
|
|
1394
|
+
var db = event.target.result;
|
|
1395
|
+
if (!db.objectStoreNames.contains(storeName)) {
|
|
1396
|
+
var store = db.createObjectStore(storeName, {
|
|
1397
|
+
autoIncrement: true,
|
|
1398
|
+
});
|
|
1399
|
+
for (var i = 0; i < _data.length; i++) {
|
|
1400
|
+
store.put(_data[i]);
|
|
1401
|
+
}
|
|
1402
|
+
store.transaction.oncomplete = function () {
|
|
1403
|
+
console.log('complete');
|
|
1404
|
+
};
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
this.networkCloud = function (options, positions) {
|
|
1412
|
+
if (!globeMap) {
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
globeMap.networkCloud(options, positions);
|
|
1416
|
+
};
|
|
1417
|
+
this.clearNetworkCloud = function (layerNames) {
|
|
1418
|
+
if (!globeMap) {
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
globeMap.clearNetworkCloud(layerNames);
|
|
1422
|
+
};
|
|
1423
|
+
this.lineOperation = function (options, data, dataLoadCb) {
|
|
1424
|
+
if (!options || !options.layerName) {
|
|
1425
|
+
console.log('图层名必须传递');
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
// 数据获取
|
|
1429
|
+
let queryFeature = (queryParams) => {
|
|
1430
|
+
if (gisMap) {
|
|
1431
|
+
return new Promise(function (resolve) {
|
|
1432
|
+
let cb = function (result) {
|
|
1433
|
+
resolve(result);
|
|
1434
|
+
};
|
|
1435
|
+
gisMap.queryFeature(queryParams, cb);
|
|
1436
|
+
});
|
|
1437
|
+
} else {
|
|
1438
|
+
return Promise.resolve(undefined);
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
// 执行绘制
|
|
1442
|
+
let drawLine = (options, data) => {
|
|
1443
|
+
if (globeMap) globeMap.lineOperation(options, data);
|
|
1444
|
+
else if (gisMap) {
|
|
1445
|
+
let style = options.style || {};
|
|
1446
|
+
let hStyle = options.hStyle || {};
|
|
1447
|
+
let symbol = {
|
|
1448
|
+
type: 'simple-line', // autocasts as new SimpleLineSymbol()
|
|
1449
|
+
color: style.color || 'lightblue',
|
|
1450
|
+
width: (style.width || 2) + 'px',
|
|
1451
|
+
style: style.style || 'short-dot',
|
|
1452
|
+
};
|
|
1453
|
+
let hsymbol = {
|
|
1454
|
+
type: 'simple-line', // autocasts as new SimpleLineSymbol()
|
|
1455
|
+
color: hStyle.color || 'lightblue',
|
|
1456
|
+
width: (hStyle.width || 2) + 'px',
|
|
1457
|
+
style: hStyle.style || 'short-dot',
|
|
1458
|
+
};
|
|
1459
|
+
var opt = options.options || {};
|
|
1460
|
+
gisMap.locateFeatureByCoords(
|
|
1461
|
+
data,
|
|
1462
|
+
options.type,
|
|
1463
|
+
options.id,
|
|
1464
|
+
symbol,
|
|
1465
|
+
hsymbol,
|
|
1466
|
+
options.zoom,
|
|
1467
|
+
options.keyField,
|
|
1468
|
+
options.labelField,
|
|
1469
|
+
options.labelStyle,
|
|
1470
|
+
options.randomColor,
|
|
1471
|
+
options.renderCanvas,
|
|
1472
|
+
options.singleSelected,
|
|
1473
|
+
opt,
|
|
1474
|
+
options.layerTag,
|
|
1475
|
+
options.callback
|
|
1476
|
+
);
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
|
|
1480
|
+
// 主逻辑
|
|
1481
|
+
if (!!data && data.length) {
|
|
1482
|
+
drawLine(options, data);
|
|
1483
|
+
} else {
|
|
1484
|
+
if (!options.usageID) {
|
|
1485
|
+
console.log('图层用途必须传递');
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
let originalData = false;
|
|
1490
|
+
if (globeMap) originalData = true;
|
|
1491
|
+
let queryParams = {
|
|
1492
|
+
layerID: options.usageID,
|
|
1493
|
+
where: options.filterString || '1=1',
|
|
1494
|
+
geometry: '',
|
|
1495
|
+
outGeometry: true,
|
|
1496
|
+
options: { originalData: originalData },
|
|
1497
|
+
};
|
|
1498
|
+
queryFeature(queryParams).then(function (resultData) {
|
|
1499
|
+
if (dataLoadCb && typeof dataLoadCb === 'function') {
|
|
1500
|
+
dataLoadCb(resultData);
|
|
1501
|
+
}
|
|
1502
|
+
if (!resultData) {
|
|
1503
|
+
console.log('没有查询到数据,请检查查询参数');
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
drawLine(options, resultData);
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
this.enableMapEvents = function (enablePan, enableZoom, callbackArray) {
|
|
1511
|
+
if (gisMap != null && mapType == 'map') {
|
|
1512
|
+
gisMap.enableMapEvents(enablePan, enableZoom, callbackArray);
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
this.setMapOpacity = function (opacity) {
|
|
1516
|
+
if (gisMap != null && mapType == 'map') {
|
|
1517
|
+
gisMap.setMapOpacity(opacity);
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
//地理坐标转屏幕坐标
|
|
1522
|
+
this.convertMapToScreen = function (list) {
|
|
1523
|
+
if (gisMap != null) {
|
|
1524
|
+
return gisMap.convertMapToScreen(list);
|
|
1525
|
+
}
|
|
1526
|
+
return list;
|
|
1527
|
+
};
|
|
1528
|
+
|
|
1529
|
+
// 屏幕坐标转地理坐标
|
|
1530
|
+
this.convertScreenToMap = function (list) {
|
|
1531
|
+
if (gisMap != null) {
|
|
1532
|
+
return gisMap.convertScreenToMap(list);
|
|
1533
|
+
}
|
|
1534
|
+
return list;
|
|
1535
|
+
};
|
|
1536
|
+
|
|
1537
|
+
//设置地下模式悟空
|
|
1538
|
+
this.SetTerrainAlpha = function (alpha) {
|
|
1539
|
+
if (globeMap != null) {
|
|
1540
|
+
globeMap.onUndergroundModel(alpha);
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
|
|
1544
|
+
// 二维引擎下加载图层目录树中的图层接口
|
|
1545
|
+
this.setTreeLayerShow = function (options, cb) {
|
|
1546
|
+
let mapInstance;
|
|
1547
|
+
if (gisMap != null && mapType == 'map') {
|
|
1548
|
+
mapInstance = gisMap;
|
|
1549
|
+
}
|
|
1550
|
+
mapInstance.setTreeLayerShow(options, cb);
|
|
1551
|
+
};
|
|
1552
|
+
|
|
1553
|
+
// 新版通用接口
|
|
1554
|
+
// 适配热力图,具体参数转换等逻辑在引擎层面实现,确保后续接口平替时只需要修改引擎层面即可
|
|
1555
|
+
this.heatMap = function (options, cb) {
|
|
1556
|
+
let mapInstance;
|
|
1557
|
+
if (globeMap != null && mapType == 'globe') {
|
|
1558
|
+
mapInstance = globeMap;
|
|
1559
|
+
} else if (gisMap != null && mapType == 'map') {
|
|
1560
|
+
mapInstance = gisMap;
|
|
1561
|
+
}
|
|
1562
|
+
mapInstance.heatMap(options, cb);
|
|
1563
|
+
};
|
|
1564
|
+
// 新版通用接口
|
|
1565
|
+
// 适配网格
|
|
1566
|
+
this.area = function (options, cb) {
|
|
1567
|
+
let mapInstance;
|
|
1568
|
+
if (globeMap != null && mapType == 'globe') {
|
|
1569
|
+
mapInstance = globeMap;
|
|
1570
|
+
} else if (gisMap != null && mapType == 'map') {
|
|
1571
|
+
mapInstance = gisMap;
|
|
1572
|
+
}
|
|
1573
|
+
mapInstance.area(options, cb);
|
|
1574
|
+
};
|
|
1575
|
+
// 新版通用接口
|
|
1576
|
+
// 适配网格
|
|
1577
|
+
this.line = function (options, cb) {
|
|
1578
|
+
let mapInstance;
|
|
1579
|
+
if (globeMap != null && mapType == 'globe') {
|
|
1580
|
+
mapInstance = globeMap;
|
|
1581
|
+
} else if (gisMap != null && mapType == 'map') {
|
|
1582
|
+
mapInstance = gisMap;
|
|
1583
|
+
}
|
|
1584
|
+
mapInstance.line(options, cb);
|
|
1585
|
+
};
|
|
1586
|
+
// webgl无人机机场接口
|
|
1587
|
+
this.addDock = function (options) {
|
|
1588
|
+
if (globeMap != null && mapType == 'globe') {
|
|
1589
|
+
globeMap.addDock(options);
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
// webgl十字聚焦特效
|
|
1593
|
+
this.lockOnPoint = function (options) {
|
|
1594
|
+
if (globeMap !== null && mapType === 'globe') {
|
|
1595
|
+
globeMap.lockOnPoint(options);
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
// 视锥体特效
|
|
1599
|
+
this.frustumOperation = function (options) {
|
|
1600
|
+
if (globeMap !== null && mapType === 'globe') {
|
|
1601
|
+
globeMap.frustumOperation(options);
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
// 新的机场区域效果
|
|
1605
|
+
this.globeImageryFocus = function (options) {
|
|
1606
|
+
if (globeMap !== null && mapType === 'globe') {
|
|
1607
|
+
globeMap.globeImageryFocus(options);
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1612
|
+
export default egovaBI;
|