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; map: IMapWrapper;
logoPosition?: PositionName; logoPosition?: PositionName;
logoVisible?: boolean; logoVisible?: boolean;
fitBoundsOptions?: mapboxgl.FitBoundsOptions;
} }
// interface IValidateResult { // interface IValidateResult {

View File

@ -58,11 +58,18 @@ class Scene
private popupService: IPopupService; private popupService: IPopupService;
private fontService: IFontService; private fontService: IFontService;
private interactionService: IInteractionService; private interactionService: IInteractionService;
private fitBoundsOptions: mapboxgl.FitBoundsOptions;
private container: Container; private container: Container;
public constructor(config: ISceneConfig) { 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(); const sceneContainer = createSceneContainer();
this.container = sceneContainer; this.container = sceneContainer;
@ -274,7 +281,7 @@ class Scene
bound: Bounds, bound: Bounds,
fitBoundsOptions?: mapboxgl.FitBoundsOptions, fitBoundsOptions?: mapboxgl.FitBoundsOptions,
): void { ): void {
this.mapService.fitBounds(bound, fitBoundsOptions); this.mapService.fitBounds(bound, this.fitBoundsOptions || fitBoundsOptions);
} }
public setZoomAndCenter(zoom: number, center: Point): void { public setZoomAndCenter(zoom: number, center: Point): void {