@hzab/map-combine 0.3.1-alpha.0 → 0.3.1-alpha.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/amap/AMap.ts +7 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/map-combine",
3
- "version": "0.3.1-alpha.0",
3
+ "version": "0.3.1-alpha.1",
4
4
  "description": "地图组件",
5
5
  "main": "src",
6
6
  "scripts": {
package/src/amap/AMap.ts CHANGED
@@ -45,6 +45,10 @@ export interface IFlyToViewerOpt {
45
45
  * 最大缩放级别
46
46
  */
47
47
  maxZoom?: number;
48
+ /**
49
+ * 动画时间
50
+ */
51
+ duration?: number;
48
52
  }
49
53
 
50
54
  export class AMap extends MapCombine {
@@ -247,18 +251,13 @@ export class AMap extends MapCombine {
247
251
  */
248
252
  flyToViewer(points: number[][], opt: IFlyToViewerOpt = { avoid: [0, 0, 0, 0], immediately: true }): void {
249
253
  this.loadPromise.then(() => {
250
- this.viewer.setBounds(
254
+ const [zoom, center] = this.viewer.getFitZoomAndCenterByBounds(
251
255
  this.getBounds(points, { canvas: this.viewer.canvas, ...opt }),
252
- opt?.immediately,
253
256
  opt?.avoid,
257
+ opt.maxZoom,
254
258
  );
255
259
 
256
- var currentZoom = this.viewer.getZoom();
257
-
258
- if (opt.maxZoom && currentZoom > opt.maxZoom) {
259
- // 如果当前缩放级别超过限制,则手动设置回最大允许级别
260
- this.viewer.setZoom(opt.maxZoom);
261
- }
260
+ this.viewer.setZoomAndCenter(zoom, center, opt?.immediately, opt?.duration);
262
261
  });
263
262
  }
264
263