const mapSupplier: number = 1;//1:高德 import { IMap, IMapOptions, IMarker, IPixel } from './map' import { GaoDeMap, GaoDeMarker, GaoDePixel } from './gaode-map' import { KeDaMap, KeDaMarker, KeDaPixel } from './keda-map'; export class MapFactory { public static MapInstance(container: string, options: IMapOptions | any): IMap { switch (mapSupplier) { case 1: return new GaoDeMap(container, options); case 2: return new KeDaMap(container, options); default: return null; } } public static PixelInstance(x: number, y: number): IPixel { switch (mapSupplier) { case 1: return new GaoDePixel(x, y); case 2: return new KeDaPixel(x, y); default: return null; } } public static MarkerInstance(options:any): IMarker { switch (mapSupplier) { case 1: return new GaoDeMarker(options); case 2: return new KeDaMarker(options); default: return null; } } }