@hzab/map-combine 0.2.3 → 0.2.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # @hzab/map-combine0.2.5
2
+
3
+ feat: flyTo 函数
4
+
5
+ # @hzab/map-combine0.2.4
6
+
7
+ fix: Cesium flyToViewer use flyTo
8
+
1
9
  # @hzab/map-combine0.2.3
2
10
 
3
11
  fix: 流动线可配置图形+颜色
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/map-combine",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "地图组件",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -76,6 +76,12 @@ export abstract class MapCombine {
76
76
  */
77
77
  abstract flyToViewer(points: number[][], opt?: Object): void;
78
78
 
79
+ /**
80
+ * 移动点位到中心点
81
+ * @param points
82
+ */
83
+ abstract flyTo(point: number[], opt?: Object): void;
84
+
79
85
  getBounds = getBounds;
80
86
 
81
87
  destroy() {
@@ -261,11 +261,23 @@ export class CesiumMap extends MapCombine {
261
261
  );
262
262
 
263
263
  // 设置相机视角
264
- this.viewer.camera.setView({
264
+ this.viewer.camera.flyTo({
265
265
  destination: rectangle,
266
266
  ...opt,
267
267
  });
268
268
  }
269
+
270
+ /**
271
+ * 移动点位到中心点
272
+ * @param point
273
+ */
274
+ flyTo(point, opt = {}) {
275
+ // 设置相机视角
276
+ this.viewer.camera.flyTo({
277
+ destination: point,
278
+ ...opt,
279
+ });
280
+ }
269
281
  }
270
282
 
271
283
  function createColorCanvas(color) {
@@ -92,6 +92,15 @@ export class MineMap extends MapCombine {
92
92
  ]);
93
93
  }
94
94
 
95
+ /**
96
+ * 移动点位到中心点
97
+ * @param point
98
+ */
99
+ flyTo(point, opt = {}) {
100
+ // 设置相机视角
101
+ this.viewer.flyTo({ center: point, ...opt });
102
+ }
103
+
95
104
  createTile3D(option?: Partial<Tile3DOption>): Tile3D {
96
105
  const e = new Tile3D(this, option);
97
106
  drawTile3D(this, e);
@@ -122,7 +122,7 @@ export class OpenlayerMap extends MapCombine {
122
122
 
123
123
  const { center } = this;
124
124
  const proj = this.viewer.getView().getProjection().getCode();
125
- this.isFromLonLat = (proj === "EPSG:3857" || proj === "EPSG:4326");
125
+ this.isFromLonLat = proj === "EPSG:3857" || proj === "EPSG:4326";
126
126
  this.offset = this.getFromLonLat(center);
127
127
  this.vectors = new VectorSource();
128
128
  this.viewer.addLayer(
@@ -144,7 +144,6 @@ export class OpenlayerMap extends MapCombine {
144
144
  bindEvent(this);
145
145
  }
146
146
 
147
-
148
147
  getFromLonLat(lonLat, isFromLonLat = this.isFromLonLat) {
149
148
  return isFromLonLat ? fromLonLat(lonLat) : lonLat;
150
149
  }
@@ -215,6 +214,18 @@ export class OpenlayerMap extends MapCombine {
215
214
  });
216
215
  }
217
216
 
217
+ /**
218
+ * 移动点位到中心点
219
+ * @param point
220
+ */
221
+ flyTo(point, opt = {}) {
222
+ // 设置相机视角
223
+ this.viewer.getView().fit(point, {
224
+ duration: 1000,
225
+ ...opt,
226
+ });
227
+ }
228
+
218
229
  geographyTspace(p: number[]): number[] {
219
230
  const { offset } = this;
220
231
  return [Projection.lonToX(p[0]) - offset[0], Projection.latToY(p[1]) - offset[1], p[2] ?? 0];