赵旭
3 years ago
8 changed files with 4278 additions and 4131 deletions
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
const mapSupplier: number = 1;//1:高德
|
||||
|
||||
import { IMap, IMapOptions, IPixel } from './map' |
||||
import { GaoDeMap, GaoDePixel } from './gaode-map' |
||||
import { KeDaMap, 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; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
import { IMap, IMapOptions, IMarker, IPixel } from './map' |
||||
declare var AMap: any; |
||||
|
||||
|
||||
export class GaoDeMap implements IMap { |
||||
self: any;//AMap.Map
|
||||
constructor(container: string, options: IMapOptions) { |
||||
this.self = new AMap.Map(container, options); |
||||
} |
||||
getCenter() { |
||||
return this.self.getCenter(); |
||||
} |
||||
getZoom() { |
||||
return this.self.getZoom(); |
||||
} |
||||
on(eventName: string, callback: Function): void { |
||||
this.self.on(eventName, callback); |
||||
} |
||||
} |
||||
|
||||
export class GaoDePixel implements IPixel { |
||||
self: any; |
||||
constructor(x: number, y: number) { |
||||
this.self = new AMap.Pixel(x, y); |
||||
} |
||||
} |
||||
|
||||
export class GaoDeMarker implements IMarker { |
||||
self: any; |
||||
constructor(options: any) { |
||||
this.self = new AMap.Marker(options); |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
import { IMap, IMapOptions, IMarker, IPixel } from './map' |
||||
declare var KMap: any; |
||||
import $ from 'jquery'; |
||||
|
||||
export class KeDaMap implements IMap { |
||||
self: any; |
||||
constructor(container: string, options: IMapOptions) { |
||||
let opt = Object.assign({}, { containerId: container }, options) as any; |
||||
opt.configUrl = ""; |
||||
this.self = new KMap(opt); |
||||
} |
||||
on(eventName: string, callback: Function): void { |
||||
let eventMapProfile = { |
||||
complete: "load", |
||||
click: "click", |
||||
rightclick: "contextmenu" |
||||
}; |
||||
this.self.addEventOnMap({ |
||||
event: eventMapProfile[eventName], |
||||
handler: callback |
||||
}); |
||||
} |
||||
} |
||||
|
||||
export class KeDaPixel implements IPixel { |
||||
self: any; |
||||
constructor(x: number, y: number) { |
||||
this.self = [x, y]; |
||||
} |
||||
} |
||||
|
||||
export class KeDaMarker implements IMarker { |
||||
self: any; |
||||
constructor(options: any) { |
||||
let element = $(options.content)[0]; |
||||
let d = { |
||||
offset: options.offset, |
||||
element: element |
||||
}; |
||||
|
||||
|
||||
|
||||
this.self = d; |
||||
} |
||||
} |
@ -0,0 +1,29 @@
|
||||
//AMap.Circle
|
||||
//AMap.Map
|
||||
//AMap.Icon
|
||||
//AMap.Pixel
|
||||
//AMap.LngLat
|
||||
|
||||
export interface ISelf { |
||||
self: any; |
||||
} |
||||
|
||||
export interface IMap extends ISelf { |
||||
on(eventName: string, callback: Function): void; |
||||
getZoom(): any; |
||||
getCenter(): any; |
||||
} |
||||
|
||||
export interface IMapOptions { |
||||
zoom?: number; |
||||
zooms?: number[]; |
||||
} |
||||
|
||||
export interface IMarker extends ISelf { |
||||
|
||||
} |
||||
|
||||
|
||||
export interface IPixel extends ISelf { |
||||
|
||||
} |
Loading…
Reference in new issue