Skip to content

Commit

Permalink
fix: 天地图 setCenter 方法缺失 (#2513)
Browse files Browse the repository at this point in the history
* fix: 天地图 setCenter 方法缺失

* chore: gui remove error

* chore: animate 调试

* chore: add changeset
  • Loading branch information
lvisei authored May 31, 2024
1 parent f5f24d3 commit cca16a3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-crabs-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/l7-maps': patch
---

fix: 天地图 setCenter 方法缺失
6 changes: 5 additions & 1 deletion examples/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ export const Main = () => {

return () => {
scene?.destroy();
extendGUI.forEach((d) => d.destroy());
while (mapContainer.current?.firstChild) {
mapContainer.current.removeChild(mapContainer.current.lastChild!);
}
try {
extendGUI.forEach((d) => d.destroy());
} catch (error) {
console.warn('error: ', error);
}
};
}, [viewDemo, guiOptions]);

Expand Down
3 changes: 2 additions & 1 deletion examples/utils/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type CaseSceneOptions = TestCaseOptions & {
};

export const CaseScene = (options: CaseSceneOptions) => {
const { map: basemap, mapConfig } = options;
const { map: basemap, animate, mapConfig } = options;

const isMapbox = ['MapLibre', 'Mapbox'].includes(basemap);

Expand All @@ -34,6 +34,7 @@ export const CaseScene = (options: CaseSceneOptions) => {

return new Promise<Scene>((resolve) => {
scene.on('loaded', () => {
animate && scene.startAnimate();
resolve(scene);
});
});
Expand Down
10 changes: 9 additions & 1 deletion packages/maps/src/tdtmap/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,15 @@ export default class TdtMapService extends BaseMapService<any> {
}

public setCenter(lnglat: [number, number]): void {
this.map.setCenter(lnglat);
// @ts-ignore
const lngLat = window.T.LngLat(lnglat[0], lnglat[1]);
this.map.centerAndZoom(lngLat, this.map.getZoom());
}

public setZoomAndCenter(zoom: number, center: [number, number]) {
// @ts-ignore
const lngLat = window.T.LngLat(center[0], center[1]);
this.map.centerAndZoom(lngLat, zoom);
}

public getPitch(): number {
Expand Down

0 comments on commit cca16a3

Please sign in to comment.