egovamap 0.35.23 → 0.35.24

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