mars3d-supermap 3.4.9 → 3.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mars3d-supermap.js +51 -89
- package/package.json +2 -2
package/dist/mars3d-supermap.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mars3D平台插件,结合supermap超图库使用的功能插件 mars3d-supermap
|
|
3
3
|
*
|
|
4
|
-
* 版本信息:v3.4.
|
|
5
|
-
* 编译日期:2022-10-
|
|
4
|
+
* 版本信息:v3.4.10
|
|
5
|
+
* 编译日期:2022-10-17 17:26:22
|
|
6
6
|
* 版权所有:Copyright by 火星科技 http://mars3d.cn
|
|
7
7
|
* 使用单位:免费公开版 ,2022-06-01
|
|
8
8
|
*/
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
const Cesium$2 = mars3d__namespace.Cesium;
|
|
36
36
|
const BaseLayer$1 = mars3d__namespace.layer.BaseLayer;
|
|
37
|
+
|
|
37
38
|
/**
|
|
38
39
|
* 超图S3M三维模型图层,
|
|
39
40
|
* 【需要引入 mars3d-supermap 插件库】
|
|
@@ -63,7 +64,6 @@
|
|
|
63
64
|
* @class S3MLayer
|
|
64
65
|
* @extends {BaseLayer}
|
|
65
66
|
*/
|
|
66
|
-
|
|
67
67
|
class S3MLayer extends BaseLayer$1 {
|
|
68
68
|
/**
|
|
69
69
|
* 模型对应的Cesium.S3MTilesLayer图层组
|
|
@@ -74,64 +74,54 @@
|
|
|
74
74
|
get layer() {
|
|
75
75
|
return this._layerArr;
|
|
76
76
|
}
|
|
77
|
+
|
|
77
78
|
/**
|
|
78
79
|
* 设置S3M图层本身支持的参数
|
|
79
80
|
* @type {Object}
|
|
80
81
|
* @see [S3M支持的参数]{@link http://support.supermap.com.cn:8090/webgl/docs/Documentation/S3MTilesLayer.html?classFilter=S3MTilesLayer}
|
|
81
82
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
83
|
get s3mOptions() {
|
|
85
84
|
return this.options.s3mOptions;
|
|
86
85
|
}
|
|
87
|
-
|
|
88
86
|
set s3mOptions(value) {
|
|
89
87
|
for (const key in value) {
|
|
90
88
|
let val = value[key];
|
|
91
89
|
this.options.s3mOptions[key] = val;
|
|
92
|
-
|
|
93
90
|
if (key === "transparentBackColor") {
|
|
94
91
|
// 去黑边,与offset互斥,注意别配置offset
|
|
95
92
|
val = Cesium$2.Color.fromCssColorString(val);
|
|
96
93
|
} else if (key === "transparentBackColorTolerance") {
|
|
97
94
|
val = Number(val);
|
|
98
95
|
}
|
|
99
|
-
|
|
100
96
|
for (let i = 0; i < this._layerArr.length; i++) {
|
|
101
97
|
const layer = this._layerArr[i];
|
|
102
|
-
|
|
103
98
|
if (layer == null) {
|
|
104
99
|
continue;
|
|
105
100
|
}
|
|
106
|
-
|
|
107
101
|
layer[key] = val;
|
|
108
102
|
}
|
|
109
103
|
}
|
|
110
104
|
}
|
|
111
|
-
|
|
112
105
|
_showHook(show) {
|
|
113
106
|
this.eachLayer(layer => {
|
|
114
107
|
layer.visible = show; // 不同超图版本,有的是visible,有的是show
|
|
115
|
-
|
|
116
108
|
layer.show = show;
|
|
117
109
|
}, this);
|
|
118
110
|
}
|
|
111
|
+
|
|
119
112
|
/**
|
|
120
113
|
* 对象添加到地图前创建一些对象的钩子方法,
|
|
121
114
|
* 只会调用一次
|
|
122
115
|
* @return {void} 无
|
|
123
116
|
* @private
|
|
124
117
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
118
|
_mountedHook() {
|
|
128
119
|
if (!this._map.scene.open) {
|
|
129
120
|
throw new Error("请引入 超图版本Cesium库 或 超图S3M插件 ");
|
|
130
|
-
}
|
|
131
|
-
|
|
121
|
+
}
|
|
132
122
|
|
|
123
|
+
// 场景添加S3M图层服务
|
|
133
124
|
let promise;
|
|
134
|
-
|
|
135
125
|
if (this.options.layername) {
|
|
136
126
|
promise = this._map.scene.addS3MTilesLayerByScp(this.options.url, {
|
|
137
127
|
name: this.options.layername,
|
|
@@ -143,55 +133,47 @@
|
|
|
143
133
|
autoSetVie: this.options.flyTo
|
|
144
134
|
});
|
|
145
135
|
}
|
|
146
|
-
|
|
147
136
|
promise.then(smLayer => {
|
|
148
137
|
if (Array.isArray(smLayer)) {
|
|
149
138
|
this._layerArr = smLayer;
|
|
150
139
|
} else {
|
|
151
140
|
this._layerArr = [smLayer];
|
|
152
141
|
}
|
|
153
|
-
|
|
154
142
|
for (let i = 0; i < this._layerArr.length; i++) {
|
|
155
143
|
const layer = this._layerArr[i];
|
|
156
|
-
|
|
157
144
|
if (!layer) {
|
|
158
145
|
continue;
|
|
159
146
|
}
|
|
160
|
-
|
|
161
147
|
try {
|
|
162
148
|
this._initModelItem(layer);
|
|
163
149
|
} catch (e) {
|
|
164
150
|
mars3d__namespace.Log.logError("s3m图层初始化出错", e);
|
|
165
151
|
}
|
|
166
152
|
}
|
|
167
|
-
|
|
168
153
|
this._showHook(this.show);
|
|
169
|
-
|
|
170
154
|
if (this.options.flyTo) {
|
|
171
155
|
this.flyToByAnimationEnd();
|
|
172
156
|
}
|
|
173
|
-
|
|
174
157
|
this._readyPromise.resolve(this);
|
|
175
|
-
|
|
176
158
|
this.fire(mars3d__namespace.EventType.load, {
|
|
177
159
|
layers: this._layerArr
|
|
178
160
|
});
|
|
179
161
|
}, error => {
|
|
180
162
|
this._readyPromise && this._readyPromise.reject(error);
|
|
181
|
-
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// this._map.viewer.pickEvent.addEventListener(function (feature) {
|
|
182
166
|
// debugger;
|
|
183
167
|
// });
|
|
184
|
-
}
|
|
185
|
-
|
|
168
|
+
}
|
|
186
169
|
|
|
170
|
+
// 对单个s3m图层处理
|
|
187
171
|
_initModelItem(layer) {
|
|
188
172
|
var _this$options, _this$options$positio;
|
|
189
|
-
|
|
190
173
|
// 图层参数合并
|
|
191
174
|
if (this.options.s3mOptions) {
|
|
192
175
|
for (const key in this.options.s3mOptions) {
|
|
193
176
|
const val = this.options.s3mOptions[key];
|
|
194
|
-
|
|
195
177
|
if (key === "transparentBackColor") {
|
|
196
178
|
layer[key] = Cesium$2.Color.fromCssColorString(val); // 去黑边
|
|
197
179
|
} else if (key === "transparentBackColorTolerance") {
|
|
@@ -200,45 +182,43 @@
|
|
|
200
182
|
layer[key] = val;
|
|
201
183
|
}
|
|
202
184
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
185
|
+
}
|
|
205
186
|
|
|
187
|
+
// 选中颜色
|
|
206
188
|
if (this.options.highlight) {
|
|
207
189
|
layer.selectedColor = mars3d__namespace.Util.getColorByStyle(this.options.highlight);
|
|
208
|
-
}
|
|
209
|
-
|
|
190
|
+
}
|
|
210
191
|
|
|
192
|
+
// 高度调整
|
|
211
193
|
if ((_this$options = this.options) !== null && _this$options !== void 0 && (_this$options$positio = _this$options.position) !== null && _this$options$positio !== void 0 && _this$options$positio.alt) {
|
|
212
194
|
layer.style3D.altitudeMode = Cesium$2.HeightReference.NONE;
|
|
213
195
|
layer.style3D.bottomAltitude = this.options.position.alt;
|
|
214
|
-
|
|
215
196
|
if (layer.refresh) {
|
|
216
197
|
layer.refresh(); // 设置风格后需刷新
|
|
217
198
|
}
|
|
218
199
|
}
|
|
219
200
|
}
|
|
201
|
+
|
|
220
202
|
/**
|
|
221
203
|
* 对象添加到地图上的创建钩子方法,
|
|
222
204
|
* 每次add时都会调用
|
|
223
205
|
* @return {void} 无
|
|
224
206
|
* @private
|
|
225
207
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
228
208
|
_addedHook() {
|
|
229
209
|
this._showHook(this.show);
|
|
230
210
|
}
|
|
211
|
+
|
|
231
212
|
/**
|
|
232
213
|
* 对象从地图上移除的创建钩子方法,
|
|
233
214
|
* 每次remove时都会调用
|
|
234
215
|
* @return {void} 无
|
|
235
216
|
* @private
|
|
236
217
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
218
|
_removedHook() {
|
|
240
219
|
this._showHook(false);
|
|
241
220
|
}
|
|
221
|
+
|
|
242
222
|
/**
|
|
243
223
|
* 遍历每一个子图层并将其作为参数传递给回调函数
|
|
244
224
|
*
|
|
@@ -246,50 +226,45 @@
|
|
|
246
226
|
* @param {Object} [context] 侦听器的上下文(this关键字将指向的对象)。
|
|
247
227
|
* @return {GroupLayer} 当前对象本身,可以链式调用
|
|
248
228
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
229
|
eachLayer(method, context) {
|
|
252
230
|
if (!this._layerArr) {
|
|
253
231
|
return;
|
|
254
232
|
}
|
|
255
|
-
|
|
256
233
|
this._layerArr.forEach(layer => {
|
|
257
234
|
method.call(context, layer);
|
|
258
235
|
});
|
|
259
|
-
|
|
260
236
|
return this;
|
|
261
237
|
}
|
|
238
|
+
|
|
262
239
|
/**
|
|
263
240
|
* 设置透明度
|
|
264
241
|
* @param {Number} value 透明度
|
|
265
242
|
* @return {void} 无
|
|
266
243
|
*/
|
|
267
|
-
|
|
268
|
-
|
|
269
244
|
setOpacity(value) {
|
|
270
245
|
this.eachLayer(layer => {
|
|
271
246
|
layer.style3D.fillForeColor.alpha = value;
|
|
272
247
|
}, this);
|
|
273
|
-
}
|
|
274
|
-
|
|
248
|
+
}
|
|
275
249
|
|
|
250
|
+
// 定位至数据区域
|
|
276
251
|
flyTo() {
|
|
277
252
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
278
|
-
|
|
279
253
|
if (this.options.center) {
|
|
280
254
|
return this._map.setCameraView(this.options.center, options);
|
|
281
255
|
} else if (this.options.extent) {
|
|
282
256
|
return this._map.flyToExtent(this.options.extent, options);
|
|
283
257
|
}
|
|
284
258
|
}
|
|
285
|
-
|
|
286
259
|
}
|
|
287
|
-
mars3d__namespace.layer.S3MLayer = S3MLayer;
|
|
260
|
+
mars3d__namespace.layer.S3MLayer = S3MLayer;
|
|
288
261
|
|
|
262
|
+
// 注册下
|
|
289
263
|
mars3d__namespace.LayerUtil.register("supermap_s3m", S3MLayer);
|
|
290
264
|
|
|
291
265
|
const Cesium$1 = mars3d__namespace.Cesium;
|
|
292
266
|
const BaseTileLayer = mars3d__namespace.layer.BaseTileLayer;
|
|
267
|
+
|
|
293
268
|
/**
|
|
294
269
|
* 超图影像瓦片服务图层,
|
|
295
270
|
* 【需要引入 mars3d-supermap 插件库】
|
|
@@ -362,39 +337,34 @@
|
|
|
362
337
|
*
|
|
363
338
|
* @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/SuperMapImageryProvider.html?classFilter=SuperMapImageryProvider
|
|
364
339
|
*/
|
|
365
|
-
|
|
366
340
|
class SmImgLayer extends BaseTileLayer {
|
|
367
341
|
// 构建ImageryProvider
|
|
368
342
|
_createImageryProvider(options) {
|
|
369
343
|
return createImageryProvider(options);
|
|
370
|
-
}
|
|
371
|
-
|
|
344
|
+
}
|
|
372
345
|
|
|
346
|
+
// 添加时
|
|
373
347
|
_addedHook() {
|
|
374
348
|
super._addedHook();
|
|
375
|
-
|
|
376
349
|
if (Cesium$1.defined(this.options.transparentBackColor)) {
|
|
377
350
|
this._imageryLayer.transparentBackColor = mars3d__namespace.Util.getCesiumColor(this.options.transparentBackColor);
|
|
378
351
|
this._imageryLayer.transparentBackColorTolerance = this.options.transparentBackColorTolerance; // 去黑边
|
|
379
352
|
}
|
|
380
353
|
}
|
|
381
|
-
|
|
382
354
|
}
|
|
383
355
|
|
|
384
356
|
function createImageryProvider(options) {
|
|
385
357
|
options = mars3d__namespace.LayerUtil.converOptions(options);
|
|
386
|
-
|
|
387
358
|
if (options.url instanceof Cesium$1.Resource) {
|
|
388
359
|
options.url = options.url.url;
|
|
389
360
|
}
|
|
390
|
-
|
|
391
361
|
if (Cesium$1.defined(options.transparentBackColor)) {
|
|
392
362
|
delete options.transparentBackColor;
|
|
393
363
|
delete options.transparentBackColorTolerance;
|
|
394
364
|
}
|
|
395
|
-
|
|
396
365
|
return new Cesium$1.SuperMapImageryProvider(options);
|
|
397
366
|
}
|
|
367
|
+
|
|
398
368
|
/**
|
|
399
369
|
* 创建用于图层的 ImageryProvider对象
|
|
400
370
|
*
|
|
@@ -402,17 +372,17 @@
|
|
|
402
372
|
* @return {Cesium.ImageryProvider} ImageryProvider类
|
|
403
373
|
* @function
|
|
404
374
|
*/
|
|
405
|
-
|
|
406
|
-
|
|
407
375
|
SmImgLayer.createImageryProvider = createImageryProvider;
|
|
408
|
-
mars3d__namespace.layer.SmImgLayer = SmImgLayer;
|
|
376
|
+
mars3d__namespace.layer.SmImgLayer = SmImgLayer;
|
|
409
377
|
|
|
378
|
+
// 注册下
|
|
410
379
|
const layerType = "supermap_img";
|
|
411
380
|
mars3d__namespace.LayerUtil.register(layerType, SmImgLayer);
|
|
412
381
|
mars3d__namespace.LayerUtil.registerImageryProvider(layerType, createImageryProvider);
|
|
413
382
|
|
|
414
383
|
const Cesium = mars3d__namespace.Cesium;
|
|
415
384
|
const BaseLayer = mars3d__namespace.layer.BaseLayer;
|
|
385
|
+
|
|
416
386
|
/**
|
|
417
387
|
* 超图MVT矢量瓦片图层,
|
|
418
388
|
* 【需要引入 mars3d-supermap 插件库】
|
|
@@ -443,7 +413,6 @@
|
|
|
443
413
|
* @class SmMvtLayer
|
|
444
414
|
* @extends {BaseLayer}
|
|
445
415
|
*/
|
|
446
|
-
|
|
447
416
|
class SmMvtLayer extends BaseLayer {
|
|
448
417
|
/**
|
|
449
418
|
* 对应的supermap图层 Cesium.VectorTilesLayer
|
|
@@ -454,113 +423,106 @@
|
|
|
454
423
|
get layer() {
|
|
455
424
|
return this._mvtLayer;
|
|
456
425
|
}
|
|
426
|
+
|
|
457
427
|
/**
|
|
458
428
|
* 对象添加到地图前创建一些对象的钩子方法,
|
|
459
429
|
* 只会调用一次
|
|
460
430
|
* @return {void} 无
|
|
461
431
|
* @private
|
|
462
432
|
*/
|
|
463
|
-
|
|
464
|
-
|
|
465
433
|
_mountedHook() {
|
|
466
434
|
// options参考API文档:http://support.supermap.com.cn:8090/webgl/docs/Documentation/Scene.html
|
|
467
435
|
this._mvtLayer = this._map.scene.addVectorTilesMap(this.options);
|
|
468
|
-
|
|
469
|
-
|
|
436
|
+
this._mvtLayer.readyPromise.then(function (data) {
|
|
437
|
+
// setPaintProperty(layerId, name, value, options)
|
|
470
438
|
// for(var layerId in that.options.style){
|
|
471
439
|
// that._mvtLayer.setPaintProperty(layerId, "fill-color", "rgba(255,0,0,0.8)");
|
|
472
440
|
// }
|
|
473
441
|
});
|
|
474
|
-
|
|
475
442
|
const scene = this._map.scene;
|
|
476
443
|
const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
|
|
477
444
|
handler.setInputAction(event => {
|
|
478
445
|
if (!this.show) {
|
|
479
446
|
return;
|
|
480
447
|
}
|
|
448
|
+
const position = mars3d__namespace.PointUtil.getCurrentMousePosition(scene, event.position);
|
|
481
449
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
});
|
|
486
|
-
|
|
450
|
+
// 查询出相交图层的feature
|
|
451
|
+
const features = this._mvtLayer.queryRenderedFeatures([position], {
|
|
452
|
+
// layers: [selectLayer.id]
|
|
453
|
+
});
|
|
487
454
|
|
|
455
|
+
// eslint-disable-next-line array-callback-return
|
|
488
456
|
features.reduce((memo, result) => {
|
|
489
457
|
const attr = result.feature.properties;
|
|
490
|
-
|
|
491
458
|
if (!attr) {
|
|
492
459
|
// eslint-disable-next-line array-callback-return
|
|
493
460
|
return;
|
|
494
461
|
}
|
|
495
|
-
|
|
496
462
|
const content = mars3d__namespace.Util.getPopupForConfig(this.options, attr);
|
|
497
463
|
const item = {
|
|
498
464
|
data: attr,
|
|
499
465
|
event: event
|
|
500
466
|
};
|
|
501
|
-
|
|
502
467
|
this._map.openPopup(position, content, item);
|
|
503
468
|
});
|
|
504
469
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
505
470
|
this.handler = handler;
|
|
506
471
|
}
|
|
472
|
+
|
|
507
473
|
/**
|
|
508
474
|
* 对象添加到地图上的创建钩子方法,
|
|
509
475
|
* 每次add时都会调用
|
|
510
476
|
* @return {void} 无
|
|
511
477
|
* @private
|
|
512
478
|
*/
|
|
513
|
-
|
|
514
|
-
|
|
515
479
|
_addedHook() {
|
|
516
|
-
this._mvtLayer.show = true;
|
|
480
|
+
this._mvtLayer.show = true;
|
|
481
|
+
// this._mvtLayer.refresh();
|
|
517
482
|
}
|
|
483
|
+
|
|
518
484
|
/**
|
|
519
485
|
* 对象从地图上移除的创建钩子方法,
|
|
520
486
|
* 每次remove时都会调用
|
|
521
487
|
* @return {void} 无
|
|
522
488
|
* @private
|
|
523
489
|
*/
|
|
524
|
-
|
|
525
|
-
|
|
526
490
|
_removedHook() {
|
|
527
491
|
if (this._mvtLayer) {
|
|
528
492
|
this._mvtLayer.show = false;
|
|
529
493
|
}
|
|
530
494
|
}
|
|
495
|
+
|
|
531
496
|
/**
|
|
532
497
|
* 设置透明度
|
|
533
498
|
* @param {Number} value 透明度
|
|
534
499
|
* @return {void} 无
|
|
535
500
|
*/
|
|
536
|
-
|
|
537
|
-
|
|
538
501
|
setOpacity(value) {
|
|
539
502
|
if (this._mvtLayer) {
|
|
540
503
|
this._mvtLayer.alpha = parseFloat(value);
|
|
541
504
|
}
|
|
542
|
-
}
|
|
543
|
-
|
|
505
|
+
}
|
|
544
506
|
|
|
507
|
+
// 定位至数据区域
|
|
545
508
|
flyTo() {
|
|
546
509
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
547
|
-
|
|
548
510
|
if (this.options.center) {
|
|
549
511
|
return this._map.setCameraView(this.options.center, options);
|
|
550
512
|
} else if (this.options.extent) {
|
|
551
513
|
return this._map.flyToExtent(this.options.extent, options);
|
|
552
514
|
} else if (this._mvtLayer) {
|
|
553
|
-
return this._map.camera.flyTo({
|
|
515
|
+
return this._map.camera.flyTo({
|
|
516
|
+
...options,
|
|
554
517
|
destination: this._mvtLayer.rectangle
|
|
555
518
|
});
|
|
556
519
|
}
|
|
557
|
-
|
|
558
520
|
return Promise.resolve(false);
|
|
559
521
|
}
|
|
560
|
-
|
|
561
522
|
}
|
|
562
|
-
mars3d__namespace.layer.SmMvtLayer = SmMvtLayer;
|
|
523
|
+
mars3d__namespace.layer.SmMvtLayer = SmMvtLayer;
|
|
563
524
|
|
|
525
|
+
// 注册下
|
|
564
526
|
mars3d__namespace.LayerUtil.register("supermap_mvt", SmMvtLayer);
|
|
565
527
|
|
|
566
528
|
exports.S3MLayer = S3MLayer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mars3d-supermap",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.10",
|
|
4
4
|
"description": "Mars3D平台插件,结合supermap超图库使用的功能插件",
|
|
5
5
|
"main": "dist/mars3d-supermap.js",
|
|
6
6
|
"files": [
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
],
|
|
9
9
|
"dependencies": {},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"mars3d": "~3.4.
|
|
11
|
+
"mars3d": "~3.4.10"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"lint": "eslint ./src/**/*.{js,ts} --fix"
|