@tuoyuan/map-adapter-lib
Version:
地图适配器库
44 lines (43 loc) • 1.84 kB
TypeScript
import { BaseMap, EventBusCallback, MapEventType, AbstractMap, IPolygonStyle, IPolylineStyle, IMarkerStyle } from './class';
import { AbstractMapMethods, GetAbstractMapMethodParameter, GetAbstractMapMethodReturnType } from './types';
type DeepReadonly<T extends Record<string, any>> = {
readonly [P in keyof T]: keyof T[P] extends Record<string, any> ? T[P] : DeepReadonly<T[P]>;
};
export interface ProxyMap extends BaseMap, AbstractMap {
}
export interface IProxyMapOptions {
dev?: boolean;
style?: {
marker?: IMarkerStyle;
polyline?: IPolylineStyle;
polygon?: IPolygonStyle;
};
label?: {
/** 最小展示层级,地图小于此层级时默认隐藏label */
minShowZoom?: number;
};
/** 热力图 */
heatmap?: {
/** 热力图半径 */
radius?: number;
/** 渐变色 */
gradient?: Record<number | string, string>;
};
}
export declare class ProxyMap {
private static readonly mapClasses;
readonly mapType: string;
readonly options: DeepReadonly<IProxyMapOptions>;
readonly mapInstance: BaseMap;
constructor(type: string, options?: IProxyMapOptions);
protected throwNoMethod(name: string): void;
has<T extends string>(name: T): boolean;
exec<T extends AbstractMapMethods>(name: T, ...args: GetAbstractMapMethodParameter<T>): GetAbstractMapMethodReturnType<T>;
on(name: MapEventType, callback: EventBusCallback): void;
once(name: MapEventType, callback: EventBusCallback): void;
off(name: MapEventType, callback: EventBusCallback): void;
static useMapClass(type: string, map: typeof BaseMap): void;
}
export declare function useMapClass(type: string, mapClass: typeof BaseMap): void;
export declare function createMap(type: string, config?: IProxyMapOptions): ProxyMap;
export {};