Browse Source

科达地图联调对接

上海一张图
陈鹏飞 4 years ago
parent
commit
f536cea099
  1. 2
      src/modules/map/declare/factory.ts
  2. 4
      src/modules/map/declare/gaode-map.ts
  3. 70
      src/modules/map/declare/keda-map.ts
  4. 16
      src/modules/map/declare/map.d.ts

2
src/modules/map/declare/factory.ts

@ -1,4 +1,4 @@
const mapSupplier: number = 1; // 1:高德, 2:科达 const mapSupplier: number = 2; // 1:高德, 2:科达
import { IMap, IMapOptions, IMarker, IPixel, IMarkOptions, ILngLat, ILayer, ICircle, IMarkerCluster, IRenderClusterMarker, IInfoWindow, IMouseTool, IIcon, ISize, IIconOptions, ITileLayer, IDriving, IDrivingOptions, IAutocomplete, IPlaceSearch } from './map' import { IMap, IMapOptions, IMarker, IPixel, IMarkOptions, ILngLat, ILayer, ICircle, IMarkerCluster, IRenderClusterMarker, IInfoWindow, IMouseTool, IIcon, ISize, IIconOptions, ITileLayer, IDriving, IDrivingOptions, IAutocomplete, IPlaceSearch } from './map'
import { GaodeCircle, GaodeIcon, GaodeInfoWindow, GaodeLayer, GaoDeLngLat, GaoDeMap, GaoDeMarker, GaoDeMarkerCluster, GaodeMouseTool, GaoDePixel, GaoDeRenderClusterMarker, GaodeTileLayer, GaodeSize, GaodeDriving, GaodeAutocomplete, GaodePlaceSearch } from './gaode-map' import { GaodeCircle, GaodeIcon, GaodeInfoWindow, GaodeLayer, GaoDeLngLat, GaoDeMap, GaoDeMarker, GaoDeMarkerCluster, GaodeMouseTool, GaoDePixel, GaoDeRenderClusterMarker, GaodeTileLayer, GaodeSize, GaodeDriving, GaodeAutocomplete, GaodePlaceSearch } from './gaode-map'

4
src/modules/map/declare/gaode-map.ts

@ -66,7 +66,9 @@ export class GaoDeMap extends GaodeBasic implements IMap {
return this.self.setCenter(pos) return this.self.setCenter(pos)
} }
getCenter() { getCenter() {
return this.self.getCenter(); let d = this.self.getCenter();
let res = new GaoDeLngLat(d.lng,d.lat);
return res;
} }
getZoom() { getZoom() {
return this.self.getZoom(); return this.self.getZoom();

70
src/modules/map/declare/keda-map.ts

@ -7,11 +7,31 @@ class KedaBasic implements ISelf {
} }
export class KeDaMap extends KedaBasic implements IMap { export class KeDaMap extends KedaBasic implements IMap {
constructor(container: string, options: IMapOptions) { constructor(container: string, options: IMapOptions) { //地图初始化
super(); super();
let that = this
let opt = Object.assign({}, { containerId: container }, options) as any; let opt = Object.assign({}, { containerId: container }, options) as any;
opt.configUrl = "../../../assets/kmap/Kmap.config.json"; opt.configUrl = "/assets/kmap/Kmap.config.json";
opt.targetCoordinateType = "WGS84", opt.targetCoordinateType = "WGS84";
let mapLayer = function () {
if (opt.viewMode && opt.viewMode=="3D") {
let data = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [121.495126354, 31.241993148]
},
properties: {height: 30}
}
]
};
that.self.add3DLayer({data: data});
}
}
opt.onLoadMap = mapLayer
this.self = new KMap(opt); this.self = new KMap(opt);
} }
setAdministrativeAreaStyle(conponent: any, getData?: Function, setData?: Function) { //自定义 行政区划 样式 setAdministrativeAreaStyle(conponent: any, getData?: Function, setData?: Function) { //自定义 行政区划 样式
@ -51,19 +71,41 @@ export class KeDaMap extends KedaBasic implements IMap {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
setCity(city: string) { setCity(city: string) {
console.log(1) let that = this
} if (city.includes("上海")) {
setZoom(zoom) { window.setTimeout(function(){
throw new Error('Method not implemented.'); that.self.flyTo({
} zoom:9,
setCenter([x, y]) { point:[121.495126354, 31.241993148]
throw new Error('Method not implemented.'); });
} },10000)
getZoom() { }
throw new Error('Method not implemented.'); }
setZoom(zoom:number) {
this.self.zoomTo({
zoom:zoom
});
}
getZoom():number {
let num
this.self.getZoom({
callback:(e)=>{
num = e.data;
}
})
return num
}
setCenter(pos: number[]) {
this.self.flyTo({point:pos})
} }
getCenter() { getCenter() {
throw new Error('Method not implemented.'); let center
this.self.getCenter({
callback: function (data) {
console.log(data);
}
});
return center
} }
on(eventName: string, callback: Function): void { on(eventName: string, callback: Function): void {
let eventMapProfile = { let eventMapProfile = {

16
src/modules/map/declare/map.d.ts vendored

@ -8,19 +8,19 @@ export interface IMap extends ISelf {
//异步加载插件,插件完成的callback //异步加载插件,插件完成的callback
//pluginName:要加载的插件名 //pluginName:要加载的插件名
plugin(pluginName: string[], callback: Function); plugin(pluginName: string[], callback: Function);
add(obj: IMarker|any): any; add(obj: IMarker|any);
remove(obj: any): any; remove(obj: any);
clearMap(); clearMap();
containerToLngLat(e:any); containerToLngLat(e:any);
setFitView(options:any); setFitView(options:any);
setBounds(zoom?:any, x?:any, y?:any, is?:boolean); setBounds(zoom?:any, x?:any, y?:any, is?:boolean);
setCity(city: string): any; setCity(city: string);
getCity(callback: Function): any; getCity(callback: Function): any;
setZoom(zoom: number): any; setZoom(zoom: number);
setZoomAndCenter(zoom: number, pos: number[]): any; setZoomAndCenter(zoom: number, pos: number[]);
getZoom(): any; getZoom(): number;
setCenter(any): any; setCenter(pos: number[]|ILngLat);
getCenter(): any; getCenter(): ILngLat;
getBounds(): any; getBounds(): any;
distance(a:number[],b:number[]): any; distance(a:number[],b:number[]): any;
setAdministrativeAreaStyle(conponent:any,getData?:Function,setData?:Function): any; //自定义 行政区划 样式 setAdministrativeAreaStyle(conponent:any,getData?:Function,setData?:Function): any; //自定义 行政区划 样式

Loading…
Cancel
Save