@mapgis/webclient-vue-cesium 10.5.5-1 → 10.5.5-6

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 (124) hide show
  1. package/README.md +46 -49
  2. package/dist-libs/webclient-vue-cesium.common.js +191087 -0
  3. package/dist-libs/webclient-vue-cesium.css +1 -1
  4. package/dist-libs/webclient-vue-cesium.umd.js +191097 -0
  5. package/dist-libs/webclient-vue-cesium.umd.min.js +204 -194
  6. package/docs/.vuepress/config.js +47 -46
  7. package/docs/README.md +5 -4
  8. package/docs/api/analysis/Aspect.md +236 -0
  9. package/docs/api/analysis/Contour.md +240 -0
  10. package/docs/api/analysis/CutFill.md +306 -0
  11. package/docs/api/analysis/DynamicSection.md +336 -0
  12. package/docs/api/analysis/Excavate.md +3 -11
  13. package/docs/api/analysis/Flood.md +177 -200
  14. package/docs/api/analysis/HeightLimited.md +7 -4
  15. package/docs/api/analysis/ParticleEffects.md +549 -0
  16. package/docs/api/analysis/Profile.md +464 -0
  17. package/docs/api/analysis/Shadow.md +76 -13
  18. package/docs/api/analysis/Sightline.md +66 -13
  19. package/docs/api/analysis/Skyline.md +144 -29
  20. package/docs/api/analysis/Slope.md +236 -0
  21. package/docs/api/analysis/Viewshed.md +100 -21
  22. package/docs/api/layer/IGServer/IgsDocLayer.md +10 -0
  23. package/docs/api/layer/IGServer/IgsFeatureLayer.md +253 -0
  24. package/docs/api/layer/IGServer/IgsTileLayer.md +11 -0
  25. package/docs/api/layer/OGC/CesiumOgcWmsLayer.md +20 -19
  26. package/docs/api/layer/OGC/Wms.png +0 -0
  27. package/docs/api/layer/marker/DynamicMarker.md +81 -0
  28. package/docs/api/layer/marker/dynamicmarker.png +0 -0
  29. package/docs/api/layer/marker/selects.png +0 -0
  30. package/docs/api/layer/vectortile/vectortile.md +10 -0
  31. package/docs/api/m3d/image/layer_control_1.png +0 -0
  32. package/docs/api/m3d/image/layer_control_2.png +0 -0
  33. package/docs/api/m3d/image/layer_control_3.png +0 -0
  34. package/docs/api/m3d/m3d.md +13 -2
  35. package/docs/api/service/comprehensiveQuery/comprehensiveQuery.md +946 -0
  36. package/docs/api/ui/draw.md +68 -40
  37. package/docs/api/ui/link.md +8 -1
  38. package/docs/api/ui/marker.md +19 -1
  39. package/docs/api/ui/measure.md +82 -10
  40. package/docs/api/ui/table.md +6 -6
  41. package/docs/guide/README.md +26 -23
  42. package/docs/guide/basemap.md +35 -33
  43. package/docs/guide/markers&popups.md +46 -53
  44. package/docs/plugin_components/create_storybook.md +241 -0
  45. package/docs/plugin_components/img.png +0 -0
  46. package/docs/plugin_components/img_1.png +0 -0
  47. package/docs/plugin_components/img_10.png +0 -0
  48. package/docs/plugin_components/img_2.png +0 -0
  49. package/docs/plugin_components/img_3.png +0 -0
  50. package/docs/plugin_components/img_4.png +0 -0
  51. package/docs/plugin_components/img_5.png +0 -0
  52. package/docs/plugin_components/img_6.png +0 -0
  53. package/docs/plugin_components/img_7.png +0 -0
  54. package/docs/plugin_components/img_8.png +0 -0
  55. package/docs/version/diff.md +4 -4
  56. package/docs/version/version.md +81 -0
  57. package/package.json +5 -5
  58. package/src/cdn/cdn_component.js +62 -0
  59. package/src/component.js +20 -2
  60. package/src/components/Analysis/Aspect.vue +318 -0
  61. package/src/components/Analysis/Contour.vue +257 -0
  62. package/src/components/Analysis/CutFill.vue +581 -0
  63. package/src/components/Analysis/DynamicCutting.vue +98 -59
  64. package/src/components/Analysis/DynamicSection.vue +494 -0
  65. package/src/components/Analysis/Excavate.vue +133 -87
  66. package/src/components/Analysis/Flood.vue +395 -487
  67. package/src/components/Analysis/Flood.vue-- +630 -0
  68. package/src/components/Analysis/HeightLimited.vue +66 -47
  69. package/src/components/Analysis/ModelFlatten.vue +2 -2
  70. package/src/components/Analysis/Profile.vue +503 -0
  71. package/src/components/Analysis/Shadow.vue +220 -309
  72. package/src/components/Analysis/Sightline.vue +393 -375
  73. package/src/components/Analysis/SkyLine.vue +283 -93
  74. package/src/components/Analysis/Slope.vue +317 -0
  75. package/src/components/Analysis/Viewshed.vue +806 -373
  76. package/src/components/Analysis/skyline2dChartOptions.js +66 -0
  77. package/src/components/DataSource/Geojson/GeoJsonDataSource.vue +201 -3
  78. package/src/components/Layer/GeoJSON/GeoJsonLayer.vue +345 -0
  79. package/src/components/Layer/IGServer/IgsFeatureLayer.vue +227 -0
  80. package/src/components/Layer/Marker/DynamicMarkerLayer.vue +487 -0
  81. package/src/components/Layer/Marker/Marker3dPro.vue +196 -0
  82. package/src/components/Layer/Marker/Marker3dSetPro.vue +67 -0
  83. package/src/components/Layer/VectorTile/VectorTileLayer.vue +117 -33
  84. package/src/components/Layer/VectorTile/VectorTileOptions.js +1 -1
  85. package/src/components/M3D/3DTilesetOptions.js +23 -1
  86. package/src/components/M3D/G3D.vue +150 -0
  87. package/src/components/M3D/M3d.vue +142 -32
  88. package/src/components/M3D/M3dSet.vue +118 -0
  89. package/src/components/M3D/M3dType.js +24 -0
  90. package/src/components/Overlay/Mapv3dLayer.vue +2 -0
  91. package/src/components/Overlay/ParticleEffects.vue +545 -0
  92. package/src/components/Overlay/mapv/MapvBaseLayer.js +351 -172
  93. package/src/components/Overlay/mapv/MapvLayer.js +372 -324
  94. package/src/components/Overlay/mapv/SuperCluster.js +611 -0
  95. package/src/components/Overlay/themeLayer/heater/CesiumHeater.vue +152 -0
  96. package/src/components/Overlay/themeLayer/heater/MapvHeater.vue +161 -0
  97. package/src/components/UI/Controls/Draw/Draw.vue +320 -92
  98. package/src/components/UI/Controls/Legend/Legend.vue +55 -51
  99. package/src/components/UI/Controls/Link/Link.vue +59 -37
  100. package/src/components/UI/Controls/Measure/Measure.vue +75 -33
  101. package/src/components/UI/Controls/Measure/components/MeasureResult.vue +71 -0
  102. package/src/components/UI/Controls/Measure/components/MeasureSetting.vue +63 -0
  103. package/src/components/UI/Controls/Measure/components/MeasureTool.vue +155 -0
  104. package/src/components/UI/Geojson/Popup.vue +101 -0
  105. package/src/components/UI/Marker/Marker.vue +185 -48
  106. package/src/components/UI/Popup/Popup.vue +21 -64
  107. package/src/components/Utils/common/color-util.js +159 -0
  108. package/src/components/Utils/util.js +311 -231
  109. package/src/components/WebGlobe/manager.js +81 -3
  110. package/src/components/WebGlobe/mixins/withPrivateMethods.js +4 -2
  111. package/src/components/WebGlobe/util.js +173 -0
  112. package/src/components/service/comprehensive-query/ComprehensiveQuery.vue +156 -0
  113. package/src/components/service/comprehensive-query/PlaceNameCesium.vue +102 -0
  114. package/src/components/service/comprehensive-query/util/catalog/document.js +626 -0
  115. package/src/components/service/comprehensive-query/util/feature/arcgis-feature-query.js +448 -0
  116. package/src/components/service/comprehensive-query/util/feature/feature-convert.js +408 -0
  117. package/src/components/service/comprehensive-query/util/feature/feature-edit.js +50 -0
  118. package/src/components/service/comprehensive-query/util/feature/feature-geojson.js +100 -0
  119. package/src/components/service/comprehensive-query/util/feature/feature-query.js +723 -0
  120. package/src/components/service/comprehensive-query/util/feature/feature.js +1 -0
  121. package/src/components/service/comprehensive-query/util/feature/index.js +9 -0
  122. package/src/components/service/comprehensive-query/util/objects/geometry.js +58 -0
  123. package/src/components/Overlay/Mapv.vue +0 -142
  124. package/src/components/Overlay/MapvHeater.vue +0 -98
@@ -1,35 +1,96 @@
1
- export const checkType = (val) => Object.prototype.toString.call(val).slice(8, -1)
1
+ export const checkType = val =>
2
+ Object.prototype.toString.call(val).slice(8, -1);
2
3
 
3
- export const toKebabCase = (str) =>
4
- str.replace(new RegExp("[A-Z]", 'g'), (letter) => `-${letter.toLowerCase()}`).replace(new RegExp("^-"), '')
4
+ export const toKebabCase = str =>
5
+ str
6
+ .replace(new RegExp("[A-Z]", "g"), letter => `-${letter.toLowerCase()}`)
7
+ .replace(new RegExp("^-"), "");
5
8
  /**
6
9
  * 通过 class 名获取 Dom 元素。
7
10
  * @param {Array<Element>} htmlCollection Dom元素集合。
8
11
  * @param {String} className class 名称。
9
12
  */
10
13
  export const getDocumentByClassName = (htmlCollection, className) => {
11
- let temp
12
- const BreakException = {}
14
+ let temp;
15
+ const BreakException = {};
13
16
  try {
14
- Array.prototype.slice.call(htmlCollection).forEach((element) => {
17
+ Array.prototype.slice.call(htmlCollection).forEach(element => {
15
18
  if (element.className === className) {
16
- temp = element
17
- throw BreakException
19
+ temp = element;
20
+ throw BreakException;
18
21
  }
19
- })
22
+ });
20
23
  } catch (e) {
21
- if (e !== BreakException) throw e
24
+ if (e !== BreakException) throw e;
22
25
  }
23
- return temp
24
- }
26
+ return temp;
27
+ };
25
28
  /**
26
29
  * 判断传入的对象是否是方法。
27
30
  * @param {*} value
28
31
  * @returns {Boolean}
29
32
  */
