From dbf16d92695b93a1adbc5cb419b51dba75aea80a Mon Sep 17 00:00:00 2001 From: anxinCPF <1105965053@qq.com> Date: Mon, 21 Jun 2021 14:28:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=B0=81=E8=A3=85=E9=83=A8?= =?UTF-8?q?=E5=88=86BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/home/home.component.ts | 2 - .../router-gis/router-gis.component.ts | 6 +-- src/modules/map/declare/gaode-map.ts | 40 +++++++++++-------- src/modules/map/declare/keda-map.ts | 2 + src/modules/map/declare/map.d.ts | 6 ++- 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 5dd308d..df5228d 100644 --- a/src/app/home/home.component.ts +++ b/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; diff --git a/src/app/key-unit/router-gis/router-gis.component.ts b/src/app/key-unit/router-gis/router-gis.component.ts index 5bf8ead..482eb50 100644 --- a/src/app/key-unit/router-gis/router-gis.component.ts +++ b/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 diff --git a/src/modules/map/declare/gaode-map.ts b/src/modules/map/declare/gaode-map.ts index 982023b..5047e30 100644 --- a/src/modules/map/declare/gaode-map.ts +++ b/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) } } diff --git a/src/modules/map/declare/keda-map.ts b/src/modules/map/declare/keda-map.ts index 8279a57..5ff90e8 100644 --- a/src/modules/map/declare/keda-map.ts +++ b/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.'); } diff --git a/src/modules/map/declare/map.d.ts b/src/modules/map/declare/map.d.ts index 9afe41b..7cf91f1 100644 --- a/src/modules/map/declare/map.d.ts +++ b/src/modules/map/declare/map.d.ts @@ -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) } \ No newline at end of file