Browse Source

修正封装部分BUG

上海一张图
陈鹏飞 4 years ago
parent
commit
dbf16d9269
  1. 2
      src/app/home/home.component.ts
  2. 6
      src/app/key-unit/router-gis/router-gis.component.ts
  3. 40
      src/modules/map/declare/gaode-map.ts
  4. 2
      src/modules/map/declare/keda-map.ts
  5. 6
      src/modules/map/declare/map.d.ts

2
src/app/home/home.component.ts

@ -1,8 +1,6 @@
import { Component, OnInit, Renderer2, ElementRef } from '@angular/core';
import { HttpClient } from '@angular/common/http'
declare var echarts: any;
declare var AMap: any;
declare var AMapUI: any;

6
src/app/key-unit/router-gis/router-gis.component.ts

@ -33,14 +33,14 @@ export class RouterGISComponent implements OnInit {
this.http.get(`/api/Companies/${this.route.snapshot.queryParams.id}`).subscribe((data:any)=>{
if (data.driveRouteStartPoint && data.driveRouteStartPoint.x && data.driveRouteStartPoint.y && data.driveRouteStartName) { //开始坐标 名称
this.routeStart = data.driveRouteStartName
this.startCoordinate = [data.driveRouteStartPoint.x,data.driveRouteStartPoint.y]
this.startCoordinate = MapFactory.LngLatInstance(data.driveRouteStartPoint.x, data.driveRouteStartPoint.y)
}
if (data.driveRouteEndPoint && data.driveRouteEndPoint.x && data.driveRouteEndPoint.y && data.driveRouteEndName) { //结束坐标 名称
this.routeEnd = data.driveRouteEndName
this.endCoordinate = [data.driveRouteEndPoint.x,data.driveRouteEndPoint.y]
this.endCoordinate = MapFactory.LngLatInstance(data.driveRouteEndPoint.x, data.driveRouteEndPoint.y)
} else if (data.location && data.location.x && data.location.y) {
this.routeEnd = data.name
this.endCoordinate = [data.location.x,data.location.y]
this.endCoordinate = MapFactory.LngLatInstance(data.location.x, data.location.y)
}
resolve('success')
}) //http

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

@ -13,16 +13,16 @@ export class GaoDeMap extends GaodeBasic implements IMap {
this.self = new AMap.Map(container, options);
}
setBounds(zoom?: any, x?: any, y?: any, is?: boolean) {
this.self.setBounds(zoom,x,y,is)
return this.self.setBounds(zoom,x,y,is)
}
setFitView(options: any) {
this.self.setFitView(options)
return this.self.setFitView(options)
}
containerToLngLat(e: any) {
this.self.containerToLngLat(e)
return this.self.containerToLngLat(e)
}
clearMap() {
this.self.clearMap();
return this.self.clearMap();
}
distance(a: number[], b: number[]) {
return AMap.GeometryUtil.distance(a, b);
@ -51,8 +51,8 @@ export class GaoDeMap extends GaodeBasic implements IMap {
setZoom(zoom) {
return this.self.setZoom(zoom)
}
setCenter([x, y]) {
return this.self.setCenter([x, y])
setCenter(pos:any) {
return this.self.setCenter(pos)
}
getCenter() {
return this.self.getCenter();
@ -61,7 +61,7 @@ export class GaoDeMap extends GaodeBasic implements IMap {
return this.self.getZoom();
}
on(eventName: string, callback: Function): void {
this.self.on(eventName, callback);
return this.self.on(eventName, callback);
}
}
@ -80,14 +80,14 @@ export class GaoDeMarker extends GaodeBasic implements IMarker {
this._position = this.self._position;
}
setContent(html: string) {
this.self.setContent(html)
return this.self.setContent(html)
}
setPosition(x: number[]) {
this.self.setPosition(x)
return this.self.setPosition(x)
}
_position: number[]
setMap() {
this.self.setMap(null)
return this.self.setMap(null)
}
get id(): string {
return this.self.id;
@ -96,7 +96,7 @@ export class GaoDeMarker extends GaodeBasic implements IMarker {
this.self.id = str;
}
on(eventName: string, callback: Function): void {
this.self.on(eventName, callback);
return this.self.on(eventName, callback);
}
}
@ -107,10 +107,10 @@ export class GaoDeMarkerCluster extends GaodeBasic implements IMarkerCluster {
this.self = new AMap.MarkerCluster(map.self, list, conf)
}
on(eventName: string, callback: Function): void {
this.self.on(eventName, callback);
return this.self.on(eventName, callback);
}
setData(list: any[]) {
this.self.setData(list)
return this.self.setData(list)
}
}
@ -119,6 +119,12 @@ export class GaoDeLngLat extends GaodeBasic implements ILngLat {
super();
this.self = new AMap.LngLat(x, y);
}
get lng(): number {
return this.self.lng;
}
get lat(): number {
return this.self.lat;
}
offset(x: number, y: number) {
return this.self.offset(x, y)
}
@ -168,10 +174,10 @@ export class GaodeDriving extends GaodeBasic implements IDriving {
this.self = new AMap.Driving(options)
}
clear() {
this.self.clear()
return this.self.clear()
}
search(x: any, y: any, callback: Function) {
this.self.search(x.self, y.self, callback)
return this.self.search(x.self, y.self, callback)
}
}
@ -181,10 +187,10 @@ export class GaodeAutocomplete extends GaodeBasic implements IAutocomplete {
this.self = new AMap.Autocomplete(city)
}
on(eventName: string, callback: Function) {
this.self.on(eventName, callback)
return this.self.on(eventName, callback)
}
search(address: string, callback: Function) {
this.self.search(address, callback)
return this.self.search(address, callback)
}
}

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

@ -113,6 +113,8 @@ export class KeDaLngLat implements ILngLat {
constructor(x: number, y: number) {
this.self = new KMap.LngLat(x, y);
}
lng: number;
lat: number;
offset(x: number, y: number) {
throw new Error('Method not implemented.');
}

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

@ -17,7 +17,7 @@ export interface IMap extends ISelf {
setZoom(zoom: number): any;
setZoomAndCenter(zoom: number, pos: number[]): any;
getZoom(): any;
setCenter(x: number[]): any;
setCenter(any): any;
getCenter(): any;
getBounds(): any;
distance(a:number[],b:number[]): any;
@ -64,6 +64,8 @@ export interface IPixel extends ISelf {
}
export interface ILngLat extends ISelf {
lng: number
lat: number
offset(x: number, y: number)
}
@ -125,5 +127,5 @@ export interface IInfoWindow extends ISelf {
export interface ICircle extends ISelf {
setRadius(num: number);
setCenter(pos: number[])
setMap(map: any)
setMap(map: IMap)
}
Loading…
Cancel
Save