From ed13f21e775082bcacf4e2c8fa26dcbf7f2fd061 Mon Sep 17 00:00:00 2001 From: 2912401452 <2912401452@qq.com> Date: Wed, 23 Mar 2022 17:11:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=20ISimpleMapCoord=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/services/map/IMapService.ts | 10 ++++++++-- packages/maps/src/amap/map.ts | 4 ++-- packages/maps/src/amap2/map.ts | 2 +- packages/maps/src/earth/map.ts | 4 ++-- packages/maps/src/index.ts | 4 ++-- packages/maps/src/map/map.ts | 4 ++-- packages/maps/src/mapbox/map.ts | 4 ++-- packages/maps/src/simpleMapCoord.ts | 8 +++++++- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/core/src/services/map/IMapService.ts b/packages/core/src/services/map/IMapService.ts index b7b1a556b8..c23e136ce4 100644 --- a/packages/core/src/services/map/IMapService.ts +++ b/packages/core/src/services/map/IMapService.ts @@ -1,4 +1,3 @@ -import { SimpleMapCoord } from '@antv/l7-maps'; import { Container } from 'inversify'; import { IViewport } from '../camera/ICameraService'; export type Point = [number, number]; @@ -35,9 +34,16 @@ export interface IMapWrapper { ): void; } +interface ISimpleMapCoord { + setSize(size: number): void; + getSize(): [number, number]; + project(lnglat: [number, number]): [number, number]; + unproject(xy: [number, number]): [number, number]; +} + export interface IMapService { version?: string; - simpleMapCoord: SimpleMapCoord; + simpleMapCoord: ISimpleMapCoord; map: RawMap; bgColor: string; setBgColor(color: string): void; diff --git a/packages/maps/src/amap/map.ts b/packages/maps/src/amap/map.ts index 9c5bc969a8..3be79aec30 100644 --- a/packages/maps/src/amap/map.ts +++ b/packages/maps/src/amap/map.ts @@ -24,7 +24,7 @@ import { mat4, vec2, vec3 } from 'gl-matrix'; import { inject, injectable } from 'inversify'; import 'reflect-metadata'; import { IAMapEvent, IAMapInstance } from '../../typings/index'; -import SimpleMapCoord from '../simpleMapCoord'; +import { SimpleMapCoord, ISimpleMapCoord } from '../simpleMapCoord'; import { toPaddingOptions } from '../utils'; import { Version } from '../version'; import './logo.css'; @@ -57,7 +57,7 @@ const LNGLAT_OFFSET_ZOOM_THRESHOLD = 12; // 暂时关闭 fix 统一不同坐标 export default class AMapService implements IMapService { public version: string = Version['GAODE1.x']; - public simpleMapCoord: SimpleMapCoord = new SimpleMapCoord(); + public simpleMapCoord: ISimpleMapCoord = new SimpleMapCoord(); /** * 原始地图实例 */ diff --git a/packages/maps/src/amap2/map.ts b/packages/maps/src/amap2/map.ts index a491d87062..9013122afa 100644 --- a/packages/maps/src/amap2/map.ts +++ b/packages/maps/src/amap2/map.ts @@ -25,7 +25,7 @@ import { mat4, vec2, vec3 } from 'gl-matrix'; import { inject, injectable } from 'inversify'; import 'reflect-metadata'; import { IAMapEvent, IAMapInstance } from '../../typings/index'; -import SimpleMapCoord from '../simpleMapCoord'; +import {ISimpleMapCoord, SimpleMapCoord} from '../simpleMapCoord'; import { toPaddingOptions } from '../utils'; import { Version } from '../version'; import './logo.css'; diff --git a/packages/maps/src/earth/map.ts b/packages/maps/src/earth/map.ts index 44c5e5c02f..e936d9a00c 100644 --- a/packages/maps/src/earth/map.ts +++ b/packages/maps/src/earth/map.ts @@ -31,7 +31,7 @@ const EventMap: { zoomchange: 'zoom', dragging: 'drag', }; -import SimpleMapCoord from '../simpleMapCoord'; +import {ISimpleMapCoord, SimpleMapCoord} from '../simpleMapCoord'; import { MapTheme } from './theme'; const LNGLAT_OFFSET_ZOOM_THRESHOLD = 12; @@ -42,7 +42,7 @@ const LNGLAT_OFFSET_ZOOM_THRESHOLD = 12; export default class L7EarthService implements IEarthService { public version: string = Version.GLOBEL; public map: Map; - public simpleMapCoord: SimpleMapCoord = new SimpleMapCoord(); + public simpleMapCoord: ISimpleMapCoord = new SimpleMapCoord(); // TODO: 判断地图是否正在拖拽 public dragging: boolean = false; diff --git a/packages/maps/src/index.ts b/packages/maps/src/index.ts index bcd6174c94..2a0db19804 100644 --- a/packages/maps/src/index.ts +++ b/packages/maps/src/index.ts @@ -5,9 +5,9 @@ import Earth from './earth/'; // import GaodeMapV2 from './amap2/'; import Map from './map/'; import Mapbox from './mapbox/'; -import SimpleMapCoord from './simpleMapCoord'; +import { ISimpleMapCoord } from './simpleMapCoord'; import { Version } from './version'; -export { SimpleMapCoord, Version, GaodeMap, GaodeMapV2, Mapbox, Map, Earth }; +export { ISimpleMapCoord, Version, GaodeMap, GaodeMapV2, Mapbox, Map, Earth }; // export { GaodeMap, GaodeMapV2, Mapbox, Map }; // export { Map }; diff --git a/packages/maps/src/map/map.ts b/packages/maps/src/map/map.ts index 030059c819..635aaf1901 100644 --- a/packages/maps/src/map/map.ts +++ b/packages/maps/src/map/map.ts @@ -21,7 +21,7 @@ import { Map } from '@antv/l7-map'; import { $window, DOM } from '@antv/l7-utils'; import { inject, injectable } from 'inversify'; import 'reflect-metadata'; -import SimpleMapCoord from '../simpleMapCoord'; +import {ISimpleMapCoord, SimpleMapCoord} from '../simpleMapCoord'; import { Version } from '../version'; import Viewport from './Viewport'; const EventMap: { @@ -42,7 +42,7 @@ const LNGLAT_OFFSET_ZOOM_THRESHOLD = 12; export default class L7MapService implements IMapService { public version: string = Version.L7MAP; public map: Map; - public simpleMapCoord: SimpleMapCoord = new SimpleMapCoord(); + public simpleMapCoord: ISimpleMapCoord = new SimpleMapCoord(); // 背景色 public bgColor: string = 'rgba(0.0, 0.0, 0.0, 0.0)'; diff --git a/packages/maps/src/mapbox/map.ts b/packages/maps/src/mapbox/map.ts index 43a8696383..1ceb70c041 100644 --- a/packages/maps/src/mapbox/map.ts +++ b/packages/maps/src/mapbox/map.ts @@ -36,7 +36,7 @@ const EventMap: { zoomchange: 'zoom', dragging: 'drag', }; -import SimpleMapCoord from '../simpleMapCoord'; +import {ISimpleMapCoord, SimpleMapCoord} from '../simpleMapCoord'; import { MapTheme } from './theme'; let mapdivCount = 0; const LNGLAT_OFFSET_ZOOM_THRESHOLD = 12; @@ -50,7 +50,7 @@ export default class MapboxService implements IMapService { public version: string = Version.MAPBOX; public map: Map & IMapboxInstance; - public simpleMapCoord: SimpleMapCoord = new SimpleMapCoord(); + public simpleMapCoord: ISimpleMapCoord = new SimpleMapCoord(); // 背景色 public bgColor: string = 'rgba(0.0, 0.0, 0.0, 0.0)'; diff --git a/packages/maps/src/simpleMapCoord.ts b/packages/maps/src/simpleMapCoord.ts index 6e3186fa69..c948131eb1 100644 --- a/packages/maps/src/simpleMapCoord.ts +++ b/packages/maps/src/simpleMapCoord.ts @@ -1,4 +1,10 @@ -export default class SimpleMapCoord { +export interface ISimpleMapCoord { + setSize(size: number): void; + getSize(): [number, number]; + project(lnglat: [number, number]): [number, number]; + unproject(xy: [number, number]): [number, number]; +} +export class SimpleMapCoord implements ISimpleMapCoord { private size: number = 10000; constructor(size?: number) { this.size = size ? size : 10000;