@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,6 +1,12 @@
1
- import { baiduMapLayer, DataSet } from "mapv";
1
+ import {
2
+ baiduMapLayer,
3
+ DataSet,
4
+ utilDataRangeIntensity as Intensity
5
+ } from "mapv";
2
6
 
3
- var BaseLayer = baiduMapLayer ? baiduMapLayer.__proto__ : Function;
7
+ import Supercluster from './SuperCluster'
8
+
9
+ let BaseLayer = baiduMapLayer ? baiduMapLayer.__proto__ : Function;
4
10
 
5
11
  /**
6
12
  * @private
@@ -14,34 +20,34 @@ var BaseLayer = baiduMapLayer ? baiduMapLayer.__proto__ : Function;
14
20
  * @extends BaseLayer
15
21
  *
16
22
  */
17
- export class MapvBaseLayer extends BaseLayer {
23
+ export class MapvBaseLayer extends BaseLayer {
18
24
  constructor(map, dataSet, options, cesiumLayer) {
19
- super(map, dataSet, options);
25
+ super(map, dataSet, options);
20
26
 
21
- if (!BaseLayer) return;
27
+ if (!BaseLayer) return;
22
28
 
23
- this.map = map; //此处的map是外面传入的cesium的map对象
24
- this.scene = map.scene;
25
- this.dataSet = dataSet;
29
+ this.map = map; //此处的map是外面传入的cesium的map对象
30
+ this.scene = map.scene;
31
+ this.dataSet = dataSet;
26
32
 
27
- var self = this;
28
- var data = null;
29
- options = options || {};
33
+ let self = this;
34
+ let data = null;
35
+ options = options || {};
30
36
 
31
- self.init(options);
32
- self.argCheck(options);
37
+ self.init(options);
38
+ self.argCheck(options);
33
39
 
34
- this.initDevicePixelRatio();
40
+ this.initDevicePixelRatio();
35
41
 
36
- this.canvasLayer = cesiumLayer;
42
+ this.canvasLayer = cesiumLayer;
37
43
 
38
- this.stopAniamation = false;
39
- this.animation = options.animation;
44
+ this.stopAniamation = false;
45
+ this.animation = options.animation;
40
46
 
41
- this.clickEvent = this.clickEvent.bind(this);
42
- this.mousemoveEvent = this.mousemoveEvent.bind(this);
47
+ this.clickEvent = this.clickEvent.bind(this);
48
+ this.mousemoveEvent = this.mousemoveEvent.bind(this);
43
49
 
44
- this.bindEvent();
50
+ this.bindEvent();
45
51
  }
46
52
 
47
53
  /**
@@ -50,17 +56,17 @@ var BaseLayer = baiduMapLayer ? baiduMapLayer.__proto__ : Function;
50
56
  * 公式表示就是:window.devicePixelRatio = 物理像素 / dips,该函数主要应用与移动设备
51
57
  */
52
58
  initDevicePixelRatio() {
53
- this.devicePixelRatio = window.devicePixelRatio || 1;
59
+ this.devicePixelRatio = window.devicePixelRatio || 1;
54
60
  }
55
61
 
56
62
  /**
57
63
  * @function cesium.zondy.MapvBaseLayer.prototype.clickEvent
58
64
  * @description 百度mapv原本的事件只有clickEvent和mousemoveEvent
59
65
  * @param e 点击事件对象 {latlng, layerPoint, containerPoint, originalEvent}
60
- * @example
66
+ * @example
61
67
  * //mapv.map.BaseLayer.clickEvent
62
68
  * clickEvent(pixel, e) {
63
- * var dataItem = this.isPointInPath(this.getContext(), pixel);
69
+ * let dataItem = this.isPointInPath(this.getContext(), pixel);
64
70
  * if (dataItem) {
65
71
  * this.options.methods.click(dataItem, e);
66
72
  * } else {
@@ -69,18 +75,18 @@ var BaseLayer = baiduMapLayer ? baiduMapLayer.__proto__ : Function;
69
75
  * }
70
76
  */
71
77
  clickEvent(e) {
72
- var pixel = e.point;
73
- super.clickEvent(pixel, e);
78
+ let pixel = e.point;
79
+ super.clickEvent(pixel, e);
74
80
  }
75
81
 
76
82
  /**
77
83
  * @function cesium.zondy.MapvBaseLayer.prototype.mousemoveEvent
78
84
  * @description 百度mapv原本的事件只有clickEvent和mousemoveEvent
79
85
  * @param e 点击事件对象 {latlng, layerPoint, containerPoint, originalEvent}
80
- * @example
86
+ * @example
81
87
  * //mapv.map.BaseLayer.mousemoveEvent
82
88
  * mousemoveEvent(pixel, e) {
83
- * var dataItem = this.isPointInPath(this.getContext(), pixel);
89
+ * let dataItem = this.isPointInPath(this.getContext(), pixel);
84
90
  * if (dataItem) {
85
91
  * this.options.methods.mousemove(dataItem, e);
86
92
  * } else {
@@ -89,220 +95,393 @@ var BaseLayer = baiduMapLayer ? baiduMapLayer.__proto__ : Function;
89
95
  * }
90
96
  */
91
97
  mousemoveEvent(e) {
92
- var pixel = e.point;
93
- super.mousemoveEvent(pixel, e);
98
+ let pixel = e.point;
99
+ super.mousemoveEvent(pixel, e);
94
100
  }
95
101
 
96
- addAnimatorEvent() {
97
-
98
- }
102
+ addAnimatorEvent() {}
99
103
 
100
104
  animatorMovestartEvent() {
101
- var animationOptions = this.options.animation;
102
- if (this.isEnabledTime() && this.animator) {
103
- this.steps.step = animationOptions.stepsRange.start;
104
- //this.animator.stop();
105
- }
105
+ let animationOptions = this.options.animation;
106
+ if (this.isEnabledTime() && this.animator) {
107
+ this.steps.step = animationOptions.stepsRange.start;
108
+ //this.animator.stop();
109
+ }
106
110
  }
107
111
 
108
112
  animatorMoveendEvent() {
109
- if (this.isEnabledTime() && this.animator) {
110
- //this.animator.start();
111
- }
113
+ if (this.isEnabledTime() && this.animator) {
114
+ //this.animator.start();
115
+ }
112
116
  }
113
117
 
114
118
  bindEvent() {
115
- var map = this.map;
116
- if (this.options.methods) {
117
- if (this.options.methods.click) {
118
- //map.on('click', this.clickEvent);
119
- }
120
- if (this.options.methods.mousemove) {
121
- //map.on('mousemove', this.mousemoveEvent);
122
- }
119
+ let map = this.map;
120
+ if (this.options.methods) {
121
+ if (this.options.methods.click) {
122
+ //map.on('click', this.clickEvent);
123
+ }
124
+ if (this.options.methods.mousemove) {
125
+ //map.on('mousemove', this.mousemoveEvent);
123
126
  }
127
+ }
124
128
  }
125
129
 
126
130
  unbindEvent() {
127
- var map = this.map;
131
+ let map = this.map;
128
132
 
129
- if (this.options.methods) {
130
- if (this.options.methods.click) {
131
- map.off('click', this.clickEvent);
132
- }
133
- if (this.options.methods.mousemove) {
134
- map.off('mousemove', this.mousemoveEvent);
135
- }
133
+ if (this.options.methods) {
134
+ if (this.options.methods.click) {
135
+ map.off("click", this.clickEvent);
136
+ }
137
+ if (this.options.methods.mousemove) {
138
+ map.off("mousemove", this.mousemoveEvent);
136
139
  }
140
+ }
137
141
  }
138
142
 
139
143
  getContext() {
140
- return this.canvasLayer.canvas.getContext(this.context);
144
+ return this.canvasLayer.canvas.getContext(this.context);
141
145
  }
142
146
 
147
+ getZoom() {
148
+ let zoom = 0;
149
+ if (!this.map) return zoom;
150
+ let tiles = this.map.scene.globe._surface._tilesToRender;
151
+ if (tiles && tiles.length > 0) {
152
+ zoom = this.map.scene.globe._surface._tilesToRender[0].level;
153
+ }
154
+ return zoom;
155
+ }
143
156
 
144
157
  init(options) {
158
+ let self = this;
145
159
 
146
- var self = this;
160
+ self.options = options;
147
161
 
148
- self.options = options;
162
+ this.initDataRange(options);
149
163
 
150
- this.initDataRange(options);
164
+ this.context = self.options.context || "2d";
151
165
 
152
- this.context = self.options.context || '2d';
166
+ if (self.options.zIndex) {
167
+ this.canvasLayer && this.canvasLayer.setZIndex(self.options.zIndex);
168
+ }
153
169
 
154
- if (self.options.zIndex) {
155
- this.canvasLayer && this.canvasLayer.setZIndex(self.options.zIndex);
156
- }
157
-
158
- this.initAnimator();
170
+ this.initAnimator();
159
171
  }
160
172
 
161
- _canvasUpdate(time) {
162
- var map = this.map;
163
- var scene = this.scene;
164
- if (!this.canvasLayer || this.stopAniamation) {
165
- return;
166
- }
167
- var self = this;
168
-
169
- var animationOptions = self.options.animation;
170
-
171
- var context = self.getContext();
172
-
173
- if (self.isEnabledTime()) {
174
- if (time === undefined) {
175
- this.clear(context);
176
- return;
177
- }
178
- if (this.context === '2d') {
179
- context.save();
180
- context.globalCompositeOperation = 'destination-out';
181
- context.fillStyle = 'rgba(0, 0, 0, .1)';
182
- context.fillRect(0, 0, context.canvas.width, context.canvas.height);
183
- context.restore();
173
+ // 经纬度左边转换为墨卡托坐标
174
+ transferToMercator(dataSet) {
175
+ if (!dataSet) {
176
+ dataSet = this.dataSet;
177
+ }
178
+ let lnglat2Mkt = poi => {
179
+ let mercator = {};
180
+ let earthRad = 6378137.0;
181
+ mercator.x = ((poi.lng * Math.PI) / 180) * earthRad;
182
+ let a = (poi.lat * Math.PI) / 180;
183
+ mercator.y =
184
+ (earthRad / 2) * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a)));
185
+ return mercator;
186
+ };
187
+
188
+ let map = this.map;
189
+ if (this.options.coordType !== "bd09mc") {
190
+ let data = dataSet.get();
191
+ data = dataSet.transferCoordinate(
192
+ data,
193
+ function(coordinates) {
194
+ if (
195
+ coordinates[0] < -180 ||
196
+ coordinates[0] > 180 ||
197
+ coordinates[1] < -90 ||
198
+ coordinates[1] > 90
199
+ ) {
200
+ return coordinates;
201
+ } else {
202
+ let pixel = lnglat2Mkt({
203
+ lng: coordinates[0],
204
+ lat: coordinates[1]
205
+ });
206
+ return [pixel.x, pixel.y];
184
207
  }
185
- } else {
186
- this.clear(context);
208
+ },
209
+ "coordinates",
210
+ "coordinates_mercator"
211
+ );
212
+ dataSet._set(data);
213
+ }
214
+ }
215
+
216
+ dataOptions() {
217
+ const self = this;
218
+ return {
219
+ transferCoordinate: function(coordinate) {
220
+ let pointSphere = Cesium.Cartesian3.fromDegrees(
221
+ coordinate[0],
222
+ coordinate[1]
223
+ );
224
+ let position = self.map.camera.position;
225
+ let cameraHeight = self.map.scene.globe.ellipsoid.cartesianToCartographic(
226
+ position
227
+ ).height;
228
+ cameraHeight += self.map.scene.globe.ellipsoid.maximumRadius * 1.2;
229
+ let distance = Cesium.Cartesian3.distance(position, pointSphere);
230
+ if (distance > cameraHeight) {
231
+ return undefined;
232
+ // return [-50, -50];a
233
+ }
234
+
235
+ let car3 = Cesium.Cartesian3.fromDegrees(coordinate[0], coordinate[1]);
236
+ let point = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
237
+ self.map.scene,
238
+ car3
239
+ );
240
+ if (!point) return [0, 0];
241
+
242
+ if (self.options.draw === "cluster") {
243
+ return [
244
+ point.x * self.devicePixelRatio,
245
+ point.y * self.devicePixelRatio
246
+ ];
247
+ }
248
+ return [point.x, point.y];
187
249
  }
250
+ };
251
+ }
188
252
 
189
- if (this.context === '2d') {
190
- for (var key in self.options) {
191
- context[key] = self.options[key];
192
- }
253
+ changeCluster() {
254
+ const self = this;
255
+ let zoom = this.getZoom();
256
+ let dataGetOptions = this.dataOptions();
257
+ let rect = this.map.scene.camera.computeViewRectangle();
258
+ const south = Cesium.Math.toDegrees(rect.south);
259
+ const north = Cesium.Math.toDegrees(rect.north);
260
+ const east = Cesium.Math.toDegrees(rect.east);
261
+ const west = Cesium.Math.toDegrees(rect.west);
262
+
263
+ let clusterData = this.supercluster.getClusters(
264
+ [west, south, east, north],
265
+ zoom
266
+ );
267
+ this.pointCountMax = this.supercluster.trees[zoom].max;
268
+ this.pointCountMin = this.supercluster.trees[zoom].min;
269
+ let intensity = {};
270
+ let color = null;
271
+ let size = null;
272
+ if (this.pointCountMax === this.pointCountMin) {
273
+ color = this.options.fillStyle;
274
+ size = this.options.minSize || 8;
275
+ } else {
276
+ intensity = new Intensity({
277
+ min: this.pointCountMin,
278
+ max: this.pointCountMax,
279
+ minSize: this.options.minSize || 8,
280
+ maxSize: this.options.maxSize || 30,
281
+ gradient: this.options.gradient
282
+ });
283
+ }
284
+ for (let i = 0; i < clusterData.length; i++) {
285
+ let item = clusterData[i];
286
+ if (item.properties && item.properties.cluster_id) {
287
+ clusterData[i].size =
288
+ size || intensity.getSize(item.properties.point_count);
289
+ clusterData[i].fillStyle =
290
+ color || intensity.getColor(item.properties.point_count);
193
291
  } else {
194
- context.clear(context.COLOR_BUFFER_BIT);
292
+ clusterData[i].size = self.options.size;
195
293
  }
294
+ }
295
+ this.clusterDataSet.set(clusterData);
296
+ this.transferToMercator(self.clusterDataSet);
297
+ let data = self.clusterDataSet.get(dataGetOptions);
298
+ return data;
299
+ }
196
300
 
197
- var dataGetOptions = {
198
- transferCoordinate: function (coordinate) {
199
- var pointSphere = Cesium.Cartesian3.fromDegrees(coordinate[0], coordinate[1]);
200
- var position = self.map.camera.position;
201
- var cameraHeight = self.map.scene.globe.ellipsoid.cartesianToCartographic(position).height;
202
- cameraHeight += self.map.scene.globe.ellipsoid.maximumRadius * 1.2;
203
- var distance = Cesium.Cartesian3.distance(position, pointSphere);
204
- if(distance>cameraHeight){
205
- return undefined;
206
- // return [-50, -50];
207
- }
208
-
209
- var position = Cesium.Cartesian3.fromDegrees(coordinate[0], coordinate[1]);
210
- var point = Cesium.SceneTransforms.wgs84ToWindowCoordinates(self.map.scene, position);
211
- if (!point) return [0, 0];
212
- return [point.x, point.y];
213
- }
214
- };
301
+ refreshCluster(options) {
302
+ options = options || this.options;
303
+ this.supercluster = new Supercluster({
304
+ maxZoom: options.maxZoom || 19,
305
+ radius: options.clusterRadius || 100,
306
+ minPoints: options.minPoints || 2,
307
+ extent: options.extent || 512
308
+ });
309
+
310
+ this.supercluster.load(this.dataSet.get());
311
+ // 拿到每个级别下的最大值最小值
312
+ this.supercluster.trees.forEach(item => {
313
+ let max = 0;
314
+ let min = Infinity;
315
+ item.points.forEach(point => {
316
+ max = Math.max(point.numPoints || 0, max);
317
+ min = Math.min(point.numPoints || Infinity, min);
318
+ });
319
+ item.max = max;
320
+ item.min = min;
321
+ });
322
+ this.clusterDataSet = new DataSet();
323
+ }
215
324
 
216
- if (time !== undefined) {
217
- dataGetOptions.filter = function (item) {
218
- var trails = animationOptions.trails || 10;
219
- if (time && item.time > (time - trails) && item.time < time) {
220
- return true;
221
- } else {
222
- return false;
223
- }
224
- }
225
- }
325
+ _canvasUpdate(time) {
326
+ let map = this.map;
327
+ let scene = this.scene;
328
+ if (!this.canvasLayer || this.stopAniamation) {
329
+ return;
330
+ }
331
+ let self = this;
226
332
 
227
- var data = self.dataSet.get(dataGetOptions);
333
+ let animationOptions = self.options.animation;
228
334
 
229
- this.processData(data);
335
+ let context = self.getContext();
230
336
 
231
- if (self.options.unit == 'm' && self.options.size) {
232
- //self.options._size = self.options.size / zoomUnit;
233
- self.options._size = self.options.size;
234
- } else {
235
- self.options._size = self.options.size;
337
+ if (self.isEnabledTime()) {
338
+ if (time === undefined) {
339
+ this.clear(context);
340
+ return;
236
341
  }
342
+ if (this.context === "2d") {
343
+ context.save();
344
+ context.globalCompositeOperation = "destination-out";
345
+ context.fillStyle = "rgba(0, 0, 0, .1)";
346
+ context.fillRect(0, 0, context.canvas.width, context.canvas.height);
347
+ context.restore();
348
+ }
349
+ } else {
350
+ this.clear(context);
351
+ }
237
352
 
238
- var pixel = Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, Cesium.Cartesian3.fromDegrees(0, 0));
239
- if (!pixel) pixel = [0, 0];
240
- this.drawContext(context, new DataSet(data), self.options, pixel);
241
-
242
- self.options.updateCallback && self.options.updateCallback(time);
353
+ if (this.context === "2d") {
354
+ for (let key in self.options) {
355
+ context[key] = self.options[key];
356
+ }
357
+ } else {
358
+ context.clear(context.COLOR_BUFFER_BIT);
359
+ }
360
+
361
+ if (
362
+ (self.options.minZoom && self.getZoom() < self.options.minZoom) ||
363
+ (self.options.maxZoom && self.getZoom() > self.options.maxZoom)
364
+ ) {
365
+ return;
366
+ }
367
+
368
+ let dataGetOptions = this.dataOptions();
369
+
370
+ if (time !== undefined) {
371
+ dataGetOptions.filter = function(item) {
372
+ let trails = animationOptions.trails || 10;
373
+ if (time && item.time > time - trails && item.time < time) {
374
+ return true;
375
+ } else {
376
+ return false;
377
+ }
378
+ };
379
+ }
380
+
381
+ let data;
382
+ let zoom = this.getZoom();
383
+ if (
384
+ this.options.draw === "cluster" &&
385
+ (!this.options.maxClusterZoom || this.options.maxClusterZoom >= zoom)
386
+ ) {
387
+ data = this.changeCluster();
388
+ } else {
389
+ data = self.dataSet.get(dataGetOptions);
390
+ }
391
+
392
+ this.processData(data);
393
+
394
+ if (self.options.unit == "m" && self.options.size) {
395
+ //self.options._size = self.options.size / zoomUnit;
396
+ self.options._size = self.options.size;
397
+ } else {
398
+ self.options._size = self.options.size;
399
+ }
400
+
401
+ let pixel = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
402
+ scene,
403
+ Cesium.Cartesian3.fromDegrees(0, 0)
404
+ );
405
+ if (!pixel) pixel = [0, 0];
406
+ this.drawContext(context, new DataSet(data), self.options, pixel);
407
+
408
+ self.options.updateCallback && self.options.updateCallback(time);
243
409
  }
244
410
 
245
411
  updateData(data, options) {
246
- var _data = data;
247
- if (_data && _data.get) {
248
- _data = _data.get();
249
- }
250
- if (_data != undefined) {
251
- this.dataSet.set(_data);
412
+ let _data = data;
413
+ if (_data && _data.get) {
414
+ _data = _data.get();
415
+ }
416
+ if (_data != undefined) {
417
+ let zoom = this.getZoom();
418
+ if (
419
+ this.options.draw === "cluster" &&
420
+ (!this.options.maxClusterZoom || this.options.maxClusterZoom >= zoom)
421
+ ) {
422
+ this.dataSet = data;
423
+ this.refreshCluster(this.options);
424
+ _data = this.changeCluster();
425
+ this.dataSet.set(_data);
426
+ } else {
427
+ this.dataSet.set(_data);
252
428
  }
429
+ }
253
430
 
254
- super.update({
255
- options: options
256
- });
257
-
431
+ super.update({
432
+ options: options
433
+ });
258
434
  }
259
435
 
260
436
  addData(data, options) {
261
- var _data = data;
262
- if (data && data.get) {
263
- _data = data.get();
264
- }
265
- this.dataSet.add(_data);
266
- this.update({
267
- options: options
268
- });
437
+ let _data = data;
438
+ if (data && data.get) {
439
+ _data = data.get();
440
+ }
441
+ this.dataSet.add(_data);
442
+ this.update({
443
+ options: options
444
+ });
269
445
  }
270
446
 
271
447
  getData() {
272
- return this.dataSet;
448
+ return this.dataSet;
273
449
  }
274
450
 
275
451
  removeData(filter) {
276
- if (!this.dataSet) {
277
- return;
452
+ if (!this.dataSet) {
453
+ return;
454
+ }
455
+ let newData = this.dataSet.get({
456
+ filter: function(data) {
457
+ return filter != null && typeof filter === "function"
458
+ ? !filter(data)
459
+ : true;
278
460
  }
279
- var newData = this.dataSet.get({
280
- filter: function (data) {
281
- return (filter != null && typeof filter === "function") ? !filter(data) : true;
282
- }
283
- });
284
- this.dataSet.set(newData);
285
- this.stopAniamation = true;
286
- /* this.update({
461
+ });
462
+ this.dataSet.set(newData);
463
+ this.stopAniamation = true;
464
+ /* this.update({
287
465
  options: null
288
466
  }); */
289
467
  }
290
468
 
291
469
  clearData() {
292
- this.dataSet && this.dataSet.clear();
293
- this.stopAniamation = true;
294
- /* this.update({
470
+ this.dataSet && this.dataSet.clear();
471
+ this.stopAniamation = true;
472
+ /* this.update({
295
473
  options: null
296
474
  }); */
297
475
  }
298
476
 
299
477
  draw() {
300
- this.canvasLayer.draw();
478
+ this.canvasLayer.draw();
301
479
  }
302
480
 
303
481
  //该函数从mapv/canvas/clear中提取
304
482
  clear(context) {
305
- context && context.clearRect && context.clearRect(0, 0, context.canvas.width, context.canvas.height);
483
+ context &&
484
+ context.clearRect &&
485
+ context.clearRect(0, 0, context.canvas.width, context.canvas.height);
306
486
  }
307
-
308
- }
487
+ }