@supermapgis/iclient-ol 11.1.2

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 (91) hide show
  1. package/README.md +56 -0
  2. package/control/ChangeTileVersion.js +438 -0
  3. package/control/Logo.js +99 -0
  4. package/control/ScaleLine.js +164 -0
  5. package/control/index.js +6 -0
  6. package/core/MapExtend.js +49 -0
  7. package/core/StyleUtils.js +1253 -0
  8. package/core/Util.js +478 -0
  9. package/core/index.js +6 -0
  10. package/css/ChangeTileVersion.css +347 -0
  11. package/css/index.js +5 -0
  12. package/dist/iclient-openlayers-es6.js +121806 -0
  13. package/dist/iclient-openlayers-es6.min.js +8 -0
  14. package/dist/iclient-openlayers.css +668 -0
  15. package/dist/iclient-openlayers.js +132335 -0
  16. package/dist/iclient-openlayers.min.css +8 -0
  17. package/dist/iclient-openlayers.min.js +8 -0
  18. package/index.js +9 -0
  19. package/mapping/BaiduMap.js +121 -0
  20. package/mapping/ImageSuperMapRest.js +252 -0
  21. package/mapping/ImageTileSuperMapRest.js +99 -0
  22. package/mapping/InitMap.js +125 -0
  23. package/mapping/SuperMapCloud.js +56 -0
  24. package/mapping/Tianditu.js +152 -0
  25. package/mapping/TileSuperMapRest.js +358 -0
  26. package/mapping/WebMap.js +5185 -0
  27. package/mapping/index.js +11 -0
  28. package/mapping/webmap/Util.js +176 -0
  29. package/mapping/webmap/config/MunicipalCenter.json +1 -0
  30. package/mapping/webmap/config/ProvinceCenter.json +1 -0
  31. package/mapping/webmap/config/SampleDataInfo.json +55 -0
  32. package/namespace.js +150 -0
  33. package/overlay/DataFlow.js +114 -0
  34. package/overlay/FGB.js +97 -0
  35. package/overlay/Graph.js +436 -0
  36. package/overlay/GraphMap.js +91 -0
  37. package/overlay/Graphic.js +587 -0
  38. package/overlay/HeatMap.js +444 -0
  39. package/overlay/Label.js +964 -0
  40. package/overlay/Mapv.js +146 -0
  41. package/overlay/Range.js +127 -0
  42. package/overlay/RankSymbol.js +94 -0
  43. package/overlay/Turf.js +298 -0
  44. package/overlay/Unique.js +123 -0
  45. package/overlay/VectorTileSuperMapRest.js +466 -0
  46. package/overlay/graphic/CanvasRenderer.js +177 -0
  47. package/overlay/graphic/CloverShape.js +133 -0
  48. package/overlay/graphic/Graphic.js +174 -0
  49. package/overlay/graphic/HitCloverShape.js +63 -0
  50. package/overlay/graphic/WebGLRenderer.js +356 -0
  51. package/overlay/graphic/index.js +9 -0
  52. package/overlay/index.js +21 -0
  53. package/overlay/mapv/MapvCanvasLayer.js +104 -0
  54. package/overlay/mapv/MapvLayer.js +410 -0
  55. package/overlay/mapv/index.js +5 -0
  56. package/overlay/theme/GeoFeature.js +275 -0
  57. package/overlay/theme/Theme.js +585 -0
  58. package/overlay/theme/ThemeFeature.js +46 -0
  59. package/overlay/theme/index.js +6 -0
  60. package/overlay/vectortile/DeafultCanvasStyle.js +125 -0
  61. package/overlay/vectortile/MapboxStyles.js +375 -0
  62. package/overlay/vectortile/StyleMap.js +252 -0
  63. package/overlay/vectortile/VectorTileStyles.js +554 -0
  64. package/overlay/vectortile/index.js +7 -0
  65. package/overlay/vectortile/olExtends.js +382 -0
  66. package/package.json +29 -0
  67. package/services/AddressMatchService.js +60 -0
  68. package/services/ChartService.js +74 -0
  69. package/services/DataFlowService.js +118 -0
  70. package/services/DatasetService.js +104 -0
  71. package/services/DatasourceService.js +76 -0
  72. package/services/FeatureService.js +196 -0
  73. package/services/FieldService.js +53 -0
  74. package/services/GeoprocessingService.js +156 -0
  75. package/services/GridCellInfosService.js +53 -0
  76. package/services/ImageCollectionService.js +92 -0
  77. package/services/ImageService.js +69 -0
  78. package/services/KnowledgeGraphService.js +82 -0
  79. package/services/LayerInfoService.js +85 -0
  80. package/services/MapService.js +85 -0
  81. package/services/MeasureService.js +77 -0
  82. package/services/NetworkAnalyst3DService.js +88 -0
  83. package/services/NetworkAnalystService.js +252 -0
  84. package/services/ProcessingService.js +478 -0
  85. package/services/QueryService.js +116 -0
  86. package/services/ServiceBase.js +26 -0
  87. package/services/SpatialAnalystService.js +432 -0
  88. package/services/ThemeService.js +50 -0
  89. package/services/TrafficTransferAnalystService.js +88 -0
  90. package/services/WebPrintingJobService.js +112 -0
  91. package/services/index.js +27 -0
@@ -0,0 +1,554 @@
1
+ /* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
2
+ * This program are made available under the terms of the Apache License, Version 2.0
3
+ * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
+ import { Util as CommonUtil} from '@supermapgis/iclient-common/commontypes/Util';
5
+ import { Unit } from '@supermapgis/iclient-common/REST';
6
+ import { CartoCSS } from '@supermapgis/iclient-common/style/CartoCSS';
7
+ import { JSONFormat } from '@supermapgis/iclient-common/format/JSON';
8
+ import {StyleUtils} from '../../core/StyleUtils';
9
+ import {Util} from '../../core/Util';
10
+ import Observable from 'ol/Observable';
11
+ import Style from 'ol/style/Style';
12
+ import CircleStyle from 'ol/style/Circle';
13
+ import FillStyle from 'ol/style/Fill';
14
+ import StrokeStyle from 'ol/style/Stroke';
15
+ import Text from 'ol/style/Text';
16
+ /**
17
+ * @class VectorTileStyles
18
+ * @classdesc 矢量瓦片风格。
19
+ * @modulecategory Overlay
20
+ * @category Visualization VectorTile
21
+ * @param {Object} options - 交互时所需可选参数。
22
+ * @extends {ol.Observable}
23
+ * @usage
24
+ */
25
+ export class VectorTileStyles extends Observable {
26
+
27
+ constructor(options) {
28
+ super();
29
+ if (!options) {
30
+ return;
31
+ }
32
+ var donotNeedServerCartoCss = false;
33
+ if (options.donotNeedServerCartoCss !== undefined) {
34
+ donotNeedServerCartoCss = options.donotNeedServerCartoCss
35
+ }
36
+ VectorTileStyles.setDonotNeedServerCartoCss(donotNeedServerCartoCss);
37
+ if (options.view) {
38
+ VectorTileStyles.setView(options.view);
39
+ }
40
+ if (options.url) {
41
+ VectorTileStyles.setUrl(options.url);
42
+ }
43
+ if (options.cartoCss) {
44
+ VectorTileStyles.setCartoCss(options.cartoCss);
45
+ }
46
+ var selectedPointStyle = getDefaultSelectedPointStyle();
47
+ if (options.selectedPointStyle) {
48
+ selectedPointStyle = options.selectedPointStyle;
49
+ }
50
+ VectorTileStyles.setSelectedPointStyle(selectedPointStyle);
51
+ var selectedLineStyle = getDefaultSelectedLineStyle();
52
+ if (options.selectedLineStyle) {
53
+ selectedLineStyle = options.selectedLineStyle;
54
+ }
55
+ VectorTileStyles.setSelectedLineStyle(selectedLineStyle);
56
+ var selectedRegionStyle = getDefaultSelectedRegionStyle();
57
+ if (options.selectedRegionStyle) {
58
+ selectedRegionStyle = options.selectedRegionStyle;
59
+ }
60
+ VectorTileStyles.setSelectedRegionStyle(selectedRegionStyle);
61
+ var selectedTextStyle = getDefaultSelectedTextStyle();
62
+ if (options.selectedTextStyle) {
63
+ selectedTextStyle = options.selectedTextStyle;
64
+ }
65
+ VectorTileStyles.setSelectedTextStyle(selectedTextStyle);
66
+ var layersXHR = new XMLHttpRequest();
67
+ layersXHR.onreadystatechange = function () {
68
+ if (layersXHR.readyState == 4) {
69
+ var result = JSON.parse(layersXHR.responseText);
70
+ var layersInfo = {};
71
+ for (var i = 0, len = result.length; i < len; i++) {
72
+ var layers = result[i].subLayers.layers;
73
+ for (var j = 0, len1 = layers.length; j < len1; j++) {
74
+ layers[j].layerIndex = len1 - j;
75
+ layersInfo[layers[j].name] = layers[j];
76
+ }
77
+ }
78
+ VectorTileStyles.setLayersInfo(layersInfo);
79
+ if (!VectorTileStyles.getDonotNeedServerCartoCss()) {
80
+ var vectorStylesXHR = new XMLHttpRequest();
81
+ vectorStylesXHR.open("GET", CommonUtil.urlPathAppend(VectorTileStyles.getUrl(), "tileFeature/vectorstyles.json"), false);
82
+ vectorStylesXHR.onreadystatechange = function () {
83
+ if (vectorStylesXHR.readyState == 4) {
84
+ var vectorStyles = new JSONFormat().read(vectorStylesXHR.responseText);
85
+ var cartoCss;
86
+ if (vectorStyles.style && vectorStyles.type === 'cartoCSS') {
87
+ cartoCss = vectorStyles.style;
88
+ cartoCss = cartoCss.replace(/[@]/gi, "___");
89
+ cartoCss = cartoCss.replace(/\\#/gi, "___");
90
+ //替换一些关键符号
91
+ var cachedLayer = {};
92
+ layersInfo && Object.keys(layersInfo).sort().forEach(function (attr) {
93
+ var newAttr = attr.replace(/[@#\s]/gi, "___");
94
+ var to = attr;
95
+ var keys = Object.keys(cachedLayer);
96
+ for (let index = keys.length; index > -1; index--) {
97
+ if (attr.indexOf(keys[index]) > -1) {
98
+ to = attr.replace(keys[index], cachedLayer[keys[index]]);
99
+ break;
100
+ }
101
+ }
102
+ to = to.replace(/[#]/gi, "\#");
103
+ cachedLayer[attr] = newAttr;
104
+ cartoCss = cartoCss.replace(new RegExp(to, "g"), newAttr);
105
+ })
106
+ cartoCss = cartoCss.replace(/[#]/gi, "\n#");
107
+ //将zoom转化为scale,以免引起混淆
108
+ cartoCss = cartoCss.replace(/\[zoom/gi, "[scale");
109
+ }
110
+ var cartoShadersArray = new CartoCSS(cartoCss).getShaders();
111
+ var cartoShaders = {};
112
+ cartoShadersArray.forEach(function (cartoShader) {
113
+ cartoShaders[cartoShader.elements[0].clean] = cartoShaders[cartoShader.elements[0].clean] || {};
114
+ cartoShaders[cartoShader.elements[0].clean][cartoShader.attachment] = cartoShaders[cartoShader.elements[0].clean][cartoShader.attachment] || [];
115
+ cartoShaders[cartoShader.elements[0].clean][cartoShader.attachment].push(cartoShader);
116
+ return cartoShader;
117
+ });
118
+ VectorTileStyles.setCartoShaders(cartoShaders);
119
+ }
120
+ };
121
+ vectorStylesXHR.send(null);
122
+ }
123
+ if (VectorTileStyles.getCartoCss()) {
124
+ var clientCartoShadersArray = new CartoCSS(VectorTileStyles.getCartoCss()).getShaders();
125
+ var clientCartoShaders = {};
126
+ clientCartoShadersArray.forEach(function (cartoShader) {
127
+ clientCartoShaders[cartoShader.elements[0].clean] = clientCartoShaders[cartoShader.elements[0].clean] || {};
128
+ clientCartoShaders[cartoShader.elements[0].clean][cartoShader.attachment] = clientCartoShaders[cartoShader.elements[0].clean][cartoShader.attachment] || [];
129
+ clientCartoShaders[cartoShader.elements[0].clean][cartoShader.attachment].push(cartoShader);
130
+ return cartoShader;
131
+ });
132
+ VectorTileStyles.setClientCartoShaders(clientCartoShaders);
133
+ }
134
+ }
135
+ };
136
+ layersXHR.open("GET", CommonUtil.urlPathAppend(VectorTileStyles.getUrl(), "layers.json"), false);
137
+ layersXHR.send(null);
138
+ this.on('featureSelected', function (e) {
139
+ VectorTileStyles.setSelectedId(e.selectedId);
140
+ VectorTileStyles.setLayerName(e.layerName);
141
+ });
142
+
143
+ /**
144
+ * @function VectorTileStyles.prototype.getDefaultSelectedPointStyle
145
+ * @description 设置默认选择后的点样式。
146
+ */
147
+ function getDefaultSelectedPointStyle() {
148
+ return new Style({
149
+ image: new CircleStyle({
150
+ radius: 5,
151
+ fill: new FillStyle({
152
+ color: 'blue'
153
+ })
154
+ })
155
+ })
156
+ }
157
+
158
+ /**
159
+ * @function VectorTileStyles.prototype.getDefaultSelectedLineStyle
160
+ * @description 设置默认选择后的线样式。
161
+ */
162
+ function getDefaultSelectedLineStyle() {
163
+ return new Style({
164
+ stroke: new StrokeStyle({
165
+ color: 'blue',
166
+ width: 3
167
+ })
168
+ })
169
+ }
170
+
171
+ /**
172
+ * @function VectorTileStyles.prototype.getDefaultSelectedRegionStyle
173
+ * @description 设置默认选择后的面样式。
174
+ */
175
+ function getDefaultSelectedRegionStyle() {
176
+ return new Style({
177
+ fill: new FillStyle({
178
+ color: [0, 0, 255, 0.5]
179
+ }),
180
+ stroke: new StrokeStyle({
181
+ color: 'blue',
182
+ width: 3
183
+ })
184
+ })
185
+ }
186
+
187
+ /**
188
+ * @function VectorTileStyles.prototype.getDefaultSelectedTextStyle
189
+ * @description 设置默认选择后的文本样式。
190
+ */
191
+ function getDefaultSelectedTextStyle() {
192
+ return new Style({
193
+ text: new Text({
194
+ font: '15px Microsoft YaHei',
195
+ fill: new FillStyle({
196
+ color: 'blue'
197
+ }),
198
+ stroke: new StrokeStyle({
199
+ color: 'white',
200
+ width: 1
201
+ })
202
+ })
203
+ });
204
+ }
205
+ }
206
+
207
+ /**
208
+ * @function VectorTileStyles.setCartoShaders
209
+ * @description 设置服务端 Carto 的阴影。
210
+ * @param {Array} cartoShaders - 服务端 Carto 阴影。
211
+ */
212
+ static setCartoShaders(cartoShaders) {
213
+ this.cartoShaders = cartoShaders;
214
+ }
215
+
216
+ /**
217
+ * @function VectorTileStyles.getCartoShaders
218
+ * @description 获取服务端 Carto 的阴影。
219
+ */
220
+ static getCartoShaders() {
221
+ return this.cartoShaders;
222
+ }
223
+
224
+ /**
225
+ * @function VectorTileStyles.setClientCartoShaders
226
+ * @description 设置客户端 Carto 的阴影。
227
+ * @param {Array} clientCartoShaders - 客户端 Carto 阴影。
228
+ */
229
+ static setClientCartoShaders(clientCartoShaders) {
230
+ this.clientCartoShaders = clientCartoShaders;
231
+ }
232
+
233
+ /**
234
+ * @function VectorTileStyles.getClientCartoShaders
235
+ * @description 获取客户端 Carto 的阴影。
236
+ */
237
+ static getClientCartoShaders() {
238
+ return this.clientCartoShaders;
239
+ }
240
+
241
+ /**
242
+ * @function VectorTileStyles.setCartoCss
243
+ * @description 设置 CartoCSS 的样式。
244
+ * @param {Object} cartoCss - CartoCSS 的样式。
245
+ */
246
+ static setCartoCss(cartoCss) {
247
+ this.cartoCss = cartoCss;
248
+ }
249
+
250
+ /**
251
+ * @function VectorTileStyles.getCartoCss
252
+ * @description 获取 CartoCSS 的样式。
253
+ */
254
+ static getCartoCss() {
255
+ return this.cartoCss;
256
+ }
257
+
258
+ /**
259
+ * @function VectorTileStyles.setDonotNeedServerCartoCss
260
+ * @description 设置是否需要 CartoCss 服务。
261
+ * @param {Object} donotNeedServerCartoCss - 是否需要 CartoCss 服务。
262
+ */
263
+ static setDonotNeedServerCartoCss(donotNeedServerCartoCss) {
264
+ this.donotNeedServerCartoCss = donotNeedServerCartoCss;
265
+ }
266
+
267
+ /**
268
+ * @function VectorTileStyles.getDonotNeedServerCartoCss
269
+ * @description 获取是否需要 CartoCss 服务。
270
+ */
271
+ static getDonotNeedServerCartoCss() {
272
+ return this.donotNeedServerCartoCss;
273
+ }
274
+
275
+ /**
276
+ * @function VectorTileStyles.setLayersInfo
277
+ * @description 设置图层信息服务。
278
+ * @param {Object} layersInfo - 图层信息。
279
+ */
280
+ static setLayersInfo(layersInfo) {
281
+ this.layersInfo = layersInfo;
282
+ }
283
+
284
+ /**
285
+ * @function VectorTileStyles.getLayersInfo
286
+ * @description 获取图层信息服务。
287
+ */
288
+ static getLayersInfo() {
289
+ return this.layersInfo;
290
+ }
291
+
292
+ /**
293
+ * @function VectorTileStyles.setUrl
294
+ * @description 设置地址。
295
+ * @param {string} url - 地址。
296
+ */
297
+ static setUrl(url) {
298
+ this.url = url;
299
+ }
300
+
301
+ /**
302
+ * @function VectorTileStyles.getUrl
303
+ * @description 获取地址。
304
+ */
305
+ static getUrl() {
306
+ return this.url;
307
+ }
308
+
309
+ /**
310
+ * @function VectorTileStyles.setView
311
+ * @description 设置视图。
312
+ * @param {Object} view - 视图。
313
+ */
314
+ static setView(view) {
315
+ this.view = view;
316
+ }
317
+
318
+ /**
319
+ * @function VectorTileStyles.getView
320
+ * @description 获取视图。
321
+ */
322
+ static getView() {
323
+ return this.view;
324
+ }
325
+
326
+ /**
327
+ * @function VectorTileStyles.setSelectedId
328
+ * @description 设置选择序号。
329
+ * @param {number} selectedId - 选择序号。
330
+ */
331
+ static setSelectedId(selectedId) {
332
+ this.selectedId = selectedId;
333
+ }
334
+
335
+ /**
336
+ * @function VectorTileStyles.getSelectedId
337
+ * @description 获取选择序号。
338
+ */
339
+ static getSelectedId() {
340
+ return this.selectedId;
341
+ }
342
+
343
+ /**
344
+ * @function VectorTileStyles.setLayerName
345
+ * @description 设置图层名称。
346
+ * @param {string} layerName - 图层名称。
347
+ */
348
+ static setLayerName(layerName) {
349
+ this.layerName = layerName;
350
+ }
351
+
352
+ /**
353
+ * @function VectorTileStyles.getLayerName
354
+ * @description 获取图层名称。
355
+ */
356
+ static getLayerName() {
357
+ return this.layerName;
358
+ }
359
+
360
+ /**
361
+ * @function VectorTileStyles.setSelectedPointStyle
362
+ * @description 设置选择后点样式。
363
+ * @param {Object} selectedPointStyle - 选择后点样式。
364
+ */
365
+ static setSelectedPointStyle(selectedPointStyle) {
366
+ this.selectedPointStyle = selectedPointStyle;
367
+ }
368
+
369
+ /**
370
+ * @function VectorTileStyles.setSelectedLineStyle
371
+ * @description 设置选择后线样式。
372
+ * @param {Object} selectedLineStyle - 选择后线样式。
373
+ */
374
+ static setSelectedLineStyle(selectedLineStyle) {
375
+ this.selectedLineStyle = selectedLineStyle;
376
+ }
377
+
378
+ /**
379
+ * @function VectorTileStyles.setSelectedRegionStyle
380
+ * @description 设置选择后面样式。
381
+ * @param {Object} selectedRegionStyle - 选择后面样式。
382
+ */
383
+ static setSelectedRegionStyle(selectedRegionStyle) {
384
+ this.selectedRegionStyle = selectedRegionStyle;
385
+ }
386
+
387
+ /**
388
+ * @function VectorTileStyles.setSelectedTextStyle
389
+ * @description 设置选择后文本样式。
390
+ * @param {Object} selectedTextStyle - 选择后文本样式。
391
+ */
392
+ static setSelectedTextStyle(selectedTextStyle) {
393
+ this.selectedTextStyle = selectedTextStyle;
394
+ }
395
+
396
+ /**
397
+ * @function VectorTileStyles.getSelectedStyle
398
+ * @description 设置选择后的样式。
399
+ * @param {string} type - 选择后的样式。
400
+ */
401
+ static getSelectedStyle(type) {
402
+ if (type === 'POINT' || type === 'MULTIPOINT') {
403
+ return this.selectedPointStyle;
404
+ }
405
+ if (type === 'LINESTRING' || type === 'MULTILINESTRING') {
406
+ return this.selectedLineStyle;
407
+ }
408
+ if (type === 'POLYGON' || type === 'MULTIPOLYGON') {
409
+ return this.selectedRegionStyle;
410
+ }
411
+ if (type === 'TEXT') {
412
+ return this.selectedTextStyle;
413
+ }
414
+ }
415
+
416
+ /**
417
+ * @function VectorTileStyles.getLayerInfo
418
+ * @description 获取图层的信息。
419
+ * @param {string} layerName - 图层名。
420
+ */
421
+ static getLayerInfo(layerName) {
422
+ var layersInfo = VectorTileStyles.getLayersInfo();
423
+ if (layersInfo === undefined) {
424
+ return null;
425
+ }
426
+ var layerInfo = layersInfo[layerName];
427
+ if (!layerInfo) {
428
+ return null;
429
+ }
430
+ var layerInfo_simple = {layerIndex: layerInfo.layerIndex, ugcLayerType: layerInfo.ugcLayerType};
431
+ switch (layerInfo.ugcLayerType) {
432
+ case "VECTOR":
433
+ layerInfo_simple.layerStyle = layerInfo.style ? layerInfo.style : null;
434
+ break;
435
+ case "THEME":
436
+ var theme = layerInfo.theme;
437
+ layerInfo_simple.layerStyle = theme ? theme.defaultStyle : null;
438
+ if (theme && theme.type === "LABEL") {
439
+ layerInfo_simple.type = theme.type;
440
+ layerInfo_simple.textField = theme.labelExpression;
441
+ }
442
+ break;
443
+ default :
444
+ //SVTile发布出来的地图没有ugcLayerType属性
445
+ if (layerInfo.style) {
446
+ layerInfo_simple.layerStyle = layerInfo.style;
447
+ }
448
+ break;
449
+ }
450
+ return layerInfo_simple;
451
+ }
452
+
453
+ /**
454
+ * @function VectorTileStyles.getStyle
455
+ * @description 获取样式。
456
+ * @param {string} originalLayerName - 原始图层信息。
457
+ * @param {Object} feature - 要素对象。
458
+ */
459
+ static getStyle(originalLayerName, feature) {
460
+ var url = VectorTileStyles.getUrl(),
461
+ view = VectorTileStyles.getView(),
462
+ zoom = view.getZoom(),
463
+ dpi = 96,
464
+ scale = Util.resolutionToScale(view.getResolution(), dpi, Unit.METER),
465
+ layerName = originalLayerName.replace(/(@)/gi, '___').replace(/(#)/gi, '___');
466
+ // feature对象样式的配置遵循以下优先级:
467
+ // 客户端CartoCSS > 服务器端CartoCSS > 服务器端layer样式 > 客户端默认样式。
468
+ if (VectorTileStyles.getCartoCss() && VectorTileStyles.getClientCartoShaders()[layerName]) {
469
+ return getStyleArray(VectorTileStyles.getClientCartoShaders()[layerName]);
470
+ }
471
+ var layerInfo = VectorTileStyles.getLayerInfo(originalLayerName);
472
+ if (!VectorTileStyles.getDonotNeedServerCartoCss() && VectorTileStyles.getCartoShaders()[layerName]) {
473
+ //如果是文本,这里特殊处理。
474
+ if (feature.getProperties().textStyle || feature.getProperties().TEXT_FEATURE_CONTENT || layerInfo.type == 'LABEL' && layerInfo.textField) {
475
+ var featureStyle = StyleUtils.getValidStyleFromLayerInfo(layerInfo, feature, url);
476
+ if (feature.getGeometry().getType().toUpperCase() === "POINT") {
477
+ featureStyle = mergeTextFeatureStyle(layerInfo, feature, url);
478
+ }
479
+ return featureStyle;
480
+ }
481
+ return getStyleArray(VectorTileStyles.getCartoShaders()[layerName]);
482
+ }
483
+ if (layerInfo) {
484
+ return StyleUtils.getValidStyleFromLayerInfo(layerInfo, feature, url);
485
+ }
486
+
487
+ function getStyleArray(shaderAttachment) {
488
+ var styleArray = [];
489
+ for (var j in shaderAttachment) {
490
+ shaderAttachment[j].map(function (shader) {
491
+ styleArray.push(StyleUtils.getStyleFromCarto(zoom, scale, shader, feature, true, url))
492
+ return shader;
493
+ })
494
+ }
495
+ return styleArray;
496
+ }
497
+
498
+ /**
499
+ * @function VectorTileStyles.prototype.mergeTextFeatureStyle
500
+ * @description 合并文本要素样式。
501
+ * @param {string} layerInfo - 图层信息。
502
+ * @param {Object} feature - 获取的要素。
503
+ * @param {string} url - 服务地址。
504
+ */
505
+ function mergeTextFeatureStyle(layerInfo, feature, url) {
506
+ var textFeatureStyle = StyleUtils.getValidStyleFromLayerInfo(layerInfo, feature, url);
507
+ if (layerInfo.type == 'LABEL') {
508
+ feature.setProperties({type: "TEXT"});
509
+ var cartoTextStyles = getStyleArray(VectorTileStyles.getCartoShaders()[layerName]);
510
+ var textStyle = textFeatureStyle.getText();
511
+ for (var i = 0; i < cartoTextStyles.length; i++) {
512
+ if (!textStyle) {
513
+ textStyle = cartoTextStyles[i].getText();
514
+ } else {
515
+ textStyle.setText(cartoTextStyles[i].getText().getText());
516
+ }
517
+ }
518
+ textFeatureStyle.setText(textStyle);
519
+ return textFeatureStyle;
520
+ }
521
+ return textFeatureStyle;
522
+ }
523
+
524
+ }
525
+
526
+ /**
527
+ * @function VectorTileStyles.prototype.getFeatureStyle
528
+ * @description 获取要素样式。
529
+ * @param {Object} feature - 要素。
530
+ */
531
+ getFeatureStyle(feature) {
532
+ var selectedStyle;
533
+ var layerName = feature.getProperties().layerName || feature.getProperties().layer;
534
+ var id = feature.getProperties().id || parseInt(feature.getProperties().SmID);
535
+ if (feature.getProperties().type && feature.getProperties().type.toUpperCase() === 'TEXT') {
536
+ selectedStyle = VectorTileStyles.getSelectedStyle(feature.getProperties().type.toUpperCase());
537
+ if (feature.getProperties().texts) {
538
+ selectedStyle.getText().text_ = feature.getProperties().texts[0];
539
+ } else {
540
+ selectedStyle.getText().text_ = "";
541
+ }
542
+ } else {
543
+ selectedStyle = VectorTileStyles.getSelectedStyle(feature.getGeometry().getType().toUpperCase());
544
+ }
545
+ if (selectedStyle) {
546
+ var selectedLayerName = VectorTileStyles.getLayerName();
547
+ var selectedId = VectorTileStyles.getSelectedId();
548
+ if (selectedLayerName === layerName && id === selectedId) {
549
+ return selectedStyle;
550
+ }
551
+ }
552
+ return VectorTileStyles.getStyle(layerName, feature);
553
+ }
554
+ }
@@ -0,0 +1,7 @@
1
+ /* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
2
+ * This program are made available under the terms of the Apache License, Version 2.0
3
+ * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
+ export { pointStyle, lineStyle, polygonStyle, DeafultCanvasStyle } from './DeafultCanvasStyle';
5
+ export { pointMap, lineMap, polygonMap, StyleMap } from './StyleMap';
6
+ export { VectorTileStyles } from './VectorTileStyles';
7
+ export { MapboxStyles } from './MapboxStyles';