tg-map-vue3 3.9.9 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +4 -1
- package/dist/src/components/TgMap.vue.d.ts +1877 -83
- package/dist/src/components/TgMapWidget.vue.d.ts +3 -3
- package/dist/src/components/controls/TgCustomControl.vue.d.ts +1 -2
- package/dist/src/components/controls/TgMapTypeControl.vue.d.ts +8 -9
- package/dist/src/components/controls/TgScaleControl.vue.d.ts +4 -5
- package/dist/src/components/controls/TgStreetViewControl.vue.d.ts +4 -4
- package/dist/src/components/controls/TgZoomControl.vue.d.ts +4 -4
- package/dist/src/components/extra/TgHeatmap.vue.d.ts +2 -2
- package/dist/src/components/extra/TgMarkerClusterer.vue.d.ts +3 -4
- package/dist/src/components/index.d.ts +4 -41
- package/dist/src/components/layers/TgTrafficLayer.vue.d.ts +1 -1
- package/dist/src/components/map-hooks.d.ts +4 -4
- package/dist/src/components/map-mixin.d.ts +2 -2
- package/dist/src/components/overlays/TgCircle.vue.d.ts +19 -14
- package/dist/src/components/overlays/TgElementOverlay.vue.d.ts +5 -7
- package/dist/src/components/overlays/TgInfoBox.vue.d.ts +5 -7
- package/dist/src/components/overlays/TgInfoWindow.vue.d.ts +16 -17
- package/dist/src/components/overlays/TgLabel.vue.d.ts +4 -7
- package/dist/src/components/overlays/TgMarker.vue.d.ts +89 -45
- package/dist/src/components/overlays/TgPolygon.vue.d.ts +64 -27
- package/dist/src/components/overlays/TgPolyline.vue.d.ts +16 -12
- package/dist/src/components/overlays/TgRectangle.vue.d.ts +28 -27
- package/dist/src/utils/hooks.d.ts +4 -0
- package/dist/src/utils/vue-utils.d.ts +13 -2
- package/dist/tg-map.cjs +2 -17
- package/dist/tg-map.cjs.map +1 -1
- package/dist/tg-map.js +679 -6481
- package/dist/tg-map.js.map +1 -1
- package/package.json +14 -13
- package/dist/src/map/event-target.d.ts +0 -71
- package/dist/src/map/event.d.ts +0 -46
- package/dist/src/map/lat-lng.d.ts +0 -157
- package/dist/src/map/map/baidu-map.d.ts +0 -82
- package/dist/src/map/map/controls/control.d.ts +0 -112
- package/dist/src/map/map/controls/map-type.control.d.ts +0 -29
- package/dist/src/map/map/controls/scale.control.d.ts +0 -15
- package/dist/src/map/map/controls/street-view.control.d.ts +0 -20
- package/dist/src/map/map/controls/zoom.control.d.ts +0 -15
- package/dist/src/map/map/extra/autocomplete.d.ts +0 -41
- package/dist/src/map/map/extra/heatmap.d.ts +0 -71
- package/dist/src/map/map/extra/map-urls.d.ts +0 -59
- package/dist/src/map/map/extra/marker-clusterer.d.ts +0 -73
- package/dist/src/map/map/extra/places-service.d.ts +0 -46
- package/dist/src/map/map/extra/search-box.d.ts +0 -38
- package/dist/src/map/map/google-map.d.ts +0 -81
- package/dist/src/map/map/here-map.d.ts +0 -78
- package/dist/src/map/map/map-options.d.ts +0 -60
- package/dist/src/map/map/map-type.d.ts +0 -110
- package/dist/src/map/map/map.d.ts +0 -168
- package/dist/src/map/map/overlay/baidu-info-box.d.ts +0 -82
- package/dist/src/map/map/overlay/circle.d.ts +0 -51
- package/dist/src/map/map/overlay/element-overlay.d.ts +0 -37
- package/dist/src/map/map/overlay/google-label.d.ts +0 -68
- package/dist/src/map/map/overlay/icon.d.ts +0 -122
- package/dist/src/map/map/overlay/info-box.d.ts +0 -60
- package/dist/src/map/map/overlay/info-window.d.ts +0 -111
- package/dist/src/map/map/overlay/label.d.ts +0 -102
- package/dist/src/map/map/overlay/marker-label.d.ts +0 -19
- package/dist/src/map/map/overlay/marker.d.ts +0 -143
- package/dist/src/map/map/overlay/overlay.d.ts +0 -46
- package/dist/src/map/map/overlay/polygon.d.ts +0 -42
- package/dist/src/map/map/overlay/polyline.d.ts +0 -71
- package/dist/src/map/map/overlay/rectangle.d.ts +0 -50
- package/dist/src/map/map/overlay/shape.d.ts +0 -65
- package/dist/src/map/map-config.d.ts +0 -25
- package/dist/src/map/map-factory.d.ts +0 -10
- package/dist/src/map/map-loader.d.ts +0 -19
- package/dist/src/map/types.d.ts +0 -17
- package/dist/src/map/unions.d.ts +0 -19
- package/dist/src/utils/arrays.d.ts +0 -19
- package/dist/src/utils/baidu-utils.d.ts +0 -23
- package/dist/src/utils/elements.d.ts +0 -4
- package/dist/src/utils/formatter.d.ts +0 -1
- package/dist/src/utils/google-utils.d.ts +0 -34
- package/dist/src/utils/here-utils.d.ts +0 -10
- package/dist/src/utils/mapped-types.d.ts +0 -90
- package/dist/src/utils/maps-utils/index.d.ts +0 -2
- package/dist/src/utils/maps-utils/math-util.d.ts +0 -59
- package/dist/src/utils/maps-utils/poly-util.d.ts +0 -103
- package/dist/src/utils/maps-utils/spherical-util.d.ts +0 -67
- package/dist/src/utils/objects.d.ts +0 -27
- package/dist/src/utils/spherical-utils.d.ts +0 -27
- package/dist/src/utils/strings.d.ts +0 -21
- package/dist/src/utils/utils.d.ts +0 -13
- package/dist/src/utils/values.d.ts +0 -34
- package/src/map/dts/baidu.d.ts +0 -53
- package/src/map/dts/google.d.ts +0 -10
- package/src/map/dts/here-v31.d.ts +0 -16
- package/src/map/dts/index.d.ts +0 -4
- package/src/map/dts/js-modules.d.ts +0 -15
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AbstractMap } from './map/map';
|
|
2
|
-
import { MapOptions } from './map/map-options';
|
|
3
|
-
export declare enum TgMapType {
|
|
4
|
-
google = "google",
|
|
5
|
-
baidu = "baidu",
|
|
6
|
-
here = "here"
|
|
7
|
-
}
|
|
8
|
-
export declare namespace TgMapFactory {
|
|
9
|
-
function createMap(type: TgMapType, $map: HTMLElement, mapOptions?: Partial<MapOptions>): AbstractMap;
|
|
10
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type TgMapConfig } from './map-config';
|
|
2
|
-
import { TgMapType } from './map-factory';
|
|
3
|
-
/**
|
|
4
|
-
* 使用类型映射的方式`TgMapConfig[T]`, 确定`type`的类型之后, 不会自动推断`config`的类型,
|
|
5
|
-
* 故另外声明了一个联合类型{@link LoadMapOptionsImpl}, 在实现代码中使用它来自动推断类型
|
|
6
|
-
*/
|
|
7
|
-
type LoadMapOptions<T extends TgMapType> = {
|
|
8
|
-
type: T;
|
|
9
|
-
config: TgMapConfig[T];
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* 加载缓存的地图, 保证一种地图只加载一次
|
|
13
|
-
*/
|
|
14
|
-
export declare function loadCachedMap(type: TgMapType): Promise<unknown>;
|
|
15
|
-
/** 载入地图库 */
|
|
16
|
-
export declare function loadMap<T extends TgMapType>(options: LoadMapOptions<T>): Promise<unknown>;
|
|
17
|
-
export declare function loadJsonp(url: string, callbackParamName?: string): Promise<unknown>;
|
|
18
|
-
export declare function loadJs(url: string): Promise<unknown>;
|
|
19
|
-
export {};
|
package/dist/src/map/types.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface Size {
|
|
2
|
-
readonly width: number;
|
|
3
|
-
readonly height: number;
|
|
4
|
-
}
|
|
5
|
-
export interface Point {
|
|
6
|
-
readonly x: number;
|
|
7
|
-
readonly y: number;
|
|
8
|
-
}
|
|
9
|
-
export declare namespace Point {
|
|
10
|
-
const ZERO: Point;
|
|
11
|
-
}
|
|
12
|
-
export interface Padding {
|
|
13
|
-
top: number;
|
|
14
|
-
right: number;
|
|
15
|
-
bottom: number;
|
|
16
|
-
left: number;
|
|
17
|
-
}
|
package/dist/src/map/unions.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { BaiduInfoBox } from './map/overlay/baidu-info-box';
|
|
2
|
-
import type { GoogleLabel } from './map/overlay/google-label';
|
|
3
|
-
/**
|
|
4
|
-
* Map相关的各种类型的联合, 可以用来简化一部分代码的书写
|
|
5
|
-
*/
|
|
6
|
-
export type UnionMap = google.maps.Map | BMap.Map | H.Map;
|
|
7
|
-
export type UnionBaiduIcon = BMap.Icon | BMap.Symbol;
|
|
8
|
-
export type UnionGoogleIcon = google.maps.Icon | google.maps.Symbol | google.maps.UrlIcon;
|
|
9
|
-
export type UnionInfoWindow = google.maps.InfoWindow | BMap.InfoWindow;
|
|
10
|
-
export type UnionAutocomplete = google.maps.places.Autocomplete | BMap.Autocomplete;
|
|
11
|
-
export type UnionPlacesService = google.maps.places.PlacesService | BMap.LocalSearch;
|
|
12
|
-
export type UnionGoogleOverlay = google.maps.Marker | google.maps.Polyline | google.maps.Polygon | google.maps.Circle | google.maps.Rectangle | GoogleLabel;
|
|
13
|
-
export type UnionBaiduOverlay = BMap.Marker | BMap.Polyline | BMap.Polygon | BMap.Circle | BMap.Label | BaiduInfoBox;
|
|
14
|
-
export type UnionGoogleEventTarget = google.maps.MVCObject;
|
|
15
|
-
export type UnionBaiduEventTarget = UnionBaiduOverlay | BMap.InfoWindow | BMap.Autocomplete | BMap.Map;
|
|
16
|
-
export type UnionBaiduShape = BMap.Polyline | BMap.Polygon | BMap.Circle;
|
|
17
|
-
export type UnionGoogleShape = google.maps.Polyline | google.maps.Polygon | google.maps.Circle | google.maps.Rectangle;
|
|
18
|
-
export type UnionControl = BMap.Control | HTMLElement;
|
|
19
|
-
export type GoogleLayer = google.maps.TrafficLayer | google.maps.TransitLayer | google.maps.KmlLayer | google.maps.BicyclingLayer;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AnyFunction, Constructor } from './mapped-types';
|
|
2
|
-
export declare namespace Arrays {
|
|
3
|
-
function findByType<T>(arr: any[], constructor: Constructor<T>): T | undefined;
|
|
4
|
-
/** 自动推断item的类型的{@link Array.includes} */
|
|
5
|
-
function includesTyped<T extends E, E>(arr: T[], item: E): item is T;
|
|
6
|
-
/** 设置 指定位置的值 */
|
|
7
|
-
function at<T>(arr: T[], index: number, value: T): void;
|
|
8
|
-
/** 获取 指定位置的值 */
|
|
9
|
-
function at<T>(arr: T[], index: number): T | undefined;
|
|
10
|
-
}
|
|
11
|
-
export declare namespace MVCArrays {
|
|
12
|
-
function indexOf<T>(arr: google.maps.MVCArray<T>, item: T): number;
|
|
13
|
-
function remove<T>(arr: google.maps.MVCArray<T>, item: T): T | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* 监听数组内容变化
|
|
16
|
-
* @see https://developers.google.com/maps/documentation/javascript/shapes#editable_events
|
|
17
|
-
* */
|
|
18
|
-
function listenChanged<T>(path: google.maps.MVCArray<T>, handler: AnyFunction): google.maps.MapsEventListener[];
|
|
19
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 3.0版的Overlay是类
|
|
3
|
-
* @see http://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference_3_0.html#a3b0
|
|
4
|
-
*/
|
|
5
|
-
export declare function ensureBaiduV3(): void;
|
|
6
|
-
/**
|
|
7
|
-
* 尝试修复baidu内存占用会越来越大的问题
|
|
8
|
-
*
|
|
9
|
-
* 当前版本的baidu源码中, 存在如下代码:
|
|
10
|
-
* ```
|
|
11
|
-
* A.lang.qx = function(a) {
|
|
12
|
-
* var b = window[A.da]; // A.da等于'$BAIDU$'
|
|
13
|
-
* b.kT && delete b.kT[a] // kT属性不存在, 故永远无法移除成功
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
* 最终会导致`$BAIDU$._instances`对象不断增长, 故我们把`$BAIDU$`对象的`kT`属性重定向到`_instances`
|
|
17
|
-
* 保证该方法能够执行成功
|
|
18
|
-
*/
|
|
19
|
-
export declare function tryFixBaiduOutOfMemory(): void;
|
|
20
|
-
export declare const BMapPoints: {
|
|
21
|
-
/** {@link BMap.Point.equals} 无效, 故需要自己写一个 */
|
|
22
|
-
equals(a: BMap.Point, b: BMap.Point): boolean;
|
|
23
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function dimen(value: string | number | null | undefined): string | undefined;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type CoordTypeSupplier } from '../map/lat-lng';
|
|
2
|
-
import type { Place } from '../map/map/extra/places-service';
|
|
3
|
-
/**
|
|
4
|
-
* Google地图官方提供的载入方式, 使用{@link google.map.importLibrary}动态载入依赖
|
|
5
|
-
*
|
|
6
|
-
* 实验性的特性, 实测当前只有`3.52`版支持
|
|
7
|
-
*
|
|
8
|
-
* @see https://developers.google.com/maps/documentation/javascript/load-maps-js-api#dynamic-library-import
|
|
9
|
-
*/
|
|
10
|
-
export declare function initGoogleMapDynamicLibraryImport(args: {
|
|
11
|
-
key: string;
|
|
12
|
-
v?: string;
|
|
13
|
-
}): void;
|
|
14
|
-
export declare const GoogleConst: {
|
|
15
|
-
/** Google的坐标0点 */
|
|
16
|
-
readonly LATLNG_ZERO: google.maps.LatLng;
|
|
17
|
-
readonly BOUNDS_ZERO: google.maps.LatLngBounds;
|
|
18
|
-
};
|
|
19
|
-
export interface AddressFields {
|
|
20
|
-
/** 国家 */
|
|
21
|
-
country: string;
|
|
22
|
-
/** 省 */
|
|
23
|
-
province: string;
|
|
24
|
-
/** 市 */
|
|
25
|
-
city: string;
|
|
26
|
-
/** 区 */
|
|
27
|
-
district: string;
|
|
28
|
-
/** 街道 */
|
|
29
|
-
street: string;
|
|
30
|
-
/** 门牌号 */
|
|
31
|
-
streetNumber: string;
|
|
32
|
-
}
|
|
33
|
-
export declare function parseGoogleAddressComponents(addressComponents: google.maps.GeocoderAddressComponent[], outResult?: AddressFields): AddressFields;
|
|
34
|
-
export declare function parseGooglePlace(place: google.maps.places.PlaceResult, coordTypeSupplier: CoordTypeSupplier): Place;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 最新是3.1版, 但@types/heremaps和以前的项目都用的是3.0版, 故当前先用3.0...
|
|
3
|
-
* TODO: 改成使用3.1版实现
|
|
4
|
-
**/
|
|
5
|
-
export declare const HERE_SUPPORTED_VERSIONS: readonly ["3.0"];
|
|
6
|
-
/**
|
|
7
|
-
* 当前@types/heremaps是v3.0版, 和v3.1版api有区别, 若要使用3.1版, 需要用这个方法来做到类型注解兼容...
|
|
8
|
-
* @see https://developer.here.com/documentation/maps/topics/migration.html
|
|
9
|
-
*/
|
|
10
|
-
export declare function ensureHereV31(): void;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { Component, ComponentPublicInstance } from 'vue';
|
|
2
|
-
/** deep版的 `Partial` */
|
|
3
|
-
export type DeepPartial<T> = {
|
|
4
|
-
[U in keyof T]?: T[U] extends object ? DeepPartial<T[U]> : T[U];
|
|
5
|
-
};
|
|
6
|
-
/** 表示一个函数 */
|
|
7
|
-
export type AnyFunction = (...args: any[]) => any;
|
|
8
|
-
/**
|
|
9
|
-
* 表示一个构造器
|
|
10
|
-
* {@link import('vue/types/options').Constructor}
|
|
11
|
-
* */
|
|
12
|
-
export type Constructor<T = {}> = new (...args: any[]) => T;
|
|
13
|
-
/**
|
|
14
|
-
* 抽象构造器类型, 相比{@link Constructor}, 不能直接用new创建对象
|
|
15
|
-
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures
|
|
16
|
-
*/
|
|
17
|
-
export type AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;
|
|
18
|
-
/** 原始类型=>包装类型 */
|
|
19
|
-
export type PrimitiveToWrapper<T> = T extends boolean ? boolean : T extends string ? string : T extends number ? number : T;
|
|
20
|
-
/** 包装类型=>原始类型 */
|
|
21
|
-
export type WrapperToPrimitive<T> = T extends boolean ? boolean : T extends string ? string : T extends number ? number : T;
|
|
22
|
-
/**
|
|
23
|
-
* `vue instanceof VueConstructor`时`vue`并不会自动转换成`VueConstructor`的子类, 用该方法可以实现这种转换
|
|
24
|
-
*/
|
|
25
|
-
export declare function isInstanceOf<T>(obj: any, constructor: Constructor<T>): obj is T;
|
|
26
|
-
/** @see isInstanceOf */
|
|
27
|
-
export declare function safeAs<T>(obj: any, constructor: Constructor<T>): T | undefined;
|
|
28
|
-
/** 判断{@link instance}是否是{@link component}的实例 */
|
|
29
|
-
export declare function isComponentByType<C extends Component & AbstractConstructor>(instance: ComponentPublicInstance | null, component: C): instance is InstanceType<C>;
|
|
30
|
-
/** 安全转换组件类型, 若不能转换会返回`undefined` */
|
|
31
|
-
export declare function safeAsComponent<C extends Component & AbstractConstructor>(instance: ComponentPublicInstance | null, component: C): InstanceType<C> | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* 查找[startInstance, endComponent)之间的第一个类型为{@link component}的父组件
|
|
34
|
-
* @param component 查找的组件
|
|
35
|
-
* @param startInstance 查找的开始实例, 包含
|
|
36
|
-
* @param endComponent 查找的终止组件, 不包含
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
export declare function findAncestorComponentByType<C extends Component & AbstractConstructor>(component: C, startInstance: ComponentPublicInstance | null, endComponent?: Component & AbstractConstructor): InstanceType<C> | undefined;
|
|
40
|
-
/** {@link NonNullable} 的反义词 */
|
|
41
|
-
export type Nullable<T> = T | null | undefined;
|
|
42
|
-
/** T的所有value的联合类型 */
|
|
43
|
-
export type ValueOf<T> = T[keyof T];
|
|
44
|
-
/**
|
|
45
|
-
* 提取出T中value为V的子类的所有key
|
|
46
|
-
* @see https://stackoverflow.com/questions/54520676/in-typescript-how-to-specify-only-keys-of-a-generic-object-whose-values-are-stri
|
|
47
|
-
* */
|
|
48
|
-
export type KeysMatching<T, V> = {
|
|
49
|
-
[K in keyof T]: T[K] extends V ? K : never;
|
|
50
|
-
}[keyof T];
|
|
51
|
-
/**
|
|
52
|
-
* 并不存在可以精确表示一个枚举类型, 该类只能近似表示一个字符枚举
|
|
53
|
-
* */
|
|
54
|
-
export type StringEnumLike = {
|
|
55
|
-
[k: string]: string;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* String枚举的值, 包括`string`类型
|
|
59
|
-
* @see https://stackoverflow.com/questions/52393730/typescript-string-literal-union-type-from-enum
|
|
60
|
-
*/
|
|
61
|
-
export type StringEnumValue<E extends StringEnumLike> = ValueOf<E> | `${ValueOf<E>}`;
|
|
62
|
-
/**
|
|
63
|
-
* 包装`T`中的部分枚举字段的值为{@link StringEnumValue}
|
|
64
|
-
*
|
|
65
|
-
* 会校验{@link EnumObjects}中的类型是否书写正确, 若写错, 会推断成`never`
|
|
66
|
-
* */
|
|
67
|
-
export type WrapStringEnumValue<T, EnumObjects extends {
|
|
68
|
-
[k in keyof T]?: StringEnumLike;
|
|
69
|
-
}> = {
|
|
70
|
-
[P in keyof T]: P extends keyof EnumObjects ? EnumObjects[P] extends StringEnumLike ? T[P] extends ValueOf<EnumObjects[P]> | undefined ? StringEnumValue<EnumObjects[P]> : never : never : T[P];
|
|
71
|
-
};
|
|
72
|
-
/** 取消包装`T`中的{@link StringEnumValue}字段 */
|
|
73
|
-
export declare function unwrapStringEnumValue<T extends object>(value: T): {
|
|
74
|
-
[K in keyof T]: T[K] extends StringEnumValue<infer Enum> ? StringEnumLike extends Enum ? T[K] : Enum[keyof Enum] : Exclude<T[K], undefined> extends StringEnumValue<infer Enum> ? StringEnumLike extends Enum ? T[K] : Enum[keyof Enum] | undefined : T[K];
|
|
75
|
-
};
|
|
76
|
-
export declare function unwrapStringEnumValue<E extends StringEnumLike>(value: StringEnumValue<E>, enumObject?: E): E[keyof E];
|
|
77
|
-
export declare function unwrapStringEnumValue<E extends StringEnumLike>(value: StringEnumValue<E> | undefined, enumObject?: E): E[keyof E] | undefined;
|
|
78
|
-
/**
|
|
79
|
-
* 非空的值
|
|
80
|
-
*
|
|
81
|
-
* 类型`{}`也表示"任何非空的值", 但由于它看起来像空对象, 所以一般更推荐用Thing
|
|
82
|
-
*
|
|
83
|
-
* @see https://github.com/microsoft/TypeScript/issues/7648#issuecomment-541625573
|
|
84
|
-
* @see https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-675156492
|
|
85
|
-
*/
|
|
86
|
-
export type Thing = string | number | boolean | bigint | object | symbol;
|
|
87
|
-
/** 除T指定的类型外, 其他参数 */
|
|
88
|
-
export type TypedAny<T> = T & {
|
|
89
|
-
[k: string]: any;
|
|
90
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The earth's radius, in meters.
|
|
3
|
-
* Mean radius as defined by IUGG.
|
|
4
|
-
*/
|
|
5
|
-
export declare const EARTH_RADIUS = 6371009;
|
|
6
|
-
/**
|
|
7
|
-
* Restrict x to the range [low, high].
|
|
8
|
-
*/
|
|
9
|
-
export declare function clamp(x: number, low: number, high: number): number;
|
|
10
|
-
/**
|
|
11
|
-
* Wraps the given value into the inclusive-exclusive interval between min and max.
|
|
12
|
-
*
|
|
13
|
-
* @param n The value to wrap.
|
|
14
|
-
* @param min The minimum.
|
|
15
|
-
* @param max The maximum.
|
|
16
|
-
*/
|
|
17
|
-
export declare function wrap(n: number, min: number, max: number): number;
|
|
18
|
-
/**
|
|
19
|
-
* Returns the non-negative remainder of x / m.
|
|
20
|
-
*
|
|
21
|
-
* @param x The operand.
|
|
22
|
-
* @param m The modulus.
|
|
23
|
-
*/
|
|
24
|
-
export declare function mod(x: number, m: number): number;
|
|
25
|
-
/**
|
|
26
|
-
* Returns mercator Y corresponding to latitude.
|
|
27
|
-
* See http://en.wikipedia.org/wiki/Mercator_projection .
|
|
28
|
-
*/
|
|
29
|
-
export declare function mercator(lat: number): number;
|
|
30
|
-
/**
|
|
31
|
-
* Returns latitude from mercator Y.
|
|
32
|
-
*/
|
|
33
|
-
export declare function inverseMercator(y: number): number;
|
|
34
|
-
/**
|
|
35
|
-
* Returns haversine(angle-in-radians).
|
|
36
|
-
* hav(x) == (1 - cos(x)) / 2 == sin(x / 2)^2.
|
|
37
|
-
*/
|
|
38
|
-
export declare function hav(x: number): number;
|
|
39
|
-
/**
|
|
40
|
-
* Computes inverse haversine. Has good numerical stability around 0.
|
|
41
|
-
* arcHav(x) == acos(1 - 2 * x) == 2 * asin(sqrt(x)).
|
|
42
|
-
* The argument must be in [0, 1], and the result is positive.
|
|
43
|
-
*/
|
|
44
|
-
export declare function arcHav(x: number): number;
|
|
45
|
-
export declare function sinFromHav(h: number): number;
|
|
46
|
-
export declare function havFromSin(x: number): number;
|
|
47
|
-
export declare function sinSumFromHav(x: number, y: number): number;
|
|
48
|
-
/**
|
|
49
|
-
* Returns hav() of distance from (lat1, lng1) to (lat2, lng2) on the unit sphere.
|
|
50
|
-
*/
|
|
51
|
-
export declare function havDistance(lat1: number, lat2: number, dLng: number): number;
|
|
52
|
-
/**
|
|
53
|
-
* Converts degrees to radians.
|
|
54
|
-
*/
|
|
55
|
-
export declare function toRadians(degrees: number): number;
|
|
56
|
-
/**
|
|
57
|
-
* Converts radians to degrees.
|
|
58
|
-
*/
|
|
59
|
-
export declare function toDegrees(radians: number): number;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import type { LatLngLiteral } from '../../map/lat-lng';
|
|
2
|
-
export declare function containsLocation(point: LatLngLiteral, polygon: LatLngLiteral[], geodesic: boolean): boolean;
|
|
3
|
-
/**
|
|
4
|
-
* Computes whether the given point lies inside the specified polygon.
|
|
5
|
-
* The polygon is always considered closed, regardless of whether the last point equals
|
|
6
|
-
* the first or not.
|
|
7
|
-
* Inside is defined as not containing the South Pole -- the South Pole is always outside.
|
|
8
|
-
* The polygon is formed of great circle segments if geodesic is true, and of rhumb
|
|
9
|
-
* (loxodromic) segments otherwise.
|
|
10
|
-
*/
|
|
11
|
-
export declare function containsLocationLatLng(latitude: number, longitude: number, polygon: LatLngLiteral[], geodesic: boolean): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Computes whether the given point lies on or near the edge of a polygon, within a specified
|
|
14
|
-
* tolerance in meters. The polygon edge is composed of great circle segments if geodesic
|
|
15
|
-
* is true, and of Rhumb segments otherwise. The polygon edge is implicitly closed -- the
|
|
16
|
-
* closing segment between the first point and the last point is included.
|
|
17
|
-
*/
|
|
18
|
-
export declare function isLocationOnEdge(point: LatLngLiteral, polygon: LatLngLiteral[], geodesic?: boolean, tolerance?: number): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Computes whether the given point lies on or near a polyline, within a specified
|
|
21
|
-
* tolerance in meters. The polyline is composed of great circle segments if geodesic
|
|
22
|
-
* is true, and of Rhumb segments otherwise. The polyline is not closed -- the closing
|
|
23
|
-
* segment between the first point and the last point is not included.
|
|
24
|
-
*/
|
|
25
|
-
export declare function isLocationOnPath(point: LatLngLiteral, polyline: LatLngLiteral[], geodesic?: boolean, tolerance?: number): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Computes whether (and where) a given point lies on or near a polyline, within a specified tolerance.
|
|
28
|
-
* The polyline is not closed -- the closing segment between the first point and the last point is not included.
|
|
29
|
-
*
|
|
30
|
-
* @param point our needle
|
|
31
|
-
* @param poly our haystack
|
|
32
|
-
* @param geodesic the polyline is composed of great circle segments if geodesic
|
|
33
|
-
* is true, and of Rhumb segments otherwise
|
|
34
|
-
* @param tolerance tolerance (in meters)
|
|
35
|
-
* @return -1 if point does not lie on or near the polyline.
|
|
36
|
-
* 0 if point is between poly[0] and poly[1] (inclusive),
|
|
37
|
-
* 1 if between poly[1] and poly[2],
|
|
38
|
-
* ...,
|
|
39
|
-
* poly.length-2 if between poly[poly.length - 2] and poly[poly.length - 1]
|
|
40
|
-
*/
|
|
41
|
-
export declare function locationIndexOnPath(point: LatLngLiteral, poly: LatLngLiteral[], geodesic: boolean, tolerance?: number): number;
|
|
42
|
-
/**
|
|
43
|
-
* Computes whether (and where) a given point lies on or near a polyline, within a specified tolerance.
|
|
44
|
-
* If closed, the closing segment between the last and first points of the polyline is not considered.
|
|
45
|
-
*
|
|
46
|
-
* @param point our needle
|
|
47
|
-
* @param poly our haystack
|
|
48
|
-
* @param closed whether the polyline should be considered closed by a segment connecting the last point back to the first one
|
|
49
|
-
* @param geodesic the polyline is composed of great circle segments if geodesic
|
|
50
|
-
* is true, and of Rhumb segments otherwise
|
|
51
|
-
* @param toleranceEarth tolerance (in meters)
|
|
52
|
-
* @return -1 if point does not lie on or near the polyline.
|
|
53
|
-
* 0 if point is between poly[0] and poly[1] (inclusive),
|
|
54
|
-
* 1 if between poly[1] and poly[2],
|
|
55
|
-
* ...,
|
|
56
|
-
* poly.length-2 if between poly[poly.length - 2] and poly[poly.length - 1]
|
|
57
|
-
*/
|
|
58
|
-
export declare function locationIndexOnEdgeOrPath(point: LatLngLiteral, poly: LatLngLiteral[], closed: boolean, geodesic: boolean, toleranceEarth: number): number;
|
|
59
|
-
/**
|
|
60
|
-
* Simplifies the given poly (polyline or polygon) using the Douglas-Peucker decimation
|
|
61
|
-
* algorithm. Increasing the tolerance will result in fewer points in the simplified polyline
|
|
62
|
-
* or polygon.
|
|
63
|
-
*
|
|
64
|
-
* When the providing a polygon as input, the first and last point of the list MUST have the
|
|
65
|
-
* same latitude and longitude (i.e., the polygon must be closed). If the input polygon is not
|
|
66
|
-
* closed, the resulting polygon may not be fully simplified.
|
|
67
|
-
*
|
|
68
|
-
* The time complexity of Douglas-Peucker is O(n^2), so take care that you do not call this
|
|
69
|
-
* algorithm too frequently in your code.
|
|
70
|
-
*
|
|
71
|
-
* @param poly polyline or polygon to be simplified. Polygon should be closed (i.e.,
|
|
72
|
-
* first and last points should have the same latitude and longitude).
|
|
73
|
-
* @param tolerance in meters. Increasing the tolerance will result in fewer points in the
|
|
74
|
-
* simplified poly.
|
|
75
|
-
* @return a simplified poly produced by the Douglas-Peucker algorithm
|
|
76
|
-
*/
|
|
77
|
-
export declare function simplify(poly: LatLngLiteral[], tolerance: number): LatLngLiteral[];
|
|
78
|
-
/**
|
|
79
|
-
* Returns true if the provided list of points is a closed polygon (i.e., the first and last
|
|
80
|
-
* points are the same), and false if it is not
|
|
81
|
-
*
|
|
82
|
-
* @param poly polyline or polygon
|
|
83
|
-
* @return true if the provided list of points is a closed polygon (i.e., the first and last
|
|
84
|
-
* points are the same), and false if it is not
|
|
85
|
-
*/
|
|
86
|
-
export declare function isClosedPolygon(poly: LatLngLiteral[]): boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Computes the distance on the sphere between the point p and the line segment start to end.
|
|
89
|
-
*
|
|
90
|
-
* @param p the point to be measured
|
|
91
|
-
* @param start the beginning of the line segment
|
|
92
|
-
* @param end the end of the line segment
|
|
93
|
-
* @return the distance in meters (assuming spherical earth)
|
|
94
|
-
*/
|
|
95
|
-
export declare function distanceToLine(p: LatLngLiteral, start: LatLngLiteral, end: LatLngLiteral): number;
|
|
96
|
-
/**
|
|
97
|
-
* Decodes an encoded path string into a sequence of LatLngs.
|
|
98
|
-
*/
|
|
99
|
-
export declare function decode(encodedPath: string): LatLngLiteral[];
|
|
100
|
-
/**
|
|
101
|
-
* Encodes a sequence of LatLngs into an encoded path string.
|
|
102
|
-
*/
|
|
103
|
-
export declare function encode(path: LatLngLiteral[]): string;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { LatLngLiteral } from '../../map/lat-lng';
|
|
2
|
-
/**
|
|
3
|
-
* Returns the heading from one LatLng to another LatLng. Headings are
|
|
4
|
-
* expressed in degrees clockwise from North within the range [-180,180).
|
|
5
|
-
*
|
|
6
|
-
* @return The heading in degrees clockwise from north.
|
|
7
|
-
*/
|
|
8
|
-
export declare function computeHeading(from: LatLngLiteral, to: LatLngLiteral): number;
|
|
9
|
-
/**
|
|
10
|
-
* Returns the LatLng resulting from moving a distance from an origin
|
|
11
|
-
* in the specified heading (expressed in degrees clockwise from north).
|
|
12
|
-
*
|
|
13
|
-
* @param from The LatLng from which to start.
|
|
14
|
-
* @param distance The distance to travel.
|
|
15
|
-
* @param heading The heading in degrees clockwise from north.
|
|
16
|
-
*/
|
|
17
|
-
export declare function computeOffset(from: LatLngLiteral, distance: number, heading: number): LatLngLiteral;
|
|
18
|
-
/**
|
|
19
|
-
* Returns the location of origin when provided with a LatLng destination,
|
|
20
|
-
* meters travelled and original heading. Headings are expressed in degrees
|
|
21
|
-
* clockwise from North. This function returns null when no solution is
|
|
22
|
-
* available.
|
|
23
|
-
*
|
|
24
|
-
* @param to The destination LatLng.
|
|
25
|
-
* @param distance The distance travelled, in meters.
|
|
26
|
-
* @param heading The heading in degrees clockwise from north.
|
|
27
|
-
*/
|
|
28
|
-
export declare function computeOffsetOrigin(to: LatLngLiteral, distance: number, heading: number): LatLngLiteral | null;
|
|
29
|
-
/**
|
|
30
|
-
* Returns the LatLng which lies the given fraction of the way between the
|
|
31
|
-
* origin LatLng and the destination LatLng.
|
|
32
|
-
*
|
|
33
|
-
* @param from The LatLng from which to start.
|
|
34
|
-
* @param to The LatLng toward which to travel.
|
|
35
|
-
* @param fraction A fraction of the distance to travel.
|
|
36
|
-
* @return The interpolated LatLng.
|
|
37
|
-
*/
|
|
38
|
-
export declare function interpolate(from: LatLngLiteral, to: LatLngLiteral, fraction: number): LatLngLiteral;
|
|
39
|
-
/**
|
|
40
|
-
* Returns the angle between two LatLngs, in radians. This is the same as the distance
|
|
41
|
-
* on the unit sphere.
|
|
42
|
-
*/
|
|
43
|
-
export declare function computeAngleBetween(from: LatLngLiteral, to: LatLngLiteral): number;
|
|
44
|
-
/**
|
|
45
|
-
* Returns the distance between two LatLngs, in meters.
|
|
46
|
-
*/
|
|
47
|
-
export declare function computeDistanceBetween(from: LatLngLiteral, to: LatLngLiteral): number;
|
|
48
|
-
/**
|
|
49
|
-
* Returns the length of the given path, in meters, on Earth.
|
|
50
|
-
*/
|
|
51
|
-
export declare function computeLength(path: LatLngLiteral[]): number;
|
|
52
|
-
/**
|
|
53
|
-
* Returns the area of a closed path on Earth.
|
|
54
|
-
*
|
|
55
|
-
* @param path A closed path.
|
|
56
|
-
* @return The path's area in square meters.
|
|
57
|
-
*/
|
|
58
|
-
export declare function computeArea(path: LatLngLiteral[]): number;
|
|
59
|
-
/**
|
|
60
|
-
* Returns the signed area of a closed path on Earth. The sign of the area may be used to
|
|
61
|
-
* determine the orientation of the path.
|
|
62
|
-
* "inside" is the surface that does not contain the South Pole.
|
|
63
|
-
*
|
|
64
|
-
* @param path A closed path.
|
|
65
|
-
* @return The loop's area in square meters.
|
|
66
|
-
*/
|
|
67
|
-
export declare function computeSignedArea(path: LatLngLiteral[], radius?: number): number;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export declare namespace Objects {
|
|
2
|
-
function fromArray<T>(arr: T[], keySelector: (it: T) => string): {
|
|
3
|
-
[key: string]: T;
|
|
4
|
-
};
|
|
5
|
-
function fromEntries<V>(entries: [string, V][]): {
|
|
6
|
-
[k: string]: V;
|
|
7
|
-
};
|
|
8
|
-
function toJsonSafely(value: any): string;
|
|
9
|
-
/** 删除obj中纯对象上的值为undefined的属性 */
|
|
10
|
-
function deleteUndefinedPropertyOnPlainObjectDeeply(obj: any): void;
|
|
11
|
-
/** 存在则返回, 不存在则新建 */
|
|
12
|
-
function putIfAbsent<K extends keyof any, V>(obj: Record<K, V>, key: K, ifAbsent: () => Exclude<V, undefined>): Exclude<V, undefined>;
|
|
13
|
-
/** @see Omit */
|
|
14
|
-
function omit<T, K extends keyof any>(obj: T, ...keys: K[]): Omit<T, K>;
|
|
15
|
-
/** @see Pick */
|
|
16
|
-
function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
|
|
17
|
-
/**
|
|
18
|
-
* 使用{@link keyPath}读取`obj`的字段
|
|
19
|
-
*
|
|
20
|
-
* @param keyPath `.`分隔的字段名 或 字段名数组
|
|
21
|
-
* @returns 若字段不存在, 则返回`undefined`
|
|
22
|
-
*/
|
|
23
|
-
function get(obj: any, keyPath: string | string[]): any;
|
|
24
|
-
function del(obj: any, keyPath: string | string[]): any;
|
|
25
|
-
}
|
|
26
|
-
/** 用于替代Vue2中的filter, 直接交给模板使用 */
|
|
27
|
-
export declare const stringify: typeof Objects.toJsonSafely;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { LatLngLiteral } from '../components';
|
|
2
|
-
/**
|
|
3
|
-
* 球面两点之间距离(米)
|
|
4
|
-
* @param p1
|
|
5
|
-
* @param p2
|
|
6
|
-
*/
|
|
7
|
-
declare function getDistance(p1: LatLngLiteral, p2: LatLngLiteral): number;
|
|
8
|
-
/**
|
|
9
|
-
* 已知一点经纬度,方位角,距离求另一点
|
|
10
|
-
* @param pt 点
|
|
11
|
-
* @param angle 角度
|
|
12
|
-
* @param dist 距离
|
|
13
|
-
*/
|
|
14
|
-
export declare function getDestination(pt: LatLngLiteral, angle: number, dist: number): LatLngLiteral;
|
|
15
|
-
/**
|
|
16
|
-
* 球面工具
|
|
17
|
-
*
|
|
18
|
-
* 代码copy自[CityBus-vue-admin](https://github.com/TranscodeGroup/CityBus-vue-admin/blob/8b8db7e23e94423747141084eb78ce3331965a4c/src/utils/index.js#L773), 实现似乎有些问题
|
|
19
|
-
* @deprecated 使用{@link SphericalUtil}替代
|
|
20
|
-
*/
|
|
21
|
-
export declare const SphericalUtils: {
|
|
22
|
-
/** @deprecated Use {@link SphericalUtil.computeDistanceBetween} instead */
|
|
23
|
-
getDistance: typeof getDistance;
|
|
24
|
-
/** @deprecated Use {@link SphericalUtil.computeOffset} instead */
|
|
25
|
-
getDestination: typeof getDestination;
|
|
26
|
-
};
|
|
27
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { StringEnumLike } from './mapped-types';
|
|
2
|
-
export declare namespace Strings {
|
|
3
|
-
/**
|
|
4
|
-
* 将string转换成字符枚举, 转换失败返回undefined
|
|
5
|
-
* @see {@link import('./vue-utils.ts').stringEnumProp} 由于使用了Object.values(enumObject), 应该避免在enumObject上添加其他属性/方法
|
|
6
|
-
* @deprecated 使用{@link import('./mapped-types.ts').unwrapStringEnumValue}替代
|
|
7
|
-
*/
|
|
8
|
-
function toEnumOrNull<E extends StringEnumLike>(value: string | undefined, enumObject: E): E[keyof E] | undefined;
|
|
9
|
-
function trimIndent(str: string): string;
|
|
10
|
-
/** 转换: `FuckYou` -> `fuck-you` */
|
|
11
|
-
function pascal2kebab(str: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* 简单判断字符串是否表示一个整数
|
|
14
|
-
* - `10` : ✅️
|
|
15
|
-
* - `-10`: ✅️
|
|
16
|
-
* - `+10`: ❌️
|
|
17
|
-
* - `2e2`: ❌️
|
|
18
|
-
* @see https://stackoverflow.com/questions/175739/how-can-i-check-if-a-string-is-a-valid-number
|
|
19
|
-
* */
|
|
20
|
-
function isInt(str: string): boolean;
|
|
21
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare function todo(msg?: string): never;
|
|
2
|
-
export declare function debug(msg?: any): any;
|
|
3
|
-
/**
|
|
4
|
-
* entry的value是否定义了
|
|
5
|
-
*
|
|
6
|
-
* 可以用在Array.filter(isEntryValueDef)中, 用来过滤值为空的元素
|
|
7
|
-
* @see isNotNull
|
|
8
|
-
*/
|
|
9
|
-
export declare function isEntryValueDef<K, V>(entry: [K, V]): entry is [K, NonNullable<V>];
|
|
10
|
-
/**
|
|
11
|
-
* 创建一个异步初始化的单例, 保证只初始化成功一次
|
|
12
|
-
*/
|
|
13
|
-
export declare function createAsyncSingleton<T>(creator: () => Promise<T>): () => Promise<T>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/** 键值对 */
|
|
2
|
-
export declare class KeyValue<K, V> {
|
|
3
|
-
private keyToValue;
|
|
4
|
-
private valueToKey;
|
|
5
|
-
/**
|
|
6
|
-
* `keys`和`values`数组中可以有相同的值, 若存在相同值, 则index越小的优先级越高
|
|
7
|
-
*/
|
|
8
|
-
constructor(keys: K[], values: V[]);
|
|
9
|
-
toKey(value: V): K;
|
|
10
|
-
toValue(key: K): V;
|
|
11
|
-
}
|
|
12
|
-
export type KeySelector<T, K> = (this: T) => K;
|
|
13
|
-
/** 用key快速查找元素的数组 */
|
|
14
|
-
export declare class FastFindValues<T> {
|
|
15
|
-
values: readonly T[];
|
|
16
|
-
private maxSize4Debug;
|
|
17
|
-
private map;
|
|
18
|
-
constructor(values: readonly T[], maxSize4Debug?: number);
|
|
19
|
-
/** 获取保存key-value映射的Map */
|
|
20
|
-
getValueMap<K>(keySelector: KeySelector<T, K>): Map<K, T>;
|
|
21
|
-
/**
|
|
22
|
-
* 直接用key获取value
|
|
23
|
-
* @param keySelector 从T中读取key的方法, 会用它当key, 缓存结果, 故多次调用需要使用相同的keySelector对象, 不要每次创建新的, 推荐直接使用T.prototype.getXxx作为keySelector
|
|
24
|
-
*/
|
|
25
|
-
getOrNull<K>(keySelector: KeySelector<T, K>, key: K): T | undefined;
|
|
26
|
-
get<K>(keySelector: KeySelector<T, K>, key: K): T;
|
|
27
|
-
}
|
|
28
|
-
/** 缓存的值 */
|
|
29
|
-
export declare class CachedValue<T> {
|
|
30
|
-
private creator;
|
|
31
|
-
private value;
|
|
32
|
-
constructor(creator: () => T);
|
|
33
|
-
get(): T;
|
|
34
|
-
}
|