feat: scene添加fitBoundsOptions属性

This commit is contained in:
聆一 2020-03-27 11:14:10 +08:00
parent d66b541c7c
commit 7c427cc749
2 changed files with 11 additions and 3 deletions

View File

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

View File

@ -58,11 +58,18 @@ class Scene
private popupService: IPopupService;
private fontService: IFontService;
private interactionService: IInteractionService;
private fitBoundsOptions: mapboxgl.FitBoundsOptions;
private container: Container;
public constructor(config: ISceneConfig) {
const { id, map, logoPosition, logoVisible = true } = config;
const {
id,
map,
logoPosition,
logoVisible = true,
fitBoundsOptions = { animate: true },
} = config;
this.fitBoundsOptions = fitBoundsOptions;
// 创建场景容器
const sceneContainer = createSceneContainer();
this.container = sceneContainer;
@ -274,7 +281,7 @@ class Scene
bound: Bounds,
fitBoundsOptions?: mapboxgl.FitBoundsOptions,
): void {
this.mapService.fitBounds(bound, fitBoundsOptions);
this.mapService.fitBounds(bound, this.fitBoundsOptions || fitBoundsOptions);
}
public setZoomAndCenter(zoom: number, center: Point): void {