feat: 添加animate配置项

This commit is contained in:
聆一 2020-03-27 11:45:55 +08:00
parent 7d46b5242d
commit 6dae6ca1a8
3 changed files with 9 additions and 8 deletions

View File

@ -8,6 +8,7 @@ export interface ISceneConfig extends IRenderConfig {
map: IMapWrapper;
logoPosition?: PositionName;
logoVisible?: boolean;
animate?: boolean;
fitBoundsOptions?: mapboxgl.FitBoundsOptions;
}

View File

@ -113,12 +113,6 @@ export default function BaseLayer(type: string, props: ILayerProps) {
}
}, [options?.blend]);
// useEffect(() => {
// if (layer && layer.inited && options && options.autoFit === true) {
// layer.fitBounds();
// }
// }, [options?.autoFit]);
return layer !== null && layer !== undefined ? (
<LayerContext.Provider value={layer}>
<Source layer={layer} source={source} />

View File

@ -58,6 +58,7 @@ class Scene
private popupService: IPopupService;
private fontService: IFontService;
private interactionService: IInteractionService;
private animate: boolean;
private fitBoundsOptions: mapboxgl.FitBoundsOptions;
private container: Container;
@ -67,7 +68,8 @@ class Scene
map,
logoPosition,
logoVisible = true,
fitBoundsOptions = { animate: true },
animate = true,
fitBoundsOptions = {},
} = config;
this.fitBoundsOptions = fitBoundsOptions;
// 创建场景容器
@ -281,7 +283,11 @@ class Scene
bound: Bounds,
fitBoundsOptions?: mapboxgl.FitBoundsOptions,
): void {
this.mapService.fitBounds(bound, this.fitBoundsOptions || fitBoundsOptions);
this.mapService.fitBounds(
bound,
// 选项优先级用户传入覆盖animate直接配置覆盖Scene配置项传入
fitBoundsOptions || { ...this.fitBoundsOptions, animate: this.animate },
);
}
public setZoomAndCenter(zoom: number, center: Point): void {