mars3d-supermap 3.4.7 → 3.4.9
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 +303 -545
- 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.9
|
|
5
|
+
* 编译日期:2022-10-10 17:12:08
|
|
6
6
|
* 版权所有:Copyright by 火星科技 http://mars3d.cn
|
|
7
7
|
* 使用单位:免费公开版 ,2022-06-01
|
|
8
8
|
*/
|
|
@@ -32,188 +32,8 @@
|
|
|
32
32
|
|
|
33
33
|
var mars3d__namespace = /*#__PURE__*/_interopNamespace(mars3d);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
35
|
+
const Cesium$2 = mars3d__namespace.Cesium;
|
|
36
|
+
const BaseLayer$1 = mars3d__namespace.layer.BaseLayer;
|
|
217
37
|
/**
|
|
218
38
|
* 超图S3M三维模型图层,
|
|
219
39
|
* 【需要引入 mars3d-supermap 插件库】
|
|
@@ -244,257 +64,232 @@
|
|
|
244
64
|
* @extends {BaseLayer}
|
|
245
65
|
*/
|
|
246
66
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 设置S3M图层本身支持的参数
|
|
79
|
+
* @type {Object}
|
|
80
|
+
* @see [S3M支持的参数]{@link http://support.supermap.com.cn:8090/webgl/docs/Documentation/S3MTilesLayer.html?classFilter=S3MTilesLayer}
|
|
81
|
+
*/
|
|
251
82
|
|
|
252
|
-
function S3MLayer() {
|
|
253
|
-
_classCallCheck(this, S3MLayer);
|
|
254
83
|
|
|
255
|
-
|
|
84
|
+
get s3mOptions() {
|
|
85
|
+
return this.options.s3mOptions;
|
|
256
86
|
}
|
|
257
87
|
|
|
258
|
-
|
|
259
|
-
key
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
* 模型对应的Cesium.S3MTilesLayer图层组
|
|
263
|
-
* @type {Object[]}
|
|
264
|
-
* @readonly
|
|
265
|
-
* @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/S3MTilesLayer.html
|
|
266
|
-
*/
|
|
267
|
-
function get() {
|
|
268
|
-
return this._layerArr;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* 设置S3M图层本身支持的参数
|
|
272
|
-
* @type {Object}
|
|
273
|
-
* @see [S3M支持的参数]{@link http://support.supermap.com.cn:8090/webgl/docs/Documentation/S3MTilesLayer.html?classFilter=S3MTilesLayer}
|
|
274
|
-
*/
|
|
275
|
-
|
|
276
|
-
}, {
|
|
277
|
-
key: "s3mOptions",
|
|
278
|
-
get: function get() {
|
|
279
|
-
return this.options.s3mOptions;
|
|
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
|
-
}
|
|
88
|
+
set s3mOptions(value) {
|
|
89
|
+
for (const key in value) {
|
|
90
|
+
let val = value[key];
|
|
91
|
+
this.options.s3mOptions[key] = val;
|
|
292
92
|
|
|
293
|
-
|
|
294
|
-
|
|
93
|
+
if (key === "transparentBackColor") {
|
|
94
|
+
// 去黑边,与offset互斥,注意别配置offset
|
|
95
|
+
val = Cesium$2.Color.fromCssColorString(val);
|
|
96
|
+
} else if (key === "transparentBackColorTolerance") {
|
|
97
|
+
val = Number(val);
|
|
98
|
+
}
|
|
295
99
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
100
|
+
for (let i = 0; i < this._layerArr.length; i++) {
|
|
101
|
+
const layer = this._layerArr[i];
|
|
299
102
|
|
|
300
|
-
|
|
103
|
+
if (layer == null) {
|
|
104
|
+
continue;
|
|
301
105
|
}
|
|
106
|
+
|
|
107
|
+
layer[key] = val;
|
|
302
108
|
}
|
|
303
109
|
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
_showHook(show) {
|
|
113
|
+
this.eachLayer(layer => {
|
|
114
|
+
layer.visible = show; // 不同超图版本,有的是visible,有的是show
|
|
115
|
+
|
|
116
|
+
layer.show = show;
|
|
117
|
+
}, this);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 对象添加到地图前创建一些对象的钩子方法,
|
|
121
|
+
* 只会调用一次
|
|
122
|
+
* @return {void} 无
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
_mountedHook() {
|
|
128
|
+
if (!this._map.scene.open) {
|
|
129
|
+
throw new Error("请引入 超图版本Cesium库 或 超图S3M插件 ");
|
|
130
|
+
} // 场景添加S3M图层服务
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
let promise;
|
|
134
|
+
|
|
135
|
+
if (this.options.layername) {
|
|
136
|
+
promise = this._map.scene.addS3MTilesLayerByScp(this.options.url, {
|
|
137
|
+
name: this.options.layername,
|
|
138
|
+
autoSetVie: this.options.flyTo,
|
|
139
|
+
cullEnabled: this.options.cullEnabled
|
|
140
|
+
});
|
|
141
|
+
} else {
|
|
142
|
+
promise = this._map.scene.open(this.options.url, this.options.sceneName, {
|
|
143
|
+
autoSetVie: this.options.flyTo
|
|
144
|
+
});
|
|
312
145
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
* @private
|
|
318
|
-
*/
|
|
319
|
-
|
|
320
|
-
}, {
|
|
321
|
-
key: "_mountedHook",
|
|
322
|
-
value: function _mountedHook() {
|
|
323
|
-
var _this = this;
|
|
324
|
-
|
|
325
|
-
if (!this._map.scene.open) {
|
|
326
|
-
throw new Error("请引入 超图版本Cesium库 或 超图S3M插件 ");
|
|
327
|
-
} // 场景添加S3M图层服务
|
|
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
|
-
});
|
|
146
|
+
|
|
147
|
+
promise.then(smLayer => {
|
|
148
|
+
if (Array.isArray(smLayer)) {
|
|
149
|
+
this._layerArr = smLayer;
|
|
338
150
|
} else {
|
|
339
|
-
|
|
340
|
-
autoSetVie: this.options.flyTo
|
|
341
|
-
});
|
|
151
|
+
this._layerArr = [smLayer];
|
|
342
152
|
}
|
|
343
153
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
154
|
+
for (let i = 0; i < this._layerArr.length; i++) {
|
|
155
|
+
const layer = this._layerArr[i];
|
|
156
|
+
|
|
157
|
+
if (!layer) {
|
|
158
|
+
continue;
|
|
349
159
|
}
|
|
350
160
|
|
|
351
|
-
|
|
352
|
-
|
|
161
|
+
try {
|
|
162
|
+
this._initModelItem(layer);
|
|
163
|
+
} catch (e) {
|
|
164
|
+
mars3d__namespace.Log.logError("s3m图层初始化出错", e);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
353
167
|
|
|
354
|
-
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
168
|
+
this._showHook(this.show);
|
|
357
169
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
mars3d__namespace.Log.logError("s3m图层初始化出错", e);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
170
|
+
if (this.options.flyTo) {
|
|
171
|
+
this.flyToByAnimationEnd();
|
|
172
|
+
}
|
|
364
173
|
|
|
365
|
-
|
|
174
|
+
this._readyPromise.resolve(this);
|
|
366
175
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
176
|
+
this.fire(mars3d__namespace.EventType.load, {
|
|
177
|
+
layers: this._layerArr
|
|
178
|
+
});
|
|
179
|
+
}, error => {
|
|
180
|
+
this._readyPromise && this._readyPromise.reject(error);
|
|
181
|
+
}); // this._map.viewer.pickEvent.addEventListener(function (feature) {
|
|
182
|
+
// debugger;
|
|
183
|
+
// });
|
|
184
|
+
} // 对单个s3m图层处理
|
|
370
185
|
|
|
371
|
-
_this._readyPromise.resolve(_this);
|
|
372
186
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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
|
-
}
|
|
187
|
+
_initModelItem(layer) {
|
|
188
|
+
var _this$options, _this$options$positio;
|
|
189
|
+
|
|
190
|
+
// 图层参数合并
|
|
191
|
+
if (this.options.s3mOptions) {
|
|
192
|
+
for (const key in this.options.s3mOptions) {
|
|
193
|
+
const val = this.options.s3mOptions[key];
|
|
194
|
+
|
|
195
|
+
if (key === "transparentBackColor") {
|
|
196
|
+
layer[key] = Cesium$2.Color.fromCssColorString(val); // 去黑边
|
|
197
|
+
} else if (key === "transparentBackColorTolerance") {
|
|
198
|
+
layer[key] = Number(val);
|
|
199
|
+
} else {
|
|
200
|
+
layer[key] = val;
|
|
400
201
|
}
|
|
401
|
-
}
|
|
202
|
+
}
|
|
203
|
+
} // 选中颜色
|
|
402
204
|
|
|
403
205
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
206
|
+
if (this.options.highlight) {
|
|
207
|
+
layer.selectedColor = mars3d__namespace.Util.getColorByStyle(this.options.highlight);
|
|
208
|
+
} // 高度调整
|
|
407
209
|
|
|
408
210
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
211
|
+
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
|
+
layer.style3D.altitudeMode = Cesium$2.HeightReference.NONE;
|
|
213
|
+
layer.style3D.bottomAltitude = this.options.position.alt;
|
|
412
214
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
215
|
+
if (layer.refresh) {
|
|
216
|
+
layer.refresh(); // 设置风格后需刷新
|
|
416
217
|
}
|
|
417
218
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}, {
|
|
426
|
-
key: "_addedHook",
|
|
427
|
-
value: function _addedHook() {
|
|
428
|
-
this._showHook(this.show);
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* 对象从地图上移除的创建钩子方法,
|
|
432
|
-
* 每次remove时都会调用
|
|
433
|
-
* @return {void} 无
|
|
434
|
-
* @private
|
|
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
|
-
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 对象添加到地图上的创建钩子方法,
|
|
222
|
+
* 每次add时都会调用
|
|
223
|
+
* @return {void} 无
|
|
224
|
+
* @private
|
|
225
|
+
*/
|
|
456
226
|
|
|
457
|
-
this._layerArr.forEach(function (layer) {
|
|
458
|
-
method.call(context, layer);
|
|
459
|
-
});
|
|
460
227
|
|
|
461
|
-
|
|
228
|
+
_addedHook() {
|
|
229
|
+
this._showHook(this.show);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* 对象从地图上移除的创建钩子方法,
|
|
233
|
+
* 每次remove时都会调用
|
|
234
|
+
* @return {void} 无
|
|
235
|
+
* @private
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
_removedHook() {
|
|
240
|
+
this._showHook(false);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 遍历每一个子图层并将其作为参数传递给回调函数
|
|
244
|
+
*
|
|
245
|
+
* @param {Function} method 回调方法
|
|
246
|
+
* @param {Object} [context] 侦听器的上下文(this关键字将指向的对象)。
|
|
247
|
+
* @return {GroupLayer} 当前对象本身,可以链式调用
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
eachLayer(method, context) {
|
|
252
|
+
if (!this._layerArr) {
|
|
253
|
+
return;
|
|
462
254
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
255
|
+
|
|
256
|
+
this._layerArr.forEach(layer => {
|
|
257
|
+
method.call(context, layer);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
return this;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* 设置透明度
|
|
264
|
+
* @param {Number} value 透明度
|
|
265
|
+
* @return {void} 无
|
|
266
|
+
*/
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
setOpacity(value) {
|
|
270
|
+
this.eachLayer(layer => {
|
|
271
|
+
layer.style3D.fillForeColor.alpha = value;
|
|
272
|
+
}, this);
|
|
273
|
+
} // 定位至数据区域
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
flyTo() {
|
|
277
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
278
|
+
|
|
279
|
+
if (this.options.center) {
|
|
280
|
+
return this._map.setCameraView(this.options.center, options);
|
|
281
|
+
} else if (this.options.extent) {
|
|
282
|
+
return this._map.flyToExtent(this.options.extent, options);
|
|
487
283
|
}
|
|
488
|
-
}
|
|
284
|
+
}
|
|
489
285
|
|
|
490
|
-
|
|
491
|
-
}(BaseLayer$1);
|
|
286
|
+
}
|
|
492
287
|
mars3d__namespace.layer.S3MLayer = S3MLayer; // 注册下
|
|
493
288
|
|
|
494
289
|
mars3d__namespace.LayerUtil.register("supermap_s3m", S3MLayer);
|
|
495
290
|
|
|
496
|
-
|
|
497
|
-
|
|
291
|
+
const Cesium$1 = mars3d__namespace.Cesium;
|
|
292
|
+
const BaseTileLayer = mars3d__namespace.layer.BaseTileLayer;
|
|
498
293
|
/**
|
|
499
294
|
* 超图影像瓦片服务图层,
|
|
500
295
|
* 【需要引入 mars3d-supermap 插件库】
|
|
@@ -568,38 +363,23 @@
|
|
|
568
363
|
* @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/SuperMapImageryProvider.html?classFilter=SuperMapImageryProvider
|
|
569
364
|
*/
|
|
570
365
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
366
|
+
class SmImgLayer extends BaseTileLayer {
|
|
367
|
+
// 构建ImageryProvider
|
|
368
|
+
_createImageryProvider(options) {
|
|
369
|
+
return createImageryProvider(options);
|
|
370
|
+
} // 添加时
|
|
575
371
|
|
|
576
|
-
function SmImgLayer() {
|
|
577
|
-
_classCallCheck(this, SmImgLayer);
|
|
578
372
|
|
|
579
|
-
|
|
580
|
-
|
|
373
|
+
_addedHook() {
|
|
374
|
+
super._addedHook();
|
|
581
375
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
function _createImageryProvider(options) {
|
|
586
|
-
return createImageryProvider(options);
|
|
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
|
-
}
|
|
376
|
+
if (Cesium$1.defined(this.options.transparentBackColor)) {
|
|
377
|
+
this._imageryLayer.transparentBackColor = mars3d__namespace.Util.getCesiumColor(this.options.transparentBackColor);
|
|
378
|
+
this._imageryLayer.transparentBackColorTolerance = this.options.transparentBackColorTolerance; // 去黑边
|
|
598
379
|
}
|
|
599
|
-
}
|
|
380
|
+
}
|
|
600
381
|
|
|
601
|
-
|
|
602
|
-
}(BaseTileLayer);
|
|
382
|
+
}
|
|
603
383
|
|
|
604
384
|
function createImageryProvider(options) {
|
|
605
385
|
options = mars3d__namespace.LayerUtil.converOptions(options);
|
|
@@ -627,12 +407,12 @@
|
|
|
627
407
|
SmImgLayer.createImageryProvider = createImageryProvider;
|
|
628
408
|
mars3d__namespace.layer.SmImgLayer = SmImgLayer; // 注册下
|
|
629
409
|
|
|
630
|
-
|
|
410
|
+
const layerType = "supermap_img";
|
|
631
411
|
mars3d__namespace.LayerUtil.register(layerType, SmImgLayer);
|
|
632
412
|
mars3d__namespace.LayerUtil.registerImageryProvider(layerType, createImageryProvider);
|
|
633
413
|
|
|
634
|
-
|
|
635
|
-
|
|
414
|
+
const Cesium = mars3d__namespace.Cesium;
|
|
415
|
+
const BaseLayer = mars3d__namespace.layer.BaseLayer;
|
|
636
416
|
/**
|
|
637
417
|
* 超图MVT矢量瓦片图层,
|
|
638
418
|
* 【需要引入 mars3d-supermap 插件库】
|
|
@@ -664,143 +444,121 @@
|
|
|
664
444
|
* @extends {BaseLayer}
|
|
665
445
|
*/
|
|
666
446
|
|
|
667
|
-
|
|
668
|
-
|
|
447
|
+
class SmMvtLayer extends BaseLayer {
|
|
448
|
+
/**
|
|
449
|
+
* 对应的supermap图层 Cesium.VectorTilesLayer
|
|
450
|
+
* @type {*}
|
|
451
|
+
* @readonly
|
|
452
|
+
* @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/VectorTilesLayer.html
|
|
453
|
+
*/
|
|
454
|
+
get layer() {
|
|
455
|
+
return this._mvtLayer;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* 对象添加到地图前创建一些对象的钩子方法,
|
|
459
|
+
* 只会调用一次
|
|
460
|
+
* @return {void} 无
|
|
461
|
+
* @private
|
|
462
|
+
*/
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
_mountedHook() {
|
|
466
|
+
// options参考API文档:http://support.supermap.com.cn:8090/webgl/docs/Documentation/Scene.html
|
|
467
|
+
this._mvtLayer = this._map.scene.addVectorTilesMap(this.options);
|
|
468
|
+
|
|
469
|
+
this._mvtLayer.readyPromise.then(function (data) {// setPaintProperty(layerId, name, value, options)
|
|
470
|
+
// for(var layerId in that.options.style){
|
|
471
|
+
// that._mvtLayer.setPaintProperty(layerId, "fill-color", "rgba(255,0,0,0.8)");
|
|
472
|
+
// }
|
|
473
|
+
});
|
|
669
474
|
|
|
670
|
-
|
|
475
|
+
const scene = this._map.scene;
|
|
476
|
+
const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
|
|
477
|
+
handler.setInputAction(event => {
|
|
478
|
+
if (!this.show) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
671
481
|
|
|
672
|
-
|
|
673
|
-
_classCallCheck(this, SmMvtLayer);
|
|
482
|
+
const position = mars3d__namespace.PointUtil.getCurrentMousePosition(scene, event.position); // 查询出相交图层的feature
|
|
674
483
|
|
|
675
|
-
|
|
676
|
-
|
|
484
|
+
const features = this._mvtLayer.queryRenderedFeatures([position], {// layers: [selectLayer.id]
|
|
485
|
+
}); // eslint-disable-next-line array-callback-return
|
|
677
486
|
|
|
678
|
-
_createClass(SmMvtLayer, [{
|
|
679
|
-
key: "layer",
|
|
680
|
-
get:
|
|
681
|
-
/**
|
|
682
|
-
* 对应的supermap图层 Cesium.VectorTilesLayer
|
|
683
|
-
* @type {*}
|
|
684
|
-
* @readonly
|
|
685
|
-
* @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/VectorTilesLayer.html
|
|
686
|
-
*/
|
|
687
|
-
function get() {
|
|
688
|
-
return this._mvtLayer;
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* 对象添加到地图前创建一些对象的钩子方法,
|
|
692
|
-
* 只会调用一次
|
|
693
|
-
* @return {void} 无
|
|
694
|
-
* @private
|
|
695
|
-
*/
|
|
696
|
-
|
|
697
|
-
}, {
|
|
698
|
-
key: "_mountedHook",
|
|
699
|
-
value: function _mountedHook() {
|
|
700
|
-
var _this = this;
|
|
701
|
-
|
|
702
|
-
// options参考API文档:http://support.supermap.com.cn:8090/webgl/docs/Documentation/Scene.html
|
|
703
|
-
this._mvtLayer = this._map.scene.addVectorTilesMap(this.options);
|
|
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
|
-
// }
|
|
709
|
-
});
|
|
710
487
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
if (!
|
|
488
|
+
features.reduce((memo, result) => {
|
|
489
|
+
const attr = result.feature.properties;
|
|
490
|
+
|
|
491
|
+
if (!attr) {
|
|
492
|
+
// eslint-disable-next-line array-callback-return
|
|
715
493
|
return;
|
|
716
494
|
}
|
|
717
495
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
496
|
+
const content = mars3d__namespace.Util.getPopupForConfig(this.options, attr);
|
|
497
|
+
const item = {
|
|
498
|
+
data: attr,
|
|
499
|
+
event: event
|
|
500
|
+
};
|
|
722
501
|
|
|
502
|
+
this._map.openPopup(position, content, item);
|
|
503
|
+
});
|
|
504
|
+
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
505
|
+
this.handler = handler;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* 对象添加到地图上的创建钩子方法,
|
|
509
|
+
* 每次add时都会调用
|
|
510
|
+
* @return {void} 无
|
|
511
|
+
* @private
|
|
512
|
+
*/
|
|
723
513
|
|
|
724
|
-
features.reduce(function (memo, result) {
|
|
725
|
-
var attr = result.feature.properties;
|
|
726
514
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
515
|
+
_addedHook() {
|
|
516
|
+
this._mvtLayer.show = true; // this._mvtLayer.refresh();
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* 对象从地图上移除的创建钩子方法,
|
|
520
|
+
* 每次remove时都会调用
|
|
521
|
+
* @return {void} 无
|
|
522
|
+
* @private
|
|
523
|
+
*/
|
|
731
524
|
|
|
732
|
-
var content = mars3d__namespace.Util.getPopupForConfig(_this.options, attr);
|
|
733
|
-
var item = {
|
|
734
|
-
data: attr,
|
|
735
|
-
event: event
|
|
736
|
-
};
|
|
737
525
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
this.handler = handler;
|
|
742
|
-
}
|
|
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();
|
|
526
|
+
_removedHook() {
|
|
527
|
+
if (this._mvtLayer) {
|
|
528
|
+
this._mvtLayer.show = false;
|
|
754
529
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
this._mvtLayer.show = false;
|
|
767
|
-
}
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* 设置透明度
|
|
533
|
+
* @param {Number} value 透明度
|
|
534
|
+
* @return {void} 无
|
|
535
|
+
*/
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
setOpacity(value) {
|
|
539
|
+
if (this._mvtLayer) {
|
|
540
|
+
this._mvtLayer.alpha = parseFloat(value);
|
|
768
541
|
}
|
|
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
|
-
}
|
|
542
|
+
} // 定位至数据区域
|
|
543
|
+
|
|
797
544
|
|
|
798
|
-
|
|
545
|
+
flyTo() {
|
|
546
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
547
|
+
|
|
548
|
+
if (this.options.center) {
|
|
549
|
+
return this._map.setCameraView(this.options.center, options);
|
|
550
|
+
} else if (this.options.extent) {
|
|
551
|
+
return this._map.flyToExtent(this.options.extent, options);
|
|
552
|
+
} else if (this._mvtLayer) {
|
|
553
|
+
return this._map.camera.flyTo({ ...options,
|
|
554
|
+
destination: this._mvtLayer.rectangle
|
|
555
|
+
});
|
|
799
556
|
}
|
|
800
|
-
}]);
|
|
801
557
|
|
|
802
|
-
|
|
803
|
-
|
|
558
|
+
return Promise.resolve(false);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
}
|
|
804
562
|
mars3d__namespace.layer.SmMvtLayer = SmMvtLayer; // 注册下
|
|
805
563
|
|
|
806
564
|
mars3d__namespace.LayerUtil.register("supermap_mvt", SmMvtLayer);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mars3d-supermap",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.9",
|
|
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.9"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"lint": "eslint ./src/**/*.{js,ts} --fix"
|