mars3d-supermap 3.4.8 → 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 +296 -576
- 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-
|
|
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
|
*/
|
|
@@ -32,188 +32,9 @@
|
|
|
32
32
|
|
|
33
33
|
var mars3d__namespace = /*#__PURE__*/_interopNamespace(mars3d);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const Cesium$2 = mars3d__namespace.Cesium;
|
|
36
|
+
const BaseLayer$1 = mars3d__namespace.layer.BaseLayer;
|
|
37
37
|
|
|
38
|
-
if (Object.getOwnPropertySymbols) {
|
|
39
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
40
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
41
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
42
|
-
})), keys.push.apply(keys, symbols);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return keys;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _objectSpread2(target) {
|
|
49
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
50
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
51
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
52
|
-
_defineProperty(target, key, source[key]);
|
|
53
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
54
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return target;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function _classCallCheck(instance, Constructor) {
|
|
62
|
-
if (!(instance instanceof Constructor)) {
|
|
63
|
-
throw new TypeError("Cannot call a class as a function");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function _defineProperties(target, props) {
|
|
68
|
-
for (var i = 0; i < props.length; i++) {
|
|
69
|
-
var descriptor = props[i];
|
|
70
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
71
|
-
descriptor.configurable = true;
|
|
72
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
73
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
78
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
79
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
80
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
81
|
-
writable: false
|
|
82
|
-
});
|
|
83
|
-
return Constructor;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function _defineProperty(obj, key, value) {
|
|
87
|
-
if (key in obj) {
|
|
88
|
-
Object.defineProperty(obj, key, {
|
|
89
|
-
value: value,
|
|
90
|
-
enumerable: true,
|
|
91
|
-
configurable: true,
|
|
92
|
-
writable: true
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
obj[key] = value;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return obj;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function _inherits(subClass, superClass) {
|
|
102
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
103
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
107
|
-
constructor: {
|
|
108
|
-
value: subClass,
|
|
109
|
-
writable: true,
|
|
110
|
-
configurable: true
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
Object.defineProperty(subClass, "prototype", {
|
|
114
|
-
writable: false
|
|
115
|
-
});
|
|
116
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function _getPrototypeOf(o) {
|
|
120
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
121
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
122
|
-
};
|
|
123
|
-
return _getPrototypeOf(o);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function _setPrototypeOf(o, p) {
|
|
127
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
128
|
-
o.__proto__ = p;
|
|
129
|
-
return o;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
return _setPrototypeOf(o, p);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function _isNativeReflectConstruct() {
|
|
136
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
137
|
-
if (Reflect.construct.sham) return false;
|
|
138
|
-
if (typeof Proxy === "function") return true;
|
|
139
|
-
|
|
140
|
-
try {
|
|
141
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
142
|
-
return true;
|
|
143
|
-
} catch (e) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function _assertThisInitialized(self) {
|
|
149
|
-
if (self === void 0) {
|
|
150
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return self;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function _possibleConstructorReturn(self, call) {
|
|
157
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
158
|
-
return call;
|
|
159
|
-
} else if (call !== void 0) {
|
|
160
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return _assertThisInitialized(self);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function _createSuper(Derived) {
|
|
167
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
168
|
-
|
|
169
|
-
return function _createSuperInternal() {
|
|
170
|
-
var Super = _getPrototypeOf(Derived),
|
|
171
|
-
result;
|
|
172
|
-
|
|
173
|
-
if (hasNativeReflectConstruct) {
|
|
174
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
175
|
-
|
|
176
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
177
|
-
} else {
|
|
178
|
-
result = Super.apply(this, arguments);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return _possibleConstructorReturn(this, result);
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function _superPropBase(object, property) {
|
|
186
|
-
while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
|
187
|
-
object = _getPrototypeOf(object);
|
|
188
|
-
if (object === null) break;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return object;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function _get() {
|
|
195
|
-
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
196
|
-
_get = Reflect.get;
|
|
197
|
-
} else {
|
|
198
|
-
_get = function _get(target, property, receiver) {
|
|
199
|
-
var base = _superPropBase(target, property);
|
|
200
|
-
|
|
201
|
-
if (!base) return;
|
|
202
|
-
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
203
|
-
|
|
204
|
-
if (desc.get) {
|
|
205
|
-
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return desc.value;
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return _get.apply(this, arguments);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var Cesium$2 = mars3d__namespace.Cesium;
|
|
216
|
-
var BaseLayer$1 = mars3d__namespace.layer.BaseLayer;
|
|
217
38
|
/**
|
|
218
39
|
* 超图S3M三维模型图层,
|
|
219
40
|
* 【需要引入 mars3d-supermap 插件库】
|
|
@@ -243,258 +64,207 @@
|
|
|
243
64
|
* @class S3MLayer
|
|
244
65
|
* @extends {BaseLayer}
|
|
245
66
|
*/
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return _super.apply(this, arguments);
|
|
67
|
+
class S3MLayer extends BaseLayer$1 {
|
|
68
|
+
/**
|
|
69
|
+
* 模型对应的Cesium.S3MTilesLayer图层组
|
|
70
|
+
* @type {Object[]}
|
|
71
|
+
* @readonly
|
|
72
|
+
* @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/S3MTilesLayer.html
|
|
73
|
+
*/
|
|
74
|
+
get layer() {
|
|
75
|
+
return this._layerArr;
|
|
256
76
|
}
|
|
257
77
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
},
|
|
281
|
-
set: function set(value) {
|
|
282
|
-
for (var key in value) {
|
|
283
|
-
var val = value[key];
|
|
284
|
-
this.options.s3mOptions[key] = val;
|
|
285
|
-
|
|
286
|
-
if (key === "transparentBackColor") {
|
|
287
|
-
// 去黑边,与offset互斥,注意别配置offset
|
|
288
|
-
val = Cesium$2.Color.fromCssColorString(val);
|
|
289
|
-
} else if (key === "transparentBackColorTolerance") {
|
|
290
|
-
val = Number(val);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
for (var i = 0; i < this._layerArr.length; i++) {
|
|
294
|
-
var layer = this._layerArr[i];
|
|
295
|
-
|
|
296
|
-
if (layer == null) {
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
layer[key] = val;
|
|
78
|
+
/**
|
|
79
|
+
* 设置S3M图层本身支持的参数
|
|
80
|
+
* @type {Object}
|
|
81
|
+
* @see [S3M支持的参数]{@link http://support.supermap.com.cn:8090/webgl/docs/Documentation/S3MTilesLayer.html?classFilter=S3MTilesLayer}
|
|
82
|
+
*/
|
|
83
|
+
get s3mOptions() {
|
|
84
|
+
return this.options.s3mOptions;
|
|
85
|
+
}
|
|
86
|
+
set s3mOptions(value) {
|
|
87
|
+
for (const key in value) {
|
|
88
|
+
let val = value[key];
|
|
89
|
+
this.options.s3mOptions[key] = val;
|
|
90
|
+
if (key === "transparentBackColor") {
|
|
91
|
+
// 去黑边,与offset互斥,注意别配置offset
|
|
92
|
+
val = Cesium$2.Color.fromCssColorString(val);
|
|
93
|
+
} else if (key === "transparentBackColorTolerance") {
|
|
94
|
+
val = Number(val);
|
|
95
|
+
}
|
|
96
|
+
for (let i = 0; i < this._layerArr.length; i++) {
|
|
97
|
+
const layer = this._layerArr[i];
|
|
98
|
+
if (layer == null) {
|
|
99
|
+
continue;
|
|
301
100
|
}
|
|
101
|
+
layer[key] = val;
|
|
302
102
|
}
|
|
303
103
|
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
104
|
+
}
|
|
105
|
+
_showHook(show) {
|
|
106
|
+
this.eachLayer(layer => {
|
|
107
|
+
layer.visible = show; // 不同超图版本,有的是visible,有的是show
|
|
108
|
+
layer.show = show;
|
|
109
|
+
}, this);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 对象添加到地图前创建一些对象的钩子方法,
|
|
114
|
+
* 只会调用一次
|
|
115
|
+
* @return {void} 无
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
118
|
+
_mountedHook() {
|
|
119
|
+
if (!this._map.scene.open) {
|
|
120
|
+
throw new Error("请引入 超图版本Cesium库 或 超图S3M插件 ");
|
|
312
121
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
var promise;
|
|
331
|
-
|
|
332
|
-
if (this.options.layername) {
|
|
333
|
-
promise = this._map.scene.addS3MTilesLayerByScp(this.options.url, {
|
|
334
|
-
name: this.options.layername,
|
|
335
|
-
autoSetVie: this.options.flyTo,
|
|
336
|
-
cullEnabled: this.options.cullEnabled
|
|
337
|
-
});
|
|
122
|
+
|
|
123
|
+
// 场景添加S3M图层服务
|
|
124
|
+
let promise;
|
|
125
|
+
if (this.options.layername) {
|
|
126
|
+
promise = this._map.scene.addS3MTilesLayerByScp(this.options.url, {
|
|
127
|
+
name: this.options.layername,
|
|
128
|
+
autoSetVie: this.options.flyTo,
|
|
129
|
+
cullEnabled: this.options.cullEnabled
|
|
130
|
+
});
|
|
131
|
+
} else {
|
|
132
|
+
promise = this._map.scene.open(this.options.url, this.options.sceneName, {
|
|
133
|
+
autoSetVie: this.options.flyTo
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
promise.then(smLayer => {
|
|
137
|
+
if (Array.isArray(smLayer)) {
|
|
138
|
+
this._layerArr = smLayer;
|
|
338
139
|
} else {
|
|
339
|
-
|
|
340
|
-
autoSetVie: this.options.flyTo
|
|
341
|
-
});
|
|
140
|
+
this._layerArr = [smLayer];
|
|
342
141
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
} else {
|
|
348
|
-
_this._layerArr = [smLayer];
|
|
142
|
+
for (let i = 0; i < this._layerArr.length; i++) {
|
|
143
|
+
const layer = this._layerArr[i];
|
|
144
|
+
if (!layer) {
|
|
145
|
+
continue;
|
|
349
146
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (!layer) {
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
try {
|
|
359
|
-
_this._initModelItem(layer);
|
|
360
|
-
} catch (e) {
|
|
361
|
-
mars3d__namespace.Log.logError("s3m图层初始化出错", e);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
_this._showHook(_this.show);
|
|
366
|
-
|
|
367
|
-
if (_this.options.flyTo) {
|
|
368
|
-
_this.flyToByAnimationEnd();
|
|
147
|
+
try {
|
|
148
|
+
this._initModelItem(layer);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
mars3d__namespace.Log.logError("s3m图层初始化出错", e);
|
|
369
151
|
}
|
|
152
|
+
}
|
|
153
|
+
this._showHook(this.show);
|
|
154
|
+
if (this.options.flyTo) {
|
|
155
|
+
this.flyToByAnimationEnd();
|
|
156
|
+
}
|
|
157
|
+
this._readyPromise.resolve(this);
|
|
158
|
+
this.fire(mars3d__namespace.EventType.load, {
|
|
159
|
+
layers: this._layerArr
|
|
160
|
+
});
|
|
161
|
+
}, error => {
|
|
162
|
+
this._readyPromise && this._readyPromise.reject(error);
|
|
163
|
+
});
|
|
370
164
|
|
|
371
|
-
|
|
165
|
+
// this._map.viewer.pickEvent.addEventListener(function (feature) {
|
|
166
|
+
// debugger;
|
|
167
|
+
// });
|
|
168
|
+
}
|
|
372
169
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
var _this$options, _this$options$positio;
|
|
387
|
-
|
|
388
|
-
// 图层参数合并
|
|
389
|
-
if (this.options.s3mOptions) {
|
|
390
|
-
for (var key in this.options.s3mOptions) {
|
|
391
|
-
var val = this.options.s3mOptions[key];
|
|
392
|
-
|
|
393
|
-
if (key === "transparentBackColor") {
|
|
394
|
-
layer[key] = Cesium$2.Color.fromCssColorString(val); // 去黑边
|
|
395
|
-
} else if (key === "transparentBackColorTolerance") {
|
|
396
|
-
layer[key] = Number(val);
|
|
397
|
-
} else {
|
|
398
|
-
layer[key] = val;
|
|
399
|
-
}
|
|
170
|
+
// 对单个s3m图层处理
|
|
171
|
+
_initModelItem(layer) {
|
|
172
|
+
var _this$options, _this$options$positio;
|
|
173
|
+
// 图层参数合并
|
|
174
|
+
if (this.options.s3mOptions) {
|
|
175
|
+
for (const key in this.options.s3mOptions) {
|
|
176
|
+
const val = this.options.s3mOptions[key];
|
|
177
|
+
if (key === "transparentBackColor") {
|
|
178
|
+
layer[key] = Cesium$2.Color.fromCssColorString(val); // 去黑边
|
|
179
|
+
} else if (key === "transparentBackColorTolerance") {
|
|
180
|
+
layer[key] = Number(val);
|
|
181
|
+
} else {
|
|
182
|
+
layer[key] = val;
|
|
400
183
|
}
|
|
401
|
-
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
402
186
|
|
|
187
|
+
// 选中颜色
|
|
188
|
+
if (this.options.highlight) {
|
|
189
|
+
layer.selectedColor = mars3d__namespace.Util.getColorByStyle(this.options.highlight);
|
|
190
|
+
}
|
|
403
191
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
192
|
+
// 高度调整
|
|
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) {
|
|
194
|
+
layer.style3D.altitudeMode = Cesium$2.HeightReference.NONE;
|
|
195
|
+
layer.style3D.bottomAltitude = this.options.position.alt;
|
|
196
|
+
if (layer.refresh) {
|
|
197
|
+
layer.refresh(); // 设置风格后需刷新
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
407
201
|
|
|
202
|
+
/**
|
|
203
|
+
* 对象添加到地图上的创建钩子方法,
|
|
204
|
+
* 每次add时都会调用
|
|
205
|
+
* @return {void} 无
|
|
206
|
+
* @private
|
|
207
|
+
*/
|
|
208
|
+
_addedHook() {
|
|
209
|
+
this._showHook(this.show);
|
|
210
|
+
}
|
|
408
211
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
212
|
+
/**
|
|
213
|
+
* 对象从地图上移除的创建钩子方法,
|
|
214
|
+
* 每次remove时都会调用
|
|
215
|
+
* @return {void} 无
|
|
216
|
+
* @private
|
|
217
|
+
*/
|
|
218
|
+
_removedHook() {
|
|
219
|
+
this._showHook(false);
|
|
220
|
+
}
|
|
412
221
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
*/
|
|
424
|
-
|
|
425
|
-
}, {
|
|
426
|
-
key: "_addedHook",
|
|
427
|
-
value: function _addedHook() {
|
|
428
|
-
this._showHook(this.show);
|
|
222
|
+
/**
|
|
223
|
+
* 遍历每一个子图层并将其作为参数传递给回调函数
|
|
224
|
+
*
|
|
225
|
+
* @param {Function} method 回调方法
|
|
226
|
+
* @param {Object} [context] 侦听器的上下文(this关键字将指向的对象)。
|
|
227
|
+
* @return {GroupLayer} 当前对象本身,可以链式调用
|
|
228
|
+
*/
|
|
229
|
+
eachLayer(method, context) {
|
|
230
|
+
if (!this._layerArr) {
|
|
231
|
+
return;
|
|
429
232
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
*/
|
|
436
|
-
|
|
437
|
-
}, {
|
|
438
|
-
key: "_removedHook",
|
|
439
|
-
value: function _removedHook() {
|
|
440
|
-
this._showHook(false);
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* 遍历每一个子图层并将其作为参数传递给回调函数
|
|
444
|
-
*
|
|
445
|
-
* @param {Function} method 回调方法
|
|
446
|
-
* @param {Object} [context] 侦听器的上下文(this关键字将指向的对象)。
|
|
447
|
-
* @return {GroupLayer} 当前对象本身,可以链式调用
|
|
448
|
-
*/
|
|
449
|
-
|
|
450
|
-
}, {
|
|
451
|
-
key: "eachLayer",
|
|
452
|
-
value: function eachLayer(method, context) {
|
|
453
|
-
if (!this._layerArr) {
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
233
|
+
this._layerArr.forEach(layer => {
|
|
234
|
+
method.call(context, layer);
|
|
235
|
+
});
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
456
238
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
239
|
+
/**
|
|
240
|
+
* 设置透明度
|
|
241
|
+
* @param {Number} value 透明度
|
|
242
|
+
* @return {void} 无
|
|
243
|
+
*/
|
|
244
|
+
setOpacity(value) {
|
|
245
|
+
this.eachLayer(layer => {
|
|
246
|
+
layer.style3D.fillForeColor.alpha = value;
|
|
247
|
+
}, this);
|
|
248
|
+
}
|
|
460
249
|
|
|
461
|
-
|
|
250
|
+
// 定位至数据区域
|
|
251
|
+
flyTo() {
|
|
252
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
253
|
+
if (this.options.center) {
|
|
254
|
+
return this._map.setCameraView(this.options.center, options);
|
|
255
|
+
} else if (this.options.extent) {
|
|
256
|
+
return this._map.flyToExtent(this.options.extent, options);
|
|
462
257
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
* @return {void} 无
|
|
467
|
-
*/
|
|
468
|
-
|
|
469
|
-
}, {
|
|
470
|
-
key: "setOpacity",
|
|
471
|
-
value: function setOpacity(value) {
|
|
472
|
-
this.eachLayer(function (layer) {
|
|
473
|
-
layer.style3D.fillForeColor.alpha = value;
|
|
474
|
-
}, this);
|
|
475
|
-
} // 定位至数据区域
|
|
476
|
-
|
|
477
|
-
}, {
|
|
478
|
-
key: "flyTo",
|
|
479
|
-
value: function flyTo() {
|
|
480
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
481
|
-
|
|
482
|
-
if (this.options.center) {
|
|
483
|
-
return this._map.setCameraView(this.options.center, options);
|
|
484
|
-
} else if (this.options.extent) {
|
|
485
|
-
return this._map.flyToExtent(this.options.extent, options);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}]);
|
|
489
|
-
|
|
490
|
-
return S3MLayer;
|
|
491
|
-
}(BaseLayer$1);
|
|
492
|
-
mars3d__namespace.layer.S3MLayer = S3MLayer; // 注册下
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
mars3d__namespace.layer.S3MLayer = S3MLayer;
|
|
493
261
|
|
|
262
|
+
// 注册下
|
|
494
263
|
mars3d__namespace.LayerUtil.register("supermap_s3m", S3MLayer);
|
|
495
264
|
|
|
496
|
-
|
|
497
|
-
|
|
265
|
+
const Cesium$1 = mars3d__namespace.Cesium;
|
|
266
|
+
const BaseTileLayer = mars3d__namespace.layer.BaseTileLayer;
|
|
267
|
+
|
|
498
268
|
/**
|
|
499
269
|
* 超图影像瓦片服务图层,
|
|
500
270
|
* 【需要引入 mars3d-supermap 插件库】
|
|
@@ -567,54 +337,34 @@
|
|
|
567
337
|
*
|
|
568
338
|
* @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/SuperMapImageryProvider.html?classFilter=SuperMapImageryProvider
|
|
569
339
|
*/
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
var _super = _createSuper(SmImgLayer);
|
|
575
|
-
|
|
576
|
-
function SmImgLayer() {
|
|
577
|
-
_classCallCheck(this, SmImgLayer);
|
|
578
|
-
|
|
579
|
-
return _super.apply(this, arguments);
|
|
340
|
+
class SmImgLayer extends BaseTileLayer {
|
|
341
|
+
// 构建ImageryProvider
|
|
342
|
+
_createImageryProvider(options) {
|
|
343
|
+
return createImageryProvider(options);
|
|
580
344
|
}
|
|
581
345
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}, {
|
|
590
|
-
key: "_addedHook",
|
|
591
|
-
value: function _addedHook() {
|
|
592
|
-
_get(_getPrototypeOf(SmImgLayer.prototype), "_addedHook", this).call(this);
|
|
593
|
-
|
|
594
|
-
if (Cesium$1.defined(this.options.transparentBackColor)) {
|
|
595
|
-
this._imageryLayer.transparentBackColor = mars3d__namespace.Util.getCesiumColor(this.options.transparentBackColor);
|
|
596
|
-
this._imageryLayer.transparentBackColorTolerance = this.options.transparentBackColorTolerance; // 去黑边
|
|
597
|
-
}
|
|
346
|
+
// 添加时
|
|
347
|
+
_addedHook() {
|
|
348
|
+
super._addedHook();
|
|
349
|
+
if (Cesium$1.defined(this.options.transparentBackColor)) {
|
|
350
|
+
this._imageryLayer.transparentBackColor = mars3d__namespace.Util.getCesiumColor(this.options.transparentBackColor);
|
|
351
|
+
this._imageryLayer.transparentBackColorTolerance = this.options.transparentBackColorTolerance; // 去黑边
|
|
598
352
|
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
return SmImgLayer;
|
|
602
|
-
}(BaseTileLayer);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
603
355
|
|
|
604
356
|
function createImageryProvider(options) {
|
|
605
357
|
options = mars3d__namespace.LayerUtil.converOptions(options);
|
|
606
|
-
|
|
607
358
|
if (options.url instanceof Cesium$1.Resource) {
|
|
608
359
|
options.url = options.url.url;
|
|
609
360
|
}
|
|
610
|
-
|
|
611
361
|
if (Cesium$1.defined(options.transparentBackColor)) {
|
|
612
362
|
delete options.transparentBackColor;
|
|
613
363
|
delete options.transparentBackColorTolerance;
|
|
614
364
|
}
|
|
615
|
-
|
|
616
365
|
return new Cesium$1.SuperMapImageryProvider(options);
|
|
617
366
|
}
|
|
367
|
+
|
|
618
368
|
/**
|
|
619
369
|
* 创建用于图层的 ImageryProvider对象
|
|
620
370
|
*
|
|
@@ -622,17 +372,17 @@
|
|
|
622
372
|
* @return {Cesium.ImageryProvider} ImageryProvider类
|
|
623
373
|
* @function
|
|
624
374
|
*/
|
|
625
|
-
|
|
626
|
-
|
|
627
375
|
SmImgLayer.createImageryProvider = createImageryProvider;
|
|
628
|
-
mars3d__namespace.layer.SmImgLayer = SmImgLayer;
|
|
376
|
+
mars3d__namespace.layer.SmImgLayer = SmImgLayer;
|
|
629
377
|
|
|
630
|
-
|
|
378
|
+
// 注册下
|
|
379
|
+
const layerType = "supermap_img";
|
|
631
380
|
mars3d__namespace.LayerUtil.register(layerType, SmImgLayer);
|
|
632
381
|
mars3d__namespace.LayerUtil.registerImageryProvider(layerType, createImageryProvider);
|
|
633
382
|
|
|
634
|
-
|
|
635
|
-
|
|
383
|
+
const Cesium = mars3d__namespace.Cesium;
|
|
384
|
+
const BaseLayer = mars3d__namespace.layer.BaseLayer;
|
|
385
|
+
|
|
636
386
|
/**
|
|
637
387
|
* 超图MVT矢量瓦片图层,
|
|
638
388
|
* 【需要引入 mars3d-supermap 插件库】
|
|
@@ -663,146 +413,116 @@
|
|
|
663
413
|
* @class SmMvtLayer
|
|
664
414
|
* @extends {BaseLayer}
|
|
665
415
|
*/
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
return _super.apply(this, arguments);
|
|
416
|
+
class SmMvtLayer extends BaseLayer {
|
|
417
|
+
/**
|
|
418
|
+
* 对应的supermap图层 Cesium.VectorTilesLayer
|
|
419
|
+
* @type {*}
|
|
420
|
+
* @readonly
|
|
421
|
+
* @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/VectorTilesLayer.html
|
|
422
|
+
*/
|
|
423
|
+
get layer() {
|
|
424
|
+
return this._mvtLayer;
|
|
676
425
|
}
|
|
677
426
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
function
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
this._mvtLayer.readyPromise.then(function (data) {// setPaintProperty(layerId, name, value, options)
|
|
706
|
-
// for(var layerId in that.options.style){
|
|
707
|
-
// that._mvtLayer.setPaintProperty(layerId, "fill-color", "rgba(255,0,0,0.8)");
|
|
708
|
-
// }
|
|
427
|
+
/**
|
|
428
|
+
* 对象添加到地图前创建一些对象的钩子方法,
|
|
429
|
+
* 只会调用一次
|
|
430
|
+
* @return {void} 无
|
|
431
|
+
* @private
|
|
432
|
+
*/
|
|
433
|
+
_mountedHook() {
|
|
434
|
+
// options参考API文档:http://support.supermap.com.cn:8090/webgl/docs/Documentation/Scene.html
|
|
435
|
+
this._mvtLayer = this._map.scene.addVectorTilesMap(this.options);
|
|
436
|
+
this._mvtLayer.readyPromise.then(function (data) {
|
|
437
|
+
// setPaintProperty(layerId, name, value, options)
|
|
438
|
+
// for(var layerId in that.options.style){
|
|
439
|
+
// that._mvtLayer.setPaintProperty(layerId, "fill-color", "rgba(255,0,0,0.8)");
|
|
440
|
+
// }
|
|
441
|
+
});
|
|
442
|
+
const scene = this._map.scene;
|
|
443
|
+
const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
|
|
444
|
+
handler.setInputAction(event => {
|
|
445
|
+
if (!this.show) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const position = mars3d__namespace.PointUtil.getCurrentMousePosition(scene, event.position);
|
|
449
|
+
|
|
450
|
+
// 查询出相交图层的feature
|
|
451
|
+
const features = this._mvtLayer.queryRenderedFeatures([position], {
|
|
452
|
+
// layers: [selectLayer.id]
|
|
709
453
|
});
|
|
710
454
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
if (!
|
|
455
|
+
// eslint-disable-next-line array-callback-return
|
|
456
|
+
features.reduce((memo, result) => {
|
|
457
|
+
const attr = result.feature.properties;
|
|
458
|
+
if (!attr) {
|
|
459
|
+
// eslint-disable-next-line array-callback-return
|
|
715
460
|
return;
|
|
716
461
|
}
|
|
462
|
+
const content = mars3d__namespace.Util.getPopupForConfig(this.options, attr);
|
|
463
|
+
const item = {
|
|
464
|
+
data: attr,
|
|
465
|
+
event: event
|
|
466
|
+
};
|
|
467
|
+
this._map.openPopup(position, content, item);
|
|
468
|
+
});
|
|
469
|
+
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
470
|
+
this.handler = handler;
|
|
471
|
+
}
|
|
717
472
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
// eslint-disable-next-line array-callback-return
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
var content = mars3d__namespace.Util.getPopupForConfig(_this.options, attr);
|
|
733
|
-
var item = {
|
|
734
|
-
data: attr,
|
|
735
|
-
event: event
|
|
736
|
-
};
|
|
473
|
+
/**
|
|
474
|
+
* 对象添加到地图上的创建钩子方法,
|
|
475
|
+
* 每次add时都会调用
|
|
476
|
+
* @return {void} 无
|
|
477
|
+
* @private
|
|
478
|
+
*/
|
|
479
|
+
_addedHook() {
|
|
480
|
+
this._mvtLayer.show = true;
|
|
481
|
+
// this._mvtLayer.refresh();
|
|
482
|
+
}
|
|
737
483
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
484
|
+
/**
|
|
485
|
+
* 对象从地图上移除的创建钩子方法,
|
|
486
|
+
* 每次remove时都会调用
|
|
487
|
+
* @return {void} 无
|
|
488
|
+
* @private
|
|
489
|
+
*/
|
|
490
|
+
_removedHook() {
|
|
491
|
+
if (this._mvtLayer) {
|
|
492
|
+
this._mvtLayer.show = false;
|
|
742
493
|
}
|
|
743
|
-
|
|
744
|
-
* 对象添加到地图上的创建钩子方法,
|
|
745
|
-
* 每次add时都会调用
|
|
746
|
-
* @return {void} 无
|
|
747
|
-
* @private
|
|
748
|
-
*/
|
|
749
|
-
|
|
750
|
-
}, {
|
|
751
|
-
key: "_addedHook",
|
|
752
|
-
value: function _addedHook() {
|
|
753
|
-
this._mvtLayer.show = true; // this._mvtLayer.refresh();
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* 对象从地图上移除的创建钩子方法,
|
|
757
|
-
* 每次remove时都会调用
|
|
758
|
-
* @return {void} 无
|
|
759
|
-
* @private
|
|
760
|
-
*/
|
|
761
|
-
|
|
762
|
-
}, {
|
|
763
|
-
key: "_removedHook",
|
|
764
|
-
value: function _removedHook() {
|
|
765
|
-
if (this._mvtLayer) {
|
|
766
|
-
this._mvtLayer.show = false;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
/**
|
|
770
|
-
* 设置透明度
|
|
771
|
-
* @param {Number} value 透明度
|
|
772
|
-
* @return {void} 无
|
|
773
|
-
*/
|
|
774
|
-
|
|
775
|
-
}, {
|
|
776
|
-
key: "setOpacity",
|
|
777
|
-
value: function setOpacity(value) {
|
|
778
|
-
if (this._mvtLayer) {
|
|
779
|
-
this._mvtLayer.alpha = parseFloat(value);
|
|
780
|
-
}
|
|
781
|
-
} // 定位至数据区域
|
|
782
|
-
|
|
783
|
-
}, {
|
|
784
|
-
key: "flyTo",
|
|
785
|
-
value: function flyTo() {
|
|
786
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
787
|
-
|
|
788
|
-
if (this.options.center) {
|
|
789
|
-
return this._map.setCameraView(this.options.center, options);
|
|
790
|
-
} else if (this.options.extent) {
|
|
791
|
-
return this._map.flyToExtent(this.options.extent, options);
|
|
792
|
-
} else if (this._mvtLayer) {
|
|
793
|
-
return this._map.camera.flyTo(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
794
|
-
destination: this._mvtLayer.rectangle
|
|
795
|
-
}));
|
|
796
|
-
}
|
|
494
|
+
}
|
|
797
495
|
|
|
798
|
-
|
|
496
|
+
/**
|
|
497
|
+
* 设置透明度
|
|
498
|
+
* @param {Number} value 透明度
|
|
499
|
+
* @return {void} 无
|
|
500
|
+
*/
|
|
501
|
+
setOpacity(value) {
|
|
502
|
+
if (this._mvtLayer) {
|
|
503
|
+
this._mvtLayer.alpha = parseFloat(value);
|
|
799
504
|
}
|
|
800
|
-
}
|
|
505
|
+
}
|
|
801
506
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
507
|
+
// 定位至数据区域
|
|
508
|
+
flyTo() {
|
|
509
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
510
|
+
if (this.options.center) {
|
|
511
|
+
return this._map.setCameraView(this.options.center, options);
|
|
512
|
+
} else if (this.options.extent) {
|
|
513
|
+
return this._map.flyToExtent(this.options.extent, options);
|
|
514
|
+
} else if (this._mvtLayer) {
|
|
515
|
+
return this._map.camera.flyTo({
|
|
516
|
+
...options,
|
|
517
|
+
destination: this._mvtLayer.rectangle
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
return Promise.resolve(false);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
mars3d__namespace.layer.SmMvtLayer = SmMvtLayer;
|
|
805
524
|
|
|
525
|
+
// 注册下
|
|
806
526
|
mars3d__namespace.LayerUtil.register("supermap_mvt", SmMvtLayer);
|
|
807
527
|
|
|
808
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"
|