30
- export function isFunction (value) {
31
- return typeof value === 'function'
33
+ export function isFunction(value) {
34
+ return typeof value === "function";
35
+ }
36
+
37
+ /**
38
+ * 是否有效数据
39
+ * @param {*} v
40
+ * @returns
41
+ */
42
+ export function isDef(v) {
43
+ return v !== undefined && v !== null;
44
+ }
45
+
46
+ /**
47
+ * 校验数据的原始数据类型
48
+ * @param {*} v
49
+ * @returns {string}
50
+ */
51
+ export function typeOf(v) {
52
+ const _toString = Object.prototype.toString;
53
+ let res;
54
+ switch (_toString.call(v)) {
55
+ case "[object Object]":
56
+ res = "object";
57
+ break;
58
+ case "[object Array]":
59
+ res = "array";
60
+ break;
61
+ case "[object Function]":
62
+ res = "function";
63
+ break;
64
+ case "[object String]":
65
+ res = "string";
66
+ break;
67
+ case "[object Number]":
68
+ res = "number";
69
+ break;
70
+ case "[object Symbol]":
71
+ res = "symbol";
72
+ break;
73
+ case "[object Undefined]":
74
+ res = "undefined";
75
+ break;
76
+ case "[object Null]":
77
+ res = "null";
78
+ break;
79
+ default:
80
+ break;
81
+ }
82
+ return res;
83
+ }
84
+
85
+ /**
86
+ * 是否空对象
87
+ * @param {*} v
88
+ * @returns {boolean}
89
+ */
90
+ export function isEmptyObj(v) {
91
+ return !isDef(v) || (typeOf(v, "object") && !Object.keys(v).length);
32
92
  }
93
+
33
94
  /**
34
95
  * 验证是否是经纬度。
35
96
  * @param {Number} longitude
@@ -37,26 +98,30 @@ export function isFunction (value) {
37
98
  * @returns {Boolean}
38
99
  */
39
100
  export function lnglatValidator(longitude, latitude) {
40
- // 经度,整数部分为0-180小数部分为0到6位
41
- // const longreg = /^(-|\+)?(((\d|[1-9]\d|1[0-7]\d|0{1,3})\.\d{0,15})|(\d|[1-9]\d|1[0-7]\d|0{1,3})|180\.0{0,15}|180)$/
42
- const longreg = new RegExp("^(-|\\+)?(((\d|[1-9]\d|1[0-7]\d|0{1,3})\.\d{0,15})|(\d|[1-9]\d|1[0-7]\d|0{1,3})|180\.0{0,15}|180)$");
43
- if (!longreg.test(longitude)) {
44
- return false
45
- } // 纬度,整数部分为0-90小数部分为0到6位
46
- // const latreg = /^(-|\+)?([0-8]?\d{1}\.\d{0,15}|90\.0{0,15}|[0-8]?\d{1}|90)$/
47
- const latreg = new RegExp("^(-|\\+)?([0-8]?\d{1}\.\d{0,15}|90\.0{0,15}|[0-8]?\d{1}|90)$");
48
- if (!latreg.test(latitude)) {
49
- return false
50
- }
51
- return true
101
+ // 经度,整数部分为0-180小数部分为0到6位
102
+ // const longreg = /^(-|\+)?(((\d|[1-9]\d|1[0-7]\d|0{1,3})\.\d{0,15})|(\d|[1-9]\d|1[0-7]\d|0{1,3})|180\.0{0,15}|180)$/
103
+ const longreg = new RegExp(
104
+ "^(-|\\+)?(((d|[1-9]d|1[0-7]d|0{1,3}).d{0,15})|(d|[1-9]d|1[0-7]d|0{1,3})|180.0{0,15}|180)$"
105
+ );
106
+ if (!longreg.test(longitude)) {
107
+ return false;
108
+ } // 纬度,整数部分为0-90小数部分为0到6位
109
+ // const latreg = /^(-|\+)?([0-8]?\d{1}\.\d{0,15}|90\.0{0,15}|[0-8]?\d{1}|90)$/
110
+ const latreg = new RegExp(
111
+ "^(-|\\+)?([0-8]?d{1}.d{0,15}|90.0{0,15}|[0-8]?d{1}|90)$"
112
+ );
113
+ if (!latreg.test(latitude)) {
114
+ return false;
115
+ }
116
+ return true;
52
117
  }
53
118
  /**
54
119
  * 普通对象 {x: number, y: number } 转换为 Cesium.Cartesian2 对象
55
120
  * @param {Object} val
56
121
  * @returns {Object}
57
122
  */
58
- export function makeCartesian2 (val) {
59
- return val && new Cesium.Cartesian2(val.x, val.y)
123
+ export function makeCartesian2(val) {
124
+ return val && new Cesium.Cartesian2(val.x, val.y);
60
125
  }
61
126
 
62
127
  /**
@@ -64,13 +129,13 @@ export function makeCartesian2 (val) {
64
129
  * @param {Object} val
65
130
  * @returns {Object}
66
131
  */
67
- export function makeCartesian3 (val) {
68
- if (val && Object.prototype.hasOwnProperty.call(val, 'x')) {
69
- return new Cesium.Cartesian3(val.x, val.y, val.z)
70
- } else if (val && Object.prototype.hasOwnProperty.call(val, 'lng')) {
71
- return Cesium.Cartesian3.fromDegrees(val.lng, val.lat, val.height)
132
+ export function makeCartesian3(val) {
133
+ if (val && Object.prototype.hasOwnProperty.call(val, "x")) {
134
+ return new Cesium.Cartesian3(val.x, val.y, val.z);
135
+ } else if (val && Object.prototype.hasOwnProperty.call(val, "lng")) {
136
+ return Cesium.Cartesian3.fromDegrees(val.lng, val.lat, val.height);
72
137
  }
73
- return val
138
+ return val;
74
139
  }
75
140
 
76
141
  /**
@@ -78,99 +143,104 @@ export function makeCartesian3 (val) {
78
143
  * @param {Array} val
79
144
  * @returns {Array<Cartesian3>}
80
145
  */
81
- export function makeCartesian3Array (vals) {
146
+ export function makeCartesian3Array(vals) {
82
147
  if (vals && vals instanceof Array && vals[0] instanceof Cesium.Cartesian3) {
83
- return vals
148
+ return vals;
84
149
  }
85
150
 
86
- const coordinates = []
87
- vals.forEach((item) => {
88
- coordinates.push(item.lng)
89
- coordinates.push(item.lat)
90
- coordinates.push(item.height)
91
- })
151
+ const coordinates = [];
152
+ vals.forEach(item => {
153
+ coordinates.push(item.lng);
154
+ coordinates.push(item.lat);
155
+ coordinates.push(item.height);
156
+ });
92
157
 
93
- return coordinates.length >= 3 ? Cesium.Cartesian3.fromDegreesArrayHeights(coordinates) : vals
158
+ return coordinates.length >= 3
159
+ ? Cesium.Cartesian3.fromDegreesArrayHeights(coordinates)
160
+ : vals;
94
161
  }
95
162
  /**
96
163
  * 普通数组 [lng, lat, ……,lng, lat] 转换为 Cesium.Cartesian2 数组
97
164
  * @param {Array} vals
98
165
  * @returns {Array<Cartesian2>}
99
166
  */
100
- export function makeCartesian2Array (vals) {
101
- const cartesian2Array = []
102
- vals.forEach((item) => {
103
- cartesian2Array.push(new Cesium.Cartesian2(item.x, item.y))
104
- })
105
- return cartesian2Array
167
+ export function makeCartesian2Array(vals) {
168
+ const cartesian2Array = [];
169
+ vals.forEach(item => {
170
+ cartesian2Array.push(new Cesium.Cartesian2(item.x, item.y));
171
+ });
172
+ return cartesian2Array;
106
173
  }
107
174
 
108
175
  /**
109
176
  *
110
177
  * @param {Object} val
111
178
  */
112
- export function makeQuaternion (val) {
113
- return val.x ? new Cesium.Quaternion(val.x, val.y, val.z, val.w) : val
179
+ export function makeQuaternion(val) {
180
+ return val.x ? new Cesium.Quaternion(val.x, val.y, val.z, val.w) : val;
114
181
  }
115
182
 
116
183
  /**
117
184
  * 解析 HierarchyJson
118
185
  * @param {Object} val
119
186
  */
120
- function parsePolygonHierarchyJson (val) {
121
- val.forEach((element) => {
122
- element.positions = makeCartesian3Array(element.positions)
187
+ function parsePolygonHierarchyJson(val) {
188
+ val.forEach(element => {
189
+ element.positions = makeCartesian3Array(element.positions);
123
190
  if (element.holes) {
124
- parsePolygonHierarchyJson(element.holes)
191
+ parsePolygonHierarchyJson(element.holes);
125
192
  }
126
- })
193
+ });
127
194
  }
128
195
 
129
196
  /**
130
197
  * 普通数组或对象转 Cesium.PolygonHierarchy 对象。
131
198
  * @param {Object|Array} val
132
199
  */
133
- export function makePolygonHierarchy (val) {
200
+ export function makePolygonHierarchy(val) {
134
201
  if (val instanceof Array && val.length >= 3) {
135
- return new Cesium.PolygonHierarchy(makeCartesian3Array(val))
202
+ return new Cesium.PolygonHierarchy(makeCartesian3Array(val));
136
203
  }
137
204
  if (Cesium.defined(val.positions)) {
138
- val.positions = makeCartesian3Array(val.positions)
139
- parsePolygonHierarchyJson(val.holes)
205
+ val.positions = makeCartesian3Array(val.positions);
206
+ parsePolygonHierarchyJson(val.holes);
140
207
  }
141
208
 
142
- return val
209
+ return val;
143
210
  }
144
211
  /**
145
212
  * 普通对象 {near: number, nearValue: number, far: number, farValue: number} 转 Cesium.NearFarScalar 对象。
146
213
  * @param {Object} val
147
214
  * @returns {NearFarScalar}
148
215
  */
149
- export function makeNearFarScalar (val) {
150
- return val && new Cesium.NearFarScalar(val.near, val.nearValue, val.far, val.farValue)
216
+ export function makeNearFarScalar(val) {
217
+ return (
218
+ val &&
219
+ new Cesium.NearFarScalar(val.near, val.nearValue, val.far, val.farValue)
220
+ );
151
221
  }
152
222
  /**
153
223
  * 普通对象 {near: number, far: number} 转 Cesium.DistanceDisplayCondition 对象。
154
224
  * @param {Object} val
155
225
  * @returns {DistanceDisplayCondition}
156
226
  */
157
- export function makeDistanceDisplayCondition (val) {
158
- return val && new Cesium.DistanceDisplayCondition(val.near, val.far)
227
+ export function makeDistanceDisplayCondition(val) {
228
+ return val && new Cesium.DistanceDisplayCondition(val.near, val.far);
159
229
  }
160
230
  /**
161
231
  * 普通对象或数组 [r, g, b, a] 或字符串转 Cesium.Color 对象。
162
232
  * @param {String|Array|Object} val
163
233
  * @returns {Color}
164
234
  */
165
- export function makeColor (val) {
235
+ export function makeColor(val) {
166
236
  if (val instanceof Cesium.Color) {
167
- return val
237
+ return val;
168
238
  } else if (val instanceof Array) {
169
- return new Cesium.Color(val[0], val[1], val[2], val[3])
170
- } else if (typeof val === 'string') {
171
- return Cesium.Color.fromCssColorString(val)
239
+ return new Cesium.Color(val[0], val[1], val[2], val[3]);
240
+ } else if (typeof val === "string") {
241
+ return Cesium.Color.fromCssColorString(val);
172
242
  }
173
- return val
243
+ return val;
174
244
  }
175
245
 
176
246
  /**
@@ -178,30 +248,29 @@ export function makeColor (val) {
178
248
  * @param {String|Array|Object} val
179
249
  */
180
250
  export function makeMaterial(val) {
181
- // if (
182
- // val instanceof Array ||
183
- // (typeof val === 'string' && !/(.*)\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$/.test(val))
184
- // ) {
185
- // return makeColor(val)
186
- // }
187
- const regExp = new RegExp("(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$");
188
- if (
189
- val instanceof Array ||
190
- (typeof val === 'string' && !regExp.test(val))
191
- ) {
192
- return makeColor(val)
193
- }
194
- // else if (val && val.hasOwnProperty('fabric')) {
195
- // return new Cesium.Material({
196
- // fabric: {
197
- // type: 'Color',
198
- // uniforms: {
199
- // color: new Cesium.Color(1.0, 1.0, 0.0, 1.0)
200
- // }
201
- // }
202
- // })
203
- // }
204
- return val
251
+ // if (
252
+ // val instanceof Array ||
253
+ // (typeof val === 'string' && !/(.*)\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$/.test(val))
254
+ // ) {
255
+ // return makeColor(val)
256
+ // }
257
+ const regExp = new RegExp(
258
+ "(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$"
259
+ );
260
+ if (val instanceof Array || (typeof val === "string" && !regExp.test(val))) {
261
+ return makeColor(val);
262
+ }
263
+ // else if (val && val.hasOwnProperty('fabric')) {
264
+ // return new Cesium.Material({
265
+ // fabric: {
266
+ // type: 'Color',
267
+ // uniforms: {
268
+ // color: new Cesium.Color(1.0, 1.0, 0.0, 1.0)
269
+ // }
270
+ // }
271
+ // })
272
+ // }
273
+ return val;
205
274
  }
206
275
 
207
276
  /**
@@ -210,11 +279,14 @@ export function makeMaterial(val) {
210
279
  * @returns {Rectangle}
211
280
  */
212
281
  export function makeRectangle(val) {
213
- // Entiy 的 rectangle 属性不能调用这个方法
214
- if (val instanceof Cesium.RectangleGraphics) {
215
- return val
216
- }
217
- return val && Cesium.Rectangle.fromDegrees(val.west, val.south, val.east, val.north)
282
+ // Entiy 的 rectangle 属性不能调用这个方法
283
+ if (val instanceof Cesium.RectangleGraphics) {
284
+ return val;
285
+ }
286
+ return (
287
+ val &&
288
+ Cesium.Rectangle.fromDegrees(val.west, val.south, val.east, val.north)
289
+ );
218
290
  }
219
291
 
220
292
  /**
@@ -223,7 +295,9 @@ export function makeRectangle(val) {
223
295
  * @returns {BoundingRectangle}
224
296
  */
225
297
  export function makeBoundingRectangle(val) {
226
- return val && new Cesium.BoundingRectangle(val.x, val.y, val.width, val.height)
298
+ return (
299
+ val && new Cesium.BoundingRectangle(val.x, val.y, val.width, val.height)
300
+ );
227
301
  }
228
302
 
229
303
  /**
@@ -232,15 +306,15 @@ export function makeBoundingRectangle(val) {
232
306
  * @returns {Plane}
233
307
  */
234
308
  export function makePlane(val) {
235
- // Entiy 和 PlaneGraphics 都有个 plane 属性 要区别一下
236
- if (val instanceof Cesium.PlaneGraphics) {
237
- return val
238
- }
239
- if (val) {
240
- Cesium.Cartesian3.normalize(makeCartesian3(val.normal), val.normal)
241
- return new Cesium.Plane(val.normal, val.distance)
242
- }
243
- return val
309
+ // Entiy 和 PlaneGraphics 都有个 plane 属性 要区别一下
310
+ if (val instanceof Cesium.PlaneGraphics) {
311
+ return val;
312
+ }
313
+ if (val) {
314
+ Cesium.Cartesian3.normalize(makeCartesian3(val.normal), val.normal);
315
+ return new Cesium.Plane(val.normal, val.distance);
316
+ }
317
+ return val;
244
318
  }
245
319
 
246
320
  /**
@@ -248,138 +322,144 @@ export function makePlane(val) {
248
322
  * @param {*} val
249
323
  */
250
324
  export function makeTranslationRotationScale(val) {
251
- return (
252
- val &&
253
- new Cesium.TranslationRotationScale(
254
- makeCartesian3(val.translation),
255
- makeQuaternion(val.rotation),
256
- makeCartesian3(val.scale)
257
- )
325
+ return (
326
+ val &&
327
+ new Cesium.TranslationRotationScale(
328
+ makeCartesian3(val.translation),
329
+ makeQuaternion(val.rotation),
330
+ makeCartesian3(val.scale)
258
331
  )
332
+ );
259
333
  }
260
334
 
261
335
  export function makeOptions(val) {
262
- const cmpName = this.$options.name
263
- switch (cmpName) {
264
- case 'vc-datasource-geojson':
265
- const result = {}
266
- Object.assign(result, val)
267
- result && result.markerColor && (result.markerColor = makeColor(result.markerColor))
268
- result && result.stroke && (result.stroke = makeColor(result.stroke))
269
- result && result.fill && (result.fill = makeColor(result.fill))
270
- return result
271
- }
272
- return val
336
+ const cmpName = this.$options.name;
337
+ switch (cmpName) {
338
+ case "vc-datasource-geojson":
339
+ const result = {};
340
+ Object.assign(result, val);
341
+ result &&
342
+ result.markerColor &&
343
+ (result.markerColor = makeColor(result.markerColor));
344
+ result && result.stroke && (result.stroke = makeColor(result.stroke));
345
+ result && result.fill && (result.fill = makeColor(result.fill));
346
+ return result;
347
+ }
348
+ return val;
273
349
  }
274
350
 
275
351
  export function dirname(path) {
276
- if (typeof path !== 'string') path = path + ''
277
- if (path.length === 0) return '.'
278
- var code = path.charCodeAt(0)
279
- var hasRoot = code === 47 /* / */
280
- var end = -1
281
- var matchedSlash = true
282
- for (var i = path.length - 1; i >= 1; --i) {
283
- code = path.charCodeAt(i)
284
- if (code === 47 /* / */) {
285
- if (!matchedSlash) {
286
- end = i
287
- break
288
- }
289
- } else {
290
- // We saw the first non-path separator
291
- matchedSlash = false
292
- }
352
+ if (typeof path !== "string") path = path + "";
353
+ if (path.length === 0) return ".";
354
+ var code = path.charCodeAt(0);
355
+ var hasRoot = code === 47; /* / */
356
+ var end = -1;
357
+ var matchedSlash = true;
358
+ for (var i = path.length - 1; i >= 1; --i) {
359
+ code = path.charCodeAt(i);
360
+ if (code === 47 /* / */) {
361
+ if (!matchedSlash) {
362
+ end = i;
363
+ break;
364
+ }
365
+ } else {
366
+ // We saw the first non-path separator
367
+ matchedSlash = false;
293
368
  }
369
+ }
294
370
 
295
- if (end === -1) return hasRoot ? '/' : '.'
296
- if (hasRoot && end === 1) {
297
- // return '//';
298
- // Backwards-compat fix:
299
- return '/'
300
- }
301
- return path.slice(0, end)
371
+ if (end === -1) return hasRoot ? "/" : ".";
372
+ if (hasRoot && end === 1) {
373
+ // return '//';
374
+ // Backwards-compat fix:
375
+ return "/";
376
+ }
377
+ return path.slice(0, end);
302
378
  }
303
379
 
304
380
  export function Platform() {
305
- var ua = navigator.userAgent
306
- // var isWindowsPhone = /(?:Windows Phone)/.test(ua)
307
- const windowsPone = new RegExp("(?:Windows Phone)")
308
- var isWindowsPhone = windowsPone.test(ua)
309
- // var isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone
310
- const symbianOs = new RegExp("(?:SymbianOS)")
311
- var isSymbian = symbianOs.test(ua) || isWindowsPhone
312
- // var isAndroid = /(?:Android)/.test(ua)
313
- const android = new RegExp("(?:Android)")
314
- var isAndroid = android.test(ua)
315
- // var isFireFox = /(?:Firefox)/.test(ua)
316
- const firefox = new RegExp("(?:Firefox)")
317
- var isFireFox = firefox.test(ua)
318
- // var isChrome = /(?:Chrome|CriOS)/.test(ua)
319
- const chrome = new RegExp("(?:Chrome|CriOS)")
320
- var isChrome = chrome.test(ua)
321
-
322
- // var isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua))
323
- const ipadOrplaybook = new RegExp("(?:iPad|PlayBook)")
324
- const mobile = new RegExp("(?:Mobile)")
325
- const tablet = new RegExp("(?:Tablet)")
326
- var isTablet = ipadOrplaybook.test(ua) || (isAndroid && !mobile.test(ua)) || (isFireFox && tablet.test(ua))
327
- // var isPhone = /(?:iPhone)/.test(ua) && !isTablet
328
- const iphone = new RegExp("(?:iPhone)")
329
- var isPhone = iphone.test(ua) && !isTablet
330
- var isPc = !isPhone && !isAndroid && !isSymbian
331
- return {
332
- isTablet: isTablet,
333
- isPhone: isPhone,
334
- isAndroid: isAndroid,
335
- isPc: isPc,
336
- isChrome: isChrome
337
- }
381
+ var ua = navigator.userAgent;
382
+ // var isWindowsPhone = /(?:Windows Phone)/.test(ua)
383
+ const windowsPone = new RegExp("(?:Windows Phone)");
384
+ var isWindowsPhone = windowsPone.test(ua);
385
+ // var isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone
386
+ const symbianOs = new RegExp("(?:SymbianOS)");
387
+ var isSymbian = symbianOs.test(ua) || isWindowsPhone;
388
+ // var isAndroid = /(?:Android)/.test(ua)
389
+ const android = new RegExp("(?:Android)");
390
+ var isAndroid = android.test(ua);
391
+ // var isFireFox = /(?:Firefox)/.test(ua)
392
+ const firefox = new RegExp("(?:Firefox)");
393
+ var isFireFox = firefox.test(ua);
394
+ // var isChrome = /(?:Chrome|CriOS)/.test(ua)
395
+ const chrome = new RegExp("(?:Chrome|CriOS)");
396
+ var isChrome = chrome.test(ua);
397
+
398
+ // var isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua))
399
+ const ipadOrplaybook = new RegExp("(?:iPad|PlayBook)");
400
+ const mobile = new RegExp("(?:Mobile)");
401
+ const tablet = new RegExp("(?:Tablet)");
402
+ var isTablet =
403
+ ipadOrplaybook.test(ua) ||
404
+ (isAndroid && !mobile.test(ua)) ||
405
+ (isFireFox && tablet.test(ua));
406
+ // var isPhone = /(?:iPhone)/.test(ua) && !isTablet
407
+ const iphone = new RegExp("(?:iPhone)");
408
+ var isPhone = iphone.test(ua) && !isTablet;
409
+ var isPc = !isPhone && !isAndroid && !isSymbian;
410
+ return {
411
+ isTablet: isTablet,
412
+ isPhone: isPhone,
413
+ isAndroid: isAndroid,
414
+ isPc: isPc,
415
+ isChrome: isChrome
416
+ };
338
417
  }
339
418
 
340
419
  export function captureScreenshot(viewer, showSplitter = false) {
341
- const {when} = Cesium
342
- const deferred = when.defer()
343
- const scene = viewer.scene
344
- var removeCallback = scene.postRender.addEventListener(function () {
345
- removeCallback()
346
- try {
347
- const cesiumCanvas = viewer.scene.canvas
348
-
349
- // If we're using the splitter, draw the split position as a vertical white line.
350
- let canvas = cesiumCanvas
351
- // if (showSplitter) {
352
- // canvas = document.createElement('canvas')
353
- // canvas.width = cesiumCanvas.width
354
- // canvas.height = cesiumCanvas.height
355
-
356
- // const context = canvas.getContext('2d')
357
- // context.drawImage(cesiumCanvas, 0, 0)
358
-
359
- // const x = viewer.splitPosition * cesiumCanvas.width
360
- // context.strokeStyle = this.terria.baseMapContrastColor
361
- // context.beginPath()
362
- // context.moveTo(x, 0)
363
- // context.lineTo(x, cesiumCanvas.height)
364
- // context.stroke()
365
- // }
366
-
367
- deferred.resolve(canvas.toDataURL('image/png'))
368
- } catch (e) {
369
- deferred.reject(e)
370
- }
371
- }, this)
372
-
373
- scene.render(viewer.clock.currentTime)
374
-
375
- return deferred.promise
420
+ const { when } = Cesium;
421
+ const deferred = when.defer();
422
+ const scene = viewer.scene;
423
+ var removeCallback = scene.postRender.addEventListener(function() {
424
+ removeCallback();
425
+ try {
426
+ const cesiumCanvas = viewer.scene.canvas;
427
+
428
+ // If we're using the splitter, draw the split position as a vertical white line.
429
+ let canvas = cesiumCanvas;
430
+ // if (showSplitter) {
431
+ // canvas = document.createElement('canvas')
432
+ // canvas.width = cesiumCanvas.width
433
+ // canvas.height = cesiumCanvas.height
434
+
435
+ // const context = canvas.getContext('2d')
436
+ // context.drawImage(cesiumCanvas, 0, 0)
437
+
438
+ // const x = viewer.splitPosition * cesiumCanvas.width
439
+ // context.strokeStyle = this.terria.baseMapContrastColor
440
+ // context.beginPath()
441
+ // context.moveTo(x, 0)
442
+ // context.lineTo(x, cesiumCanvas.height)
443
+ // context.stroke()
444
+ // }
445
+
446
+ deferred.resolve(canvas.toDataURL("image/png"));
447
+ } catch (e) {
448
+ deferred.reject(e);
449
+ }
450
+ }, this);
451
+
452
+ scene.render(viewer.clock.currentTime);
453
+
454
+ return deferred.promise;
376
455
  }
377
456
 
378
457
  export function getAllAttribution(viewer) {
379
- const credits = viewer.scene.frameState.creditDisplay._currentFrameCredits.screenCredits.values.concat(
380
- viewer.scene.frameState.creditDisplay._currentFrameCredits.lightboxCredits.values
381
- )
382
- return credits.map(credit => credit.html)
458
+ const credits = viewer.scene.frameState.creditDisplay._currentFrameCredits.screenCredits.values.concat(
459
+ viewer.scene.frameState.creditDisplay._currentFrameCredits.lightboxCredits
460
+ .values
461
+ );
462
+ return credits.map(credit => credit.html);
383
463
  }
384
464
 
385
465
  /**
@@ -388,12 +468,12 @@ export function getAllAttribution(viewer) {
388
468
  * @param name String 对象名称
389
469
  * */
390
470
  export function getCesiumBaseObject(vm, name) {
391
- let baseObject = vm[name];
471
+ let baseObject = vm[name];
472
+ if (!baseObject) {
473
+ baseObject = window[name];
392
474
  if (!baseObject) {
393
- baseObject = window[name];
394
- if (!baseObject) {
395
- throw new Error("未找到可用的" + name + "对象!");
396
- }
475
+ throw new Error("未找到可用的" + name + "对象!");
397
476
  }
398
- return baseObject;
399
- }
477
+ }
478
+ return baseObject;
479
+ }