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 { 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)
}
getCenter() {
return this.self.getCenter();
let d = this.self.getCenter();
let res = new GaoDeLngLat(d.lng,d.lat);
return res;
}
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 {
constructor(container: string, options: IMapOptions) {
constructor(container: string, options: IMapOptions) { //地图初始化
super();
let that = this
let opt = Object.assign({}, { containerId: container }, options) as any;
opt.configUrl = "../../../assets/kmap/Kmap.config.json";
opt.targetCoordinateType = "WGS84",
opt.configUrl = "/assets/kmap/Kmap.config.json";
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);
}
setAdministrativeAreaStyle(conponent: any, getData?: Function, setData?: Function) { //自定义 行政区划 样式
@ -51,19 +71,41 @@ export class KeDaMap extends KedaBasic implements IMap {
throw new Error('Method not implemented.');
}
setCity(city: string) {
console.log(1)
}
setZoom(zoom) {
throw new Error('Method not implemented.');
}
setCenter([x, y]) {
throw new Error('Method not implemented.');
}
getZoom() {
throw new Error('Method not implemented.');
let that = this
if (city.includes("上海")) {
window.setTimeout(function(){
that.self.flyTo({
zoom:9,
point:[121.495126354, 31.241993148]
});
},10000)
}
}
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() {
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 {
let eventMapProfile = {

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

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

Loading…
Cancel
Save