|
|
|
@ -9,9 +9,18 @@ class GaodeBasic implements ISelf {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export class GaoDeMap extends GaodeBasic implements IMap { |
|
|
|
|
constructor(container: string, options: IMapOptions) { |
|
|
|
|
/// plugins:同步加载插件
|
|
|
|
|
constructor(container: string, options: IMapOptions,plugins?:string[]) { |
|
|
|
|
super(); |
|
|
|
|
this.self = new AMap.Map(container, options); |
|
|
|
|
if(!!plugins && plugins.length){ |
|
|
|
|
for(var i in plugins){ |
|
|
|
|
let name = plugins[i]; |
|
|
|
|
if(name.indexOf('AMap.')==-1)continue; |
|
|
|
|
let pObj = eval(`new ${plugins[i]}()`); |
|
|
|
|
this.self.plugin(pObj); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
setBounds(zoom?: any, x?: any, y?: any, is?: boolean) { |
|
|
|
|
return this.self.setBounds(zoom, x, y, is) |
|
|
|
@ -34,8 +43,9 @@ export class GaoDeMap extends GaodeBasic implements IMap {
|
|
|
|
|
setZoomAndCenter(zoom: number, pos: number[]) { |
|
|
|
|
return this.self.setZoomAndCenter(zoom, pos) |
|
|
|
|
} |
|
|
|
|
plugin(eventName: string[], callback: Function) { |
|
|
|
|
return this.self.plugin(eventName, callback) |
|
|
|
|
plugin(pluginNames: string[], callback: Function) { |
|
|
|
|
let names = pluginNames.filter(s=>s.indexOf("AMap.")==0); |
|
|
|
|
return this.self.plugin(names, callback) |
|
|
|
|
} |
|
|
|
|
getBounds() { |
|
|
|
|
return this.self.getBounds() |
|
|
|
@ -264,7 +274,10 @@ export class GaoDeMarkerCluster extends GaodeBasic implements IMarkerCluster {
|
|
|
|
|
constructor(map: IMap, list: Object[], options: any) { |
|
|
|
|
super(); |
|
|
|
|
let conf = MapTools.ExplicitConvert(options); |
|
|
|
|
|
|
|
|
|
AMap.plugin('AMap.MarkerClusterer',()=>{ |
|
|
|
|
this.self = new AMap.MarkerCluster(map.self, list, conf) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
on(eventName: string, callback: Function): void { |
|
|
|
|
return this.self.on(eventName, callback); |
|
|
|
@ -331,7 +344,9 @@ export class GaodeDriving extends GaodeBasic implements IDriving {
|
|
|
|
|
constructor(options: IDrivingOptions) { |
|
|
|
|
super(); |
|
|
|
|
options.map = options.map.self |
|
|
|
|
AMap.plugin('AMap.Driving',()=>{ |
|
|
|
|
this.self = new AMap.Driving(options) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
clear() { |
|
|
|
|
return this.self.clear() |
|
|
|
@ -344,7 +359,9 @@ export class GaodeDriving extends GaodeBasic implements IDriving {
|
|
|
|
|
export class GaodeAutocomplete extends GaodeBasic implements IAutocomplete { |
|
|
|
|
constructor(city: Object) { |
|
|
|
|
super(); |
|
|
|
|
AMap.plugin('AMap.AutoComplete',()=>{ |
|
|
|
|
this.self = new AMap.Autocomplete(city) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
on(eventName: string, callback: Function) { |
|
|
|
|
return this.self.on(eventName, callback) |
|
|
|
@ -357,7 +374,9 @@ export class GaodeAutocomplete extends GaodeBasic implements IAutocomplete {
|
|
|
|
|
export class GaodePlaceSearch extends GaodeBasic implements IPlaceSearch { |
|
|
|
|
constructor() { |
|
|
|
|
super(); |
|
|
|
|
AMap.plugin('AMap.PlaceSearch',()=>{ |
|
|
|
|
this.self = new AMap.PlaceSearch() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
search(text: string, callback: Function) { |
|
|
|
|
return this.self.search(text, callback) |
|
|
|
@ -367,7 +386,9 @@ export class GaodePlaceSearch extends GaodeBasic implements IPlaceSearch {
|
|
|
|
|
export class GaodeMouseTool extends GaodeBasic implements IMouseTool { |
|
|
|
|
constructor(map: IMap) { |
|
|
|
|
super(); |
|
|
|
|
AMap.plugin(["AMap.RangingTool", "AMap.MouseTool"],()=>{ |
|
|
|
|
this.self = new AMap.MouseTool(map.self); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
rule(options: any) { |
|
|
|
|
let conf = MapTools.ExplicitConvert(options); |
|
|
|
|