mirror of https://gitee.com/antv-l7/antv-l7
fix: map style ts Type
This commit is contained in:
parent
d17b0326fe
commit
b71ddb5a72
|
@ -11,6 +11,7 @@ export interface IPoint {
|
||||||
y: number;
|
y: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type MapStyle = string | { [key: string]: any };
|
||||||
export interface IMapWrapper {
|
export interface IMapWrapper {
|
||||||
setContainer(container: Container, id: string): void;
|
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,
|
IPoint,
|
||||||
IViewport,
|
IViewport,
|
||||||
MapServiceEvent,
|
MapServiceEvent,
|
||||||
|
MapStyle,
|
||||||
TYPES,
|
TYPES,
|
||||||
} from '@antv/l7-core';
|
} from '@antv/l7-core';
|
||||||
import { DOM } from '@antv/l7-utils';
|
import { DOM } from '@antv/l7-utils';
|
||||||
|
@ -249,7 +250,7 @@ export default class AMapService
|
||||||
);
|
);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.map = new AMap.Map(this.$mapContainer, {
|
this.map = new AMap.Map(this.$mapContainer, {
|
||||||
mapStyle: this.getMapStyle(style),
|
mapStyle: this.getMapStyle(style as string),
|
||||||
zooms: [minZoom, maxZoom],
|
zooms: [minZoom, maxZoom],
|
||||||
viewMode: '3D',
|
viewMode: '3D',
|
||||||
...rest,
|
...rest,
|
||||||
|
@ -361,7 +362,7 @@ export default class AMapService
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private getMapStyle(name: string) {
|
private getMapStyle(name: string): string {
|
||||||
return MapTheme[name] ? MapTheme[name] : name;
|
return MapTheme[name] ? MapTheme[name] : name;
|
||||||
}
|
}
|
||||||
private creatAmapContainer(id: string | HTMLDivElement) {
|
private creatAmapContainer(id: string | HTMLDivElement) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
IPoint,
|
IPoint,
|
||||||
IViewport,
|
IViewport,
|
||||||
MapServiceEvent,
|
MapServiceEvent,
|
||||||
|
MapStyle,
|
||||||
TYPES,
|
TYPES,
|
||||||
} from '@antv/l7-core';
|
} from '@antv/l7-core';
|
||||||
import { DOM } from '@antv/l7-utils';
|
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;
|
return MapTheme[name] ? MapTheme[name] : name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue