From e296c52587d906e60674e688ae9b91e3757d4351 Mon Sep 17 00:00:00 2001 From: 2912401452 <2912401452@qq.com> Date: Fri, 8 Apr 2022 14:18:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20setZoomAndCenter/se?= =?UTF-8?q?tZoom=20=E7=BC=A9=E6=94=BE=E5=B1=82=E7=BA=A7=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/maps/src/amap/map.ts | 2 +- packages/maps/src/amap2/map.ts | 2 +- stories/Map/components/bugfix.tsx | 36 +++++++------------------------ 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/packages/maps/src/amap/map.ts b/packages/maps/src/amap/map.ts index 0b6eddc219..e4b99f4019 100644 --- a/packages/maps/src/amap/map.ts +++ b/packages/maps/src/amap/map.ts @@ -250,7 +250,7 @@ export default class AMapService } public setZoomAndCenter(zoom: number, center: [number, number]): void { - this.map.setZoomAndCenter(zoom, center); + this.map.setZoomAndCenter(zoom + 1, center); } public setMapStyle(style: string): void { diff --git a/packages/maps/src/amap2/map.ts b/packages/maps/src/amap2/map.ts index ea9ecaf52c..1fad990c5b 100644 --- a/packages/maps/src/amap2/map.ts +++ b/packages/maps/src/amap2/map.ts @@ -328,7 +328,7 @@ export default class AMapService ); } public setZoomAndCenter(zoom: number, center: [number, number]): void { - this.map.setZoomAndCenter(zoom, center); + this.map.setZoomAndCenter(zoom + 1, center); } public setMapStyle(style: string): void { this.map.setMapStyle(this.getMapStyle(style)); diff --git a/stories/Map/components/bugfix.tsx b/stories/Map/components/bugfix.tsx index a8b5050896..d432e527b3 100644 --- a/stories/Map/components/bugfix.tsx +++ b/stories/Map/components/bugfix.tsx @@ -19,32 +19,6 @@ export default class Amap2demo extends React.Component { } public async componentDidMount() { - function initScene() { - return new Promise((resolve, reject) => { - const scene = new Scene({ - id: 'map', - map: new GaodeMapV2({ - // center: [121.434765, 31.256735], - // zoom: 14.83, - pitch: 0, - style: 'light', - center: [120, 30], - zoom: 4, - }), - }); - scene.on('loaded', () => { - setTimeout(() => { - resolve(scene); - }, 200); - }); - }); - } - - // for (let i = 0; i < 20; i++) { - // console.log('init ' + (i + 1)); - // let scene = await initScene(); - // scene.destroy(); - // } const scene = new Scene({ id: 'map', @@ -63,7 +37,7 @@ export default class Amap2demo extends React.Component { ); scene.on('loaded', () => { - for (let i = 0; i < 20; i++) { + // const layer = new PointLayer().source([ // { lng: 120, lat: 30, name: '00' } // ], { @@ -78,6 +52,12 @@ export default class Amap2demo extends React.Component { // scene.addLayer(layer); + setTimeout(() => { + scene.setZoom(4) + // scene.setZoomAndCenter(4, [120, 30]) + console.log('rezoom') + }, 2000) + const lineLayer = new LineLayer() .source( [ @@ -103,7 +83,7 @@ export default class Amap2demo extends React.Component { .color('#f00'); scene.addLayer(lineLayer); - } + }); }