|
|
|
const mapSupplier: number = 1; //1:高德
|
|
|
|
|
|
|
|
import { IMap, IMapOptions, IMarker, IPixel, IMarkOptions, ILngLat, ILayer, ICircle, IMarkerCluster, IRenderClusterMarker, InfoWindow } from './map'
|
|
|
|
import { GaodeCircle, GaodeInfoWindow, GaodeLayer, GaoDeLngLat, GaoDeMap, GaoDeMarker, GaoDeMarkerCluster, GaoDePixel, GaoDeRenderClusterMarker } from './gaode-map'
|
|
|
|
import { KeDaLngLat, KeDaMap, KeDaMarker, KeDaPixel } from './keda-map';
|
|
|
|
import MapTools from './map-tools';
|
|
|
|
|
|
|
|
export class MapFactory {
|
|
|
|
public static MapInstance(container: string, options: IMapOptions | any): IMap {
|
|
|
|
let config = MapTools.InstanceConvert(options);
|
|
|
|
switch (mapSupplier) {
|
|
|
|
case 1: return new GaoDeMap(container, config);
|
|
|
|
case 2: return new KeDaMap(container, config);
|
|
|
|
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: IMarkOptions): IMarker {
|
|
|
|
switch (mapSupplier) {
|
|
|
|
case 1: return new GaoDeMarker(options);
|
|
|
|
case 2: return new KeDaMarker(options);
|
|
|
|
default: return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static MarkerClusterInstance(map: IMap, list: Object[], renderObj: { gridSize: number, render: IRenderClusterMarker }): IMarkerCluster {
|
|
|
|
switch (mapSupplier) {
|
|
|
|
case 1: return new GaoDeMarkerCluster(map, list, renderObj);
|
|
|
|
default: return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static LngLatInstance(x: number, y: number): ILngLat {
|
|
|
|
switch (mapSupplier) {
|
|
|
|
case 1: return new GaoDeLngLat(x, y);
|
|
|
|
case 2: return new KeDaLngLat(x, y);
|
|
|
|
default: return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static LayerInstance(options: any): ILayer {
|
|
|
|
switch (mapSupplier) {
|
|
|
|
case 1: return new GaodeLayer(options);
|
|
|
|
default: return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static InfoWindowInstance(options: any): InfoWindow {
|
|
|
|
switch (mapSupplier) {
|
|
|
|
case 1: return new GaodeInfoWindow(options);
|
|
|
|
default: return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static CircleInstance(options: any): ICircle {
|
|
|
|
switch (mapSupplier) {
|
|
|
|
case 1: return new GaodeCircle(options);
|
|
|
|
default: return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static RenderClusterMarkerInstance(): IRenderClusterMarker {
|
|
|
|
switch (mapSupplier) {
|
|
|
|
case 1: return new GaoDeRenderClusterMarker();
|
|
|
|
default: return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|