mirror of https://gitee.com/antv-l7/antv-l7
fix: map style ts Type
This commit is contained in:
parent
52f33658d1
commit
1b83e7ccd9
|
@ -11,6 +11,7 @@ export interface IPoint {
|
|||
y: number;
|
||||
}
|
||||
|
||||
export type MapStyle = string | { [key: string]: any };
|
||||
export interface IMapWrapper {
|
||||
setContainer(container: Container, id: string): void;
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ export interface IMapConfig<RawMap = {}> {
|
|||
/**
|
||||
* 底图样式
|
||||
*/
|
||||
style?: string | { [key: string]: any };
|
||||
style?: MapStyle;
|
||||
/**
|
||||
* 最小缩放等级
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
IPoint,
|
||||
IViewport,
|
||||
MapServiceEvent,
|
||||
MapStyle,
|
||||
TYPES,
|
||||
} from '@antv/l7-core';
|
||||
import { DOM } from '@antv/l7-utils';
|
||||
|
@ -249,7 +250,7 @@ export default class AMapService
|
|||
);
|
||||
// @ts-ignore
|
||||
this.map = new AMap.Map(this.$mapContainer, {
|
||||
mapStyle: this.getMapStyle(style),
|
||||
mapStyle: this.getMapStyle(style as string),
|
||||
zooms: [minZoom, maxZoom],
|
||||
viewMode: '3D',
|
||||
...rest,
|
||||
|
@ -361,7 +362,7 @@ export default class AMapService
|
|||
}
|
||||
};
|
||||
|
||||
private getMapStyle(name: string) {
|
||||
private getMapStyle(name: string): string {
|
||||
return MapTheme[name] ? MapTheme[name] : name;
|
||||
}
|
||||
private creatAmapContainer(id: string | HTMLDivElement) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
IPoint,
|
||||
IViewport,
|
||||
MapServiceEvent,
|
||||
MapStyle,
|
||||
TYPES,
|
||||
} from '@antv/l7-core';
|
||||
import { DOM } from '@antv/l7-utils';
|
||||
|
@ -318,7 +319,10 @@ export default class MapboxService
|
|||
}
|
||||
}
|
||||
|
||||
private getMapStyle(name: string) {
|
||||
private getMapStyle(name: MapStyle) {
|
||||
if (typeof name !== 'string') {
|
||||
return name;
|
||||
}
|
||||
return MapTheme[name] ? MapTheme[name] : name;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue