fix: 新增 ISimpleMapCoord 类型定义

This commit is contained in:
2912401452 2022-03-23 17:11:47 +08:00
parent 3de9d38e28
commit ed13f21e77
8 changed files with 26 additions and 14 deletions

View File

@ -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<RawMap = {}> {
version?: string;
simpleMapCoord: SimpleMapCoord;
simpleMapCoord: ISimpleMapCoord;
map: RawMap;
bgColor: string;
setBgColor(color: string): void;

View File

@ -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<AMap.Map & IAMapInstance> {
public version: string = Version['GAODE1.x'];
public simpleMapCoord: SimpleMapCoord = new SimpleMapCoord();
public simpleMapCoord: ISimpleMapCoord = new SimpleMapCoord();
/**
*
*/

View File

@ -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';

View File

@ -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<Map> {
public version: string = Version.GLOBEL;
public map: Map;
public simpleMapCoord: SimpleMapCoord = new SimpleMapCoord();
public simpleMapCoord: ISimpleMapCoord = new SimpleMapCoord();
// TODO: 判断地图是否正在拖拽
public dragging: boolean = false;

View File

@ -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 };

View File

@ -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<Map> {
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)';

View File

@ -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<Map & IMapboxInstance> {
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)';

View File

@ -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;