tg-map-vue3 3.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/README.md +109 -0
- package/dist/src/components/TgMap.vue.d.ts +45 -0
- package/dist/src/components/TgMapWidget.vue.d.ts +49 -0
- package/dist/src/components/controls/TgCustomControl.vue.d.ts +16 -0
- package/dist/src/components/controls/TgMapTypeControl.vue.d.ts +14 -0
- package/dist/src/components/controls/TgScaleControl.vue.d.ts +12 -0
- package/dist/src/components/controls/TgZoomControl.vue.d.ts +12 -0
- package/dist/src/components/extra/TgMarkerClusterer.vue.d.ts +48 -0
- package/dist/src/components/index.d.ts +36 -0
- package/dist/src/components/layers/TgTrafficLayer.vue.d.ts +15 -0
- package/dist/src/components/map-mixin.d.ts +22 -0
- package/dist/src/components/overlays/TgCircle.vue.d.ts +21 -0
- package/dist/src/components/overlays/TgElementOverlay.vue.d.ts +30 -0
- package/dist/src/components/overlays/TgInfoBox.vue.d.ts +29 -0
- package/dist/src/components/overlays/TgInfoWindow.vue.d.ts +25 -0
- package/dist/src/components/overlays/TgLabel.vue.d.ts +21 -0
- package/dist/src/components/overlays/TgMarker.vue.d.ts +60 -0
- package/dist/src/components/overlays/TgPolygon.vue.d.ts +20 -0
- package/dist/src/components/overlays/TgPolyline.vue.d.ts +18 -0
- package/dist/src/map/event-target.d.ts +35 -0
- package/dist/src/map/event.d.ts +47 -0
- package/dist/src/map/lat-lng.d.ts +89 -0
- package/dist/src/map/map/baidu-map.d.ts +66 -0
- package/dist/src/map/map/controls/control.d.ts +101 -0
- package/dist/src/map/map/controls/map-type.control.d.ts +30 -0
- package/dist/src/map/map/controls/scale.control.d.ts +15 -0
- package/dist/src/map/map/controls/zoom.control.d.ts +16 -0
- package/dist/src/map/map/extra/marker-clusterer.d.ts +69 -0
- package/dist/src/map/map/google-map.d.ts +68 -0
- package/dist/src/map/map/here-map.d.ts +49 -0
- package/dist/src/map/map/map-options.d.ts +46 -0
- package/dist/src/map/map/map-type.d.ts +113 -0
- package/dist/src/map/map/map.d.ts +129 -0
- package/dist/src/map/map/overlay/baidu-info-box.d.ts +81 -0
- package/dist/src/map/map/overlay/circle.d.ts +42 -0
- package/dist/src/map/map/overlay/element-overlay.d.ts +33 -0
- package/dist/src/map/map/overlay/google-label.d.ts +74 -0
- package/dist/src/map/map/overlay/icon.d.ts +16 -0
- package/dist/src/map/map/overlay/info-box.d.ts +58 -0
- package/dist/src/map/map/overlay/info-window.d.ts +112 -0
- package/dist/src/map/map/overlay/label.d.ts +89 -0
- package/dist/src/map/map/overlay/marker.d.ts +126 -0
- package/dist/src/map/map/overlay/overlay.d.ts +38 -0
- package/dist/src/map/map/overlay/polygon.d.ts +35 -0
- package/dist/src/map/map/overlay/polyline.d.ts +35 -0
- package/dist/src/map/map/overlay/shape.d.ts +48 -0
- package/dist/src/map/map-config.d.ts +14 -0
- package/dist/src/map/map-factory.d.ts +10 -0
- package/dist/src/map/map-loader.d.ts +5 -0
- package/dist/src/map/types.d.ts +17 -0
- package/dist/src/map/unions.d.ts +19 -0
- package/dist/src/utils/arrays.d.ts +10 -0
- package/dist/src/utils/assert.d.ts +9 -0
- package/dist/src/utils/baidu-utils.d.ts +5 -0
- package/dist/src/utils/elements.d.ts +4 -0
- package/dist/src/utils/formatter.d.ts +1 -0
- package/dist/src/utils/here-utils.d.ts +10 -0
- package/dist/src/utils/lifecycle-log.d.ts +14 -0
- package/dist/src/utils/mapped-types.d.ts +60 -0
- package/dist/src/utils/objects.d.ts +13 -0
- package/dist/src/utils/strings.d.ts +9 -0
- package/dist/src/utils/utils.d.ts +9 -0
- package/dist/src/utils/values.d.ts +34 -0
- package/dist/src/utils/vue-utils.d.ts +82 -0
- package/dist/style.css +1 -0
- package/dist/tg-map.js +4871 -0
- package/dist/tg-map.js.map +1 -0
- package/dist/tg-map.umd.cjs +14 -0
- package/dist/tg-map.umd.cjs.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Tg } from './event';
|
|
2
|
+
import { type CoordTypeSupplier } from './lat-lng';
|
|
3
|
+
import type { UnionGoogleEventTarget, UnionBaiduEventTarget } from './unions';
|
|
4
|
+
/**
|
|
5
|
+
* ## Delegate(代理) VS Mixin(混合)
|
|
6
|
+
* Delegate相对于Mixin的优点是调用路径更明确, 缺点是js/ts原生不支持, 需要写样板代码
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class AbstractEventTargetDelegate<T = any> implements Tg.EventTarget {
|
|
9
|
+
protected inner: T;
|
|
10
|
+
protected coordTypeSupplier: CoordTypeSupplier;
|
|
11
|
+
protected eventMap: Map<string, any>;
|
|
12
|
+
protected target: Tg.EventTarget;
|
|
13
|
+
constructor(inner: T, coordTypeSupplier: CoordTypeSupplier);
|
|
14
|
+
setTarget(target: Tg.EventTarget): this;
|
|
15
|
+
abstract addEventListener(type: string, listener: Tg.EventListener): void;
|
|
16
|
+
abstract removeEventListener(type: string, listener: Tg.EventListener): void;
|
|
17
|
+
}
|
|
18
|
+
export declare class GoogleEventTargetDelegate<T extends UnionGoogleEventTarget = UnionGoogleEventTarget> extends AbstractEventTargetDelegate<T> {
|
|
19
|
+
private static EVENT_TYPE_MAP;
|
|
20
|
+
addEventListener(type: string, listener: Tg.EventListener): void;
|
|
21
|
+
removeEventListener(type: string, listener: Tg.EventListener): void;
|
|
22
|
+
}
|
|
23
|
+
export declare class BaiduEventTargetDelegate<T extends UnionBaiduEventTarget = UnionBaiduEventTarget> extends AbstractEventTargetDelegate<T> {
|
|
24
|
+
private static EVENT_TYPE_MAP;
|
|
25
|
+
addEventListener(type: string, listener: Tg.EventListener): void;
|
|
26
|
+
removeEventListener(type: string, listener: Tg.EventListener): void;
|
|
27
|
+
}
|
|
28
|
+
/** 手动维护事件 */
|
|
29
|
+
export declare class EventHub implements Tg.EventTarget {
|
|
30
|
+
private typeMap;
|
|
31
|
+
addEventListener(type: string, listener: Tg.EventListener): void;
|
|
32
|
+
removeEventListener(type: string, listener: Tg.EventListener): void;
|
|
33
|
+
hasListener(type: string): boolean;
|
|
34
|
+
notify(event: Tg.Event): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { LatLng } from './lat-lng';
|
|
2
|
+
import type { ComponentPublicInstance } from './@vue/compat';
|
|
3
|
+
/**
|
|
4
|
+
* ## 事件机制对比
|
|
5
|
+
* - DOM: add/removeEventListener, Event {type, target}
|
|
6
|
+
* - Vue: $on/$off, 没有Event, listener直接接收数据
|
|
7
|
+
* - baidu: 模仿DOM
|
|
8
|
+
* - here: 模仿DOM
|
|
9
|
+
* - google: addListener+remove, 没有Event, listener直接接收数据
|
|
10
|
+
*
|
|
11
|
+
* 综合对比之后, 决定模仿DOM的事件机制
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace Tg {
|
|
14
|
+
interface Event {
|
|
15
|
+
type: string;
|
|
16
|
+
target: EventTarget;
|
|
17
|
+
originalEvent?: any;
|
|
18
|
+
}
|
|
19
|
+
interface MouseEvent extends Event {
|
|
20
|
+
position: LatLng;
|
|
21
|
+
}
|
|
22
|
+
interface EventListener {
|
|
23
|
+
(this: EventTarget, event: Event): void;
|
|
24
|
+
/** 唯一id */
|
|
25
|
+
__id__?: number;
|
|
26
|
+
}
|
|
27
|
+
interface EventTarget {
|
|
28
|
+
addEventListener(type: string, listener: EventListener): void;
|
|
29
|
+
removeEventListener(type: string, listener: EventListener): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 拥有更详细的类型信息
|
|
33
|
+
* @see EventTarget
|
|
34
|
+
* */
|
|
35
|
+
interface EventTargetTyped<THIS extends EventTarget, MAP extends {
|
|
36
|
+
[k: string]: Event;
|
|
37
|
+
}> extends EventTarget {
|
|
38
|
+
addEventListener<K extends keyof MAP>(type: K, listener: (this: THIS, event: MAP[K]) => void): void;
|
|
39
|
+
removeEventListener<K extends keyof MAP>(type: K, listener: (this: THIS, event: MAP[K]) => void): void;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export declare function bindEvents(this: ComponentPublicInstance, target: Tg.EventTarget, excludes?: string[]): void;
|
|
43
|
+
export declare function generateNextEventListenerId(): number;
|
|
44
|
+
/**
|
|
45
|
+
* JS的Map/object的key都不支持自定义hashCode()/equals(), 故只能生成字符串当作key
|
|
46
|
+
*/
|
|
47
|
+
export declare function generateEventKey(type: string, listener: Tg.EventListener): string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
/// <reference types="googlemaps" />
|
|
3
|
+
/// <reference types="heremaps" />
|
|
4
|
+
import { type LngLatTuple } from 'coordtransform';
|
|
5
|
+
export declare enum CoordType {
|
|
6
|
+
wgs84 = "wgs84",
|
|
7
|
+
gcj02 = "gcj02",
|
|
8
|
+
bd09 = "bd09"
|
|
9
|
+
}
|
|
10
|
+
export interface CoordTypeSupplier {
|
|
11
|
+
readonly coordType: CoordType;
|
|
12
|
+
}
|
|
13
|
+
export interface LatLngLiteral {
|
|
14
|
+
readonly lat: number;
|
|
15
|
+
readonly lng: number;
|
|
16
|
+
readonly coord?: CoordType;
|
|
17
|
+
}
|
|
18
|
+
export declare class LatLng {
|
|
19
|
+
readonly lat: number;
|
|
20
|
+
readonly lng: number;
|
|
21
|
+
readonly coord: CoordType;
|
|
22
|
+
static ZERO: LatLng;
|
|
23
|
+
/** @param coord Baidu Map的坐标一般都是bd09 */
|
|
24
|
+
static fromBaidu(point: BMap.Point, coord: CoordType): LatLng;
|
|
25
|
+
/** @param coord Google Map的坐标依据地图类型不同是不一样的 */
|
|
26
|
+
static fromGoogle(latlng: google.maps.LatLng, coord: CoordType): LatLng;
|
|
27
|
+
static fromHere(point: H.geo.IPoint, coord: CoordType): LatLng;
|
|
28
|
+
static fromLiteral(latlng: LatLngLiteral): LatLng;
|
|
29
|
+
static fromLngLat(lng: number, lat: number, coord?: CoordType): LatLng;
|
|
30
|
+
static create(lat: number, lng: number, coord?: CoordType): LatLng;
|
|
31
|
+
constructor(lat: number, lng: number, coord: CoordType);
|
|
32
|
+
to(coord: CoordType): LatLng;
|
|
33
|
+
toBaidu(coord: CoordType): BMap.Point;
|
|
34
|
+
toGoogle(coord: CoordType): google.maps.LatLng;
|
|
35
|
+
toHere(coord: CoordType): H.geo.Point;
|
|
36
|
+
/**
|
|
37
|
+
* 该方法之所以设计的这么不友好, 是为了防止不必要的开销(大概有点影响😅)
|
|
38
|
+
*
|
|
39
|
+
* @returns `[lng, lat]` 注意不要取错顺序
|
|
40
|
+
* @throws 若当前coord和targetCoord相同, 会抛异常, 故请在外部判断
|
|
41
|
+
*/
|
|
42
|
+
convert(targetCoord: CoordType): LngLatTuple;
|
|
43
|
+
equals(other: LatLng): boolean;
|
|
44
|
+
toString(): string;
|
|
45
|
+
}
|
|
46
|
+
/** 少数接口同时支持对象形式和字面量形式 */
|
|
47
|
+
export type LatLngType = LatLng | LatLngLiteral;
|
|
48
|
+
/**
|
|
49
|
+
* 反编译自{@link com.google.android.gms.maps.model.LatLngBounds}
|
|
50
|
+
*/
|
|
51
|
+
export declare class LatLngBounds {
|
|
52
|
+
sw: LatLng;
|
|
53
|
+
ne: LatLng;
|
|
54
|
+
static EMPTY: LatLngBounds;
|
|
55
|
+
static isBetweenLng(minLng: number, maxLng: number, lng: number): boolean;
|
|
56
|
+
static fromArray(positions: readonly LatLng[]): LatLngBounds | undefined;
|
|
57
|
+
static from(...positions: LatLng[]): LatLngBounds;
|
|
58
|
+
static fromGoogle(bounds: google.maps.LatLngBounds, coord: CoordType): LatLngBounds;
|
|
59
|
+
static fromBaidu(bounds: BMap.Bounds, coord: CoordType): LatLngBounds;
|
|
60
|
+
static create(sw: LatLng, ne: LatLng): LatLngBounds;
|
|
61
|
+
coord: CoordType;
|
|
62
|
+
/**
|
|
63
|
+
* 不推荐直接创建LatLngBounds, sw和ne的大小关系可能没法保证, 推荐用LatLngBounds.Builder或者LatLngBounds.from等静态方法来创建
|
|
64
|
+
* @param sw 西南, lat/lng更小
|
|
65
|
+
* @param ne 东北, lat/lng更大
|
|
66
|
+
*/
|
|
67
|
+
constructor(sw: LatLng, ne: LatLng);
|
|
68
|
+
isEmpty(): boolean;
|
|
69
|
+
contains(position: LatLng): boolean;
|
|
70
|
+
getCenter(): LatLng;
|
|
71
|
+
toString(): string;
|
|
72
|
+
equals(other: LatLngBounds): boolean;
|
|
73
|
+
toGoogle(coord: CoordType): google.maps.LatLngBounds;
|
|
74
|
+
toBaidu(coord: CoordType): BMap.Bounds;
|
|
75
|
+
toBaiduArray(coord: CoordType): BMap.Point[];
|
|
76
|
+
}
|
|
77
|
+
export declare namespace LatLngBounds {
|
|
78
|
+
class Builder {
|
|
79
|
+
private coord;
|
|
80
|
+
private minLat;
|
|
81
|
+
private minLng;
|
|
82
|
+
private maxLat;
|
|
83
|
+
private maxLng;
|
|
84
|
+
constructor(start: LatLng);
|
|
85
|
+
build(): LatLngBounds;
|
|
86
|
+
include(position: LatLng): this;
|
|
87
|
+
private delta;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { LatLng, LatLngBounds } from '../lat-lng';
|
|
2
|
+
import { AbstractMap, type AbstractMapEventMap } from './map';
|
|
3
|
+
import { MapOptions, GestureHandlingOptions, type MapStyle } from './map-options';
|
|
4
|
+
import type { BaiduOverlay } from './overlay/overlay';
|
|
5
|
+
import { BaiduMarkerClusterer, type MarkerClustererOptions } from './extra/marker-clusterer';
|
|
6
|
+
import { BaiduPolyline } from './overlay/polyline';
|
|
7
|
+
import { BaiduPolygon } from './overlay/polygon';
|
|
8
|
+
import { BaiduCircle } from './overlay/circle';
|
|
9
|
+
import { CustomControl } from './controls/control';
|
|
10
|
+
import { BaiduMapTypeControl } from './controls/map-type.control';
|
|
11
|
+
import { BaiduZoomControl } from './controls/zoom.control';
|
|
12
|
+
import { BaiduScaleControl } from './controls/scale.control';
|
|
13
|
+
import { BaiduMarker } from './overlay/marker';
|
|
14
|
+
import { BaiduInfoWindow } from './overlay/info-window';
|
|
15
|
+
import { BuildInMapTypeId, MapType, type Layer } from './map-type';
|
|
16
|
+
import type { Padding, Point } from '../types';
|
|
17
|
+
import { BaiduLabelOverlay } from './overlay/label';
|
|
18
|
+
import { BaiduInfoBoxOverlay } from './overlay/info-box';
|
|
19
|
+
import type { ElementOverlay } from './overlay/element-overlay';
|
|
20
|
+
export declare class BaiduMap extends AbstractMap {
|
|
21
|
+
setDefaultCursor(cursor: string): void;
|
|
22
|
+
private buildInMapTypeId2BIMT;
|
|
23
|
+
private baiduMapType2BIMT;
|
|
24
|
+
private map;
|
|
25
|
+
constructor(element: HTMLElement, mapOptions: MapOptions);
|
|
26
|
+
setGestureHandling(gestureHandling?: GestureHandlingOptions): void;
|
|
27
|
+
get innerMap(): BMap.Map;
|
|
28
|
+
get coordType(): import("../lat-lng").CoordType;
|
|
29
|
+
addEventListener<K extends keyof AbstractMapEventMap>(type: K, listener: (event: AbstractMapEventMap[K]) => void): void;
|
|
30
|
+
removeEventListener<K extends keyof AbstractMapEventMap>(type: K, listener: (event: AbstractMapEventMap[K]) => void): void;
|
|
31
|
+
fromContainerPointToLatLng(point: Point): LatLng;
|
|
32
|
+
fromLatLngToContainerPoint(latLng: LatLng): Point;
|
|
33
|
+
setDraggable(draggable: boolean): void;
|
|
34
|
+
setDisableDoubleClickZoom(type: boolean): void;
|
|
35
|
+
getCenter(): LatLng;
|
|
36
|
+
setCenter(latlng: LatLng): void;
|
|
37
|
+
setMinZoom(zoom: number): void;
|
|
38
|
+
setMaxZoom(zoom: number): void;
|
|
39
|
+
setMapStyle(mapStyle: MapStyle): void;
|
|
40
|
+
setBuildInMapTypeId(id: BuildInMapTypeId): void;
|
|
41
|
+
setMapType(mapType: MapType): void;
|
|
42
|
+
getMapType(): MapType;
|
|
43
|
+
addLayer(layer: Layer): void;
|
|
44
|
+
removeLayer(layer: Layer): void;
|
|
45
|
+
panTo(position: LatLng): void;
|
|
46
|
+
panBy(x: number, y: number): void;
|
|
47
|
+
fitBounds(bounds: LatLngBounds, padding?: Padding): void;
|
|
48
|
+
getBounds(): LatLngBounds;
|
|
49
|
+
addElementOverlay(overlay: ElementOverlay): void;
|
|
50
|
+
removeElementOverlay(overlay: ElementOverlay): void;
|
|
51
|
+
addOverlay(overlay: BaiduOverlay): void;
|
|
52
|
+
removeOverlay(overlay: BaiduOverlay): void;
|
|
53
|
+
addCustomControl(control: CustomControl): void;
|
|
54
|
+
removeCustomControl(control: CustomControl): void;
|
|
55
|
+
createLabel: typeof BaiduLabelOverlay.create;
|
|
56
|
+
createCircle: typeof BaiduCircle.create;
|
|
57
|
+
createPolygon: typeof BaiduPolygon.create;
|
|
58
|
+
createPolyline: typeof BaiduPolyline.create;
|
|
59
|
+
createInfoWindow: typeof BaiduInfoWindow.create;
|
|
60
|
+
createInfoBox: typeof BaiduInfoBoxOverlay.create;
|
|
61
|
+
createMarker: typeof BaiduMarker.create;
|
|
62
|
+
createMapTypeControl: typeof BaiduMapTypeControl.create;
|
|
63
|
+
createZoomControl: typeof BaiduZoomControl.create;
|
|
64
|
+
createScaleControl: typeof BaiduScaleControl.create;
|
|
65
|
+
createMarkerClusterer(options: MarkerClustererOptions): BaiduMarkerClusterer;
|
|
66
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/// <reference types="googlemaps" />
|
|
2
|
+
import type { UnionControl } from '../../unions';
|
|
3
|
+
import { KeyValue } from '../../../utils/values';
|
|
4
|
+
import type { GoogleMap } from '../google-map';
|
|
5
|
+
import type { BaiduMap } from '../baidu-map';
|
|
6
|
+
import type { AbstractMap } from '../map';
|
|
7
|
+
export declare enum ControlPosition {
|
|
8
|
+
/** 左上 */
|
|
9
|
+
TOP_LEFT = "top-left",
|
|
10
|
+
TOP_CENTER = "top-center",
|
|
11
|
+
/** 右上 */
|
|
12
|
+
TOP_RIGHT = "top-right",
|
|
13
|
+
BOTTOM_LEFT = "bottom-left",
|
|
14
|
+
BOTTOM_CENTER = "bottom-center",
|
|
15
|
+
BOTTOM_RIGHT = "bottom-right",
|
|
16
|
+
LEFT_TOP = "left-top",
|
|
17
|
+
LEFT_CENTER = "left-center",
|
|
18
|
+
/** 左下 */
|
|
19
|
+
LEFT_BOTTOM = "left-bottom",
|
|
20
|
+
RIGHT_TOP = "right-top",
|
|
21
|
+
RIGHT_CENTER = "right-center",
|
|
22
|
+
/** 右下 */
|
|
23
|
+
RIGHT_BOTTOM = "right-bottom"
|
|
24
|
+
}
|
|
25
|
+
export declare namespace ControlPositionConverter {
|
|
26
|
+
function getBaidu(): KeyValue<ControlPosition, number>;
|
|
27
|
+
function getGoogle(): KeyValue<ControlPosition, google.maps.ControlPosition>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 自定义的Control
|
|
31
|
+
* @see BaiduMap.addCustomControl
|
|
32
|
+
* @see GoogleMap.addCustomControl
|
|
33
|
+
* */
|
|
34
|
+
export declare abstract class CustomControl {
|
|
35
|
+
position: ControlPosition;
|
|
36
|
+
/** 实际添加到地图中的control对象 */
|
|
37
|
+
inner?: UnionControl;
|
|
38
|
+
constructor(position: ControlPosition);
|
|
39
|
+
/** 创建UI元素 */
|
|
40
|
+
abstract onCreateElement(): HTMLElement;
|
|
41
|
+
}
|
|
42
|
+
/** 内置的Control */
|
|
43
|
+
export declare abstract class AbstractControl {
|
|
44
|
+
abstract isVisible(): boolean;
|
|
45
|
+
abstract setVisible(visible: boolean): void;
|
|
46
|
+
abstract getPosition(): ControlPosition;
|
|
47
|
+
abstract setPosition(position: ControlPosition): void;
|
|
48
|
+
abstract addTo(map: AbstractMap): void;
|
|
49
|
+
abstract removeFrom(map: AbstractMap): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* baidu内置的Control
|
|
53
|
+
* - NavigationControl
|
|
54
|
+
* - OverviewMapControl
|
|
55
|
+
* - ScaleControl
|
|
56
|
+
* - MapTypeControl
|
|
57
|
+
* - CopyrightControl
|
|
58
|
+
* - GeolocationControl
|
|
59
|
+
*/
|
|
60
|
+
export declare class BaiduControl<CONTROL extends BMap.Control = BMap.Control> extends AbstractControl {
|
|
61
|
+
private inner;
|
|
62
|
+
/** 由于@tg/map的position和baidu的position是多对一的关系, 为了防止set后再get, 得到不同的值, 应该用this.position保存set的值 */
|
|
63
|
+
private position?;
|
|
64
|
+
constructor(inner: CONTROL,
|
|
65
|
+
/** 由于@tg/map的position和baidu的position是多对一的关系, 为了防止set后再get, 得到不同的值, 应该用this.position保存set的值 */
|
|
66
|
+
position?: ControlPosition | undefined);
|
|
67
|
+
isVisible(): boolean;
|
|
68
|
+
setVisible(visible: boolean): void;
|
|
69
|
+
getPosition(): ControlPosition;
|
|
70
|
+
setPosition(position: ControlPosition): void;
|
|
71
|
+
addTo(map: BaiduMap): void;
|
|
72
|
+
removeFrom(map: BaiduMap): void;
|
|
73
|
+
}
|
|
74
|
+
export type GoogleControlType = 'zoom' | 'mapType' | 'scale' | 'streetView' | 'rotate' | 'fullscreen';
|
|
75
|
+
/**
|
|
76
|
+
* google内置的Control
|
|
77
|
+
* - ZoomControl
|
|
78
|
+
* - MapTypeControl
|
|
79
|
+
* - ScaleControl
|
|
80
|
+
* - StreetViewControl
|
|
81
|
+
* - RotateControl
|
|
82
|
+
* - FullscreenControl
|
|
83
|
+
*/
|
|
84
|
+
export declare class GoogleControl extends AbstractControl {
|
|
85
|
+
private _type;
|
|
86
|
+
/** 每种类型的position的初始值不一样, 需要外部传入 */
|
|
87
|
+
private position;
|
|
88
|
+
visible: boolean;
|
|
89
|
+
private map;
|
|
90
|
+
constructor(_type: GoogleControlType,
|
|
91
|
+
/** 每种类型的position的初始值不一样, 需要外部传入 */
|
|
92
|
+
position: ControlPosition);
|
|
93
|
+
isVisible(): boolean;
|
|
94
|
+
setVisible(visible: boolean): void;
|
|
95
|
+
getPosition(): ControlPosition;
|
|
96
|
+
setPosition(position: ControlPosition): void;
|
|
97
|
+
addTo(map: GoogleMap): void;
|
|
98
|
+
removeFrom(): void;
|
|
99
|
+
protected onCreateOptions(): any;
|
|
100
|
+
protected tryUpdateOptions(): void;
|
|
101
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
import { BaiduControl, GoogleControl, ControlPosition, AbstractControl } from './control';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
import type { GoogleMap } from '../google-map';
|
|
5
|
+
import { MapType } from '../map-type';
|
|
6
|
+
export interface MapTypeControl extends AbstractControl {
|
|
7
|
+
}
|
|
8
|
+
export declare enum MapTypeControlType {
|
|
9
|
+
DEFAULT = "default",
|
|
10
|
+
HORIZONTAL = "horizontal",
|
|
11
|
+
DROPDOWN = "dropdown"
|
|
12
|
+
}
|
|
13
|
+
export interface MapTypeControlOptions {
|
|
14
|
+
position?: ControlPosition;
|
|
15
|
+
type?: MapTypeControlType;
|
|
16
|
+
/** @default MAP_TYPES_DEFAULT 这有这些mapTypes才是各种地图都兼容的 */
|
|
17
|
+
mapTypes?: MapType[];
|
|
18
|
+
}
|
|
19
|
+
export declare class BaiduMapTypeControl extends BaiduControl<BMap.MapTypeControl> implements MapTypeControl {
|
|
20
|
+
static create(this: BaiduMap, options: MapTypeControlOptions): BaiduMapTypeControl;
|
|
21
|
+
}
|
|
22
|
+
export declare class GoogleMapTypeControl extends GoogleControl implements MapTypeControl {
|
|
23
|
+
type: MapTypeControlType;
|
|
24
|
+
private mapTypes;
|
|
25
|
+
static create(this: GoogleMap, options: MapTypeControlOptions): GoogleMapTypeControl;
|
|
26
|
+
private static type2google;
|
|
27
|
+
constructor(type?: MapTypeControlType, position?: ControlPosition, mapTypes?: MapType[]);
|
|
28
|
+
onCreateOptions(): any;
|
|
29
|
+
addTo(map: GoogleMap): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaiduControl, GoogleControl, ControlPosition, AbstractControl } from './control';
|
|
2
|
+
import type { GoogleMap } from '../google-map';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
export interface ScaleControl extends AbstractControl {
|
|
5
|
+
}
|
|
6
|
+
export interface ScaleControlOptions {
|
|
7
|
+
position?: ControlPosition;
|
|
8
|
+
}
|
|
9
|
+
export declare class BaiduScaleControl extends BaiduControl implements ScaleControl {
|
|
10
|
+
static create(this: BaiduMap, options: ScaleControlOptions): BaiduScaleControl;
|
|
11
|
+
}
|
|
12
|
+
export declare class GoogleScaleControl extends GoogleControl implements ScaleControl {
|
|
13
|
+
static create(this: GoogleMap, options: ScaleControlOptions): GoogleScaleControl;
|
|
14
|
+
constructor(position?: ControlPosition);
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
import { BaiduControl, GoogleControl, ControlPosition, AbstractControl } from './control';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
import type { GoogleMap } from '../google-map';
|
|
5
|
+
export interface ZoomControl extends AbstractControl {
|
|
6
|
+
}
|
|
7
|
+
export interface ZoomControlOptions {
|
|
8
|
+
position?: ControlPosition;
|
|
9
|
+
}
|
|
10
|
+
export declare class BaiduZoomControl extends BaiduControl<BMap.NavigationControl> implements ZoomControl {
|
|
11
|
+
static create(this: BaiduMap, options: ZoomControlOptions): BaiduZoomControl;
|
|
12
|
+
}
|
|
13
|
+
export declare class GoogleZoomControl extends GoogleControl implements ZoomControl {
|
|
14
|
+
static create(this: GoogleMap, options: ZoomControlOptions): GoogleZoomControl;
|
|
15
|
+
constructor(position?: ControlPosition);
|
|
16
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { AbstractMap } from '../map';
|
|
2
|
+
import type { GoogleMap } from '../google-map';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
import type { MarkerOverlay } from '../overlay/marker';
|
|
5
|
+
import type { Size, Point } from '../../types';
|
|
6
|
+
export interface MarkerClustererOptions {
|
|
7
|
+
markers?: MarkerOverlay[];
|
|
8
|
+
gridSize?: number;
|
|
9
|
+
maxZoom?: number;
|
|
10
|
+
minClusterSize?: number;
|
|
11
|
+
averageCenter?: boolean;
|
|
12
|
+
styles?: ClusterIconStyle[];
|
|
13
|
+
stylesIndexCalculator?: (markersLength: number, stylesLength: number) => number;
|
|
14
|
+
zIndex?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ClusterIconStyle {
|
|
17
|
+
url: string;
|
|
18
|
+
size: Size;
|
|
19
|
+
anchor?: Point;
|
|
20
|
+
offset?: Point;
|
|
21
|
+
textColor?: string;
|
|
22
|
+
textSize?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* ## GMarkerClusterer 和 BMarkerClusterer 的区别
|
|
26
|
+
*
|
|
27
|
+
* GMarkerClusterer
|
|
28
|
+
* - resetViewport(): 移除
|
|
29
|
+
* - redraw(): 绘制新的
|
|
30
|
+
* - repaint(): 先移除, 再绘制
|
|
31
|
+
* - setXxx(): 只修改值, 不触发repaint()
|
|
32
|
+
* - add/removeMarker/s(): 接收`opt_nodraw`参数, 为true时不触发redraw/repaint()
|
|
33
|
+
* - clearMarkers(): 只有clear才会将marker从map上移除
|
|
34
|
+
*
|
|
35
|
+
* BMarkerClusterer
|
|
36
|
+
* - _clearLastClusters(): 移除
|
|
37
|
+
* - _createClusters(): 绘制新的
|
|
38
|
+
* - _redraw(): 先移除, 再重绘
|
|
39
|
+
* - setXxx(): 修改值, 同时触发_redraw()
|
|
40
|
+
* - add/removeMarker/s(): 每次都触发_redraw/_createClusters()
|
|
41
|
+
* - clearMarkers(): 同GMarkerClusterer
|
|
42
|
+
*
|
|
43
|
+
* H.clustering.Provider(here的点聚合工具类)
|
|
44
|
+
* - 和baidu/google的api有很大不同, 但总体倾向于baidu的实现, 每次修改坐标点都触发重新计算点聚合
|
|
45
|
+
*/
|
|
46
|
+
export declare abstract class MarkerClusterer {
|
|
47
|
+
map: AbstractMap;
|
|
48
|
+
inner: any;
|
|
49
|
+
constructor(map: AbstractMap);
|
|
50
|
+
/** baidu/google 拥有相同的函数名 */
|
|
51
|
+
clearMarkers(): void;
|
|
52
|
+
/** @see clearMarkers */
|
|
53
|
+
addMarker(marker: MarkerOverlay): void;
|
|
54
|
+
/** @see clearMarkers */
|
|
55
|
+
removeMarker(marker: MarkerOverlay): boolean;
|
|
56
|
+
/** @see clearMarkers */
|
|
57
|
+
addMarkers(markers: MarkerOverlay[]): void;
|
|
58
|
+
/** @see clearMarkers */
|
|
59
|
+
removeMarkers(markers: MarkerOverlay[]): boolean;
|
|
60
|
+
abstract recreate(): void;
|
|
61
|
+
}
|
|
62
|
+
export declare class BaiduMarkerClusterer extends MarkerClusterer {
|
|
63
|
+
constructor(map: BaiduMap, options: MarkerClustererOptions);
|
|
64
|
+
recreate(): void;
|
|
65
|
+
}
|
|
66
|
+
export declare class GoogleMarkerClusterer extends MarkerClusterer {
|
|
67
|
+
constructor(map: GoogleMap, options: MarkerClustererOptions);
|
|
68
|
+
recreate(): void;
|
|
69
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/// <reference types="googlemaps" />
|
|
2
|
+
import { LatLng, LatLngBounds } from '../lat-lng';
|
|
3
|
+
import { AbstractMap } from './map';
|
|
4
|
+
import type { MapOptions, GestureHandlingOptions, MapStyle } from './map-options';
|
|
5
|
+
import type { GoogleOverlay } from './overlay/overlay';
|
|
6
|
+
import { type MarkerClustererOptions, GoogleMarkerClusterer } from './extra/marker-clusterer';
|
|
7
|
+
import { GooglePolyline } from './overlay/polyline';
|
|
8
|
+
import { GooglePolygon } from './overlay/polygon';
|
|
9
|
+
import { GoogleCircle } from './overlay/circle';
|
|
10
|
+
import { CustomControl } from './controls/control';
|
|
11
|
+
import { GoogleMapTypeControl } from './controls/map-type.control';
|
|
12
|
+
import { GoogleZoomControl } from './controls/zoom.control';
|
|
13
|
+
import { GoogleScaleControl } from './controls/scale.control';
|
|
14
|
+
import { GoogleMarker } from './overlay/marker';
|
|
15
|
+
import { GoogleInfoWindow } from './overlay/info-window';
|
|
16
|
+
import { BuildInMapTypeId, MapType, type Layer, type OverlayMapType } from './map-type';
|
|
17
|
+
import { type Padding, Point } from '../types';
|
|
18
|
+
import { GoogleLabelOverlay } from './overlay/label';
|
|
19
|
+
import { GoogleInfoBoxOverlay } from './overlay/info-box';
|
|
20
|
+
import type { ElementOverlay } from './overlay/element-overlay';
|
|
21
|
+
export declare class GoogleMap extends AbstractMap {
|
|
22
|
+
mapOptions: MapOptions;
|
|
23
|
+
setDefaultCursor(cursor: string): void;
|
|
24
|
+
private buildInMapTypeId2BIMT;
|
|
25
|
+
private googleMapTypeId2BIMT;
|
|
26
|
+
private map;
|
|
27
|
+
constructor(element: HTMLElement, mapOptions: MapOptions);
|
|
28
|
+
setGestureHandling(gestureHandling?: GestureHandlingOptions): void;
|
|
29
|
+
get innerMap(): google.maps.Map;
|
|
30
|
+
get coordType(): import("../lat-lng").CoordType;
|
|
31
|
+
fromContainerPointToLatLng(point: Point): LatLng;
|
|
32
|
+
fromLatLngToContainerPoint(latLng: LatLng): Point;
|
|
33
|
+
setDraggable(draggable: boolean): void;
|
|
34
|
+
setDisableDoubleClickZoom(type: boolean): void;
|
|
35
|
+
getCenter(): LatLng;
|
|
36
|
+
setCenter(latlng: LatLng): void;
|
|
37
|
+
setMinZoom(zoom: number): void;
|
|
38
|
+
setMaxZoom(zoom: number): void;
|
|
39
|
+
setMapStyle(mapStyle: MapStyle): void;
|
|
40
|
+
setBuildInMapTypeId(id: BuildInMapTypeId): void;
|
|
41
|
+
setMapType(mapType: MapType): void;
|
|
42
|
+
getMapType(): MapType;
|
|
43
|
+
addOverlayMapType(mapType: OverlayMapType): void;
|
|
44
|
+
removeOverlayMapType(mapType: OverlayMapType): void;
|
|
45
|
+
addLayer(layer: Layer): void;
|
|
46
|
+
removeLayer(layer: Layer): void;
|
|
47
|
+
panTo(position: LatLng): void;
|
|
48
|
+
panBy(x: number, y: number): void;
|
|
49
|
+
fitBounds(bounds: LatLngBounds, padding?: Padding): void;
|
|
50
|
+
getBounds(): LatLngBounds;
|
|
51
|
+
addElementOverlay(overlay: ElementOverlay): void;
|
|
52
|
+
removeElementOverlay(overlay: ElementOverlay): void;
|
|
53
|
+
addOverlay(overlay: GoogleOverlay): void;
|
|
54
|
+
removeOverlay(overlay: GoogleOverlay): void;
|
|
55
|
+
addCustomControl(control: CustomControl): void;
|
|
56
|
+
removeCustomControl(control: CustomControl): void;
|
|
57
|
+
createLabel: typeof GoogleLabelOverlay.create;
|
|
58
|
+
createCircle: typeof GoogleCircle.create;
|
|
59
|
+
createPolygon: typeof GooglePolygon.create;
|
|
60
|
+
createPolyline: typeof GooglePolyline.create;
|
|
61
|
+
createInfoWindow: typeof GoogleInfoWindow.create;
|
|
62
|
+
createInfoBox: typeof GoogleInfoBoxOverlay.create;
|
|
63
|
+
createMarker: typeof GoogleMarker.create;
|
|
64
|
+
createMapTypeControl: typeof GoogleMapTypeControl.create;
|
|
65
|
+
createZoomControl: typeof GoogleZoomControl.create;
|
|
66
|
+
createScaleControl: typeof GoogleScaleControl.create;
|
|
67
|
+
createMarkerClusterer(options: MarkerClustererOptions): GoogleMarkerClusterer;
|
|
68
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="heremaps" />
|
|
2
|
+
import { AbstractMap } from './map';
|
|
3
|
+
import type { MapOptions } from './map-options';
|
|
4
|
+
import { CoordType, LatLng } from '../lat-lng';
|
|
5
|
+
export declare class HereMap extends AbstractMap {
|
|
6
|
+
mapOptions: MapOptions;
|
|
7
|
+
setDefaultCursor(cursor: string): void;
|
|
8
|
+
private map;
|
|
9
|
+
defaultLayers: H.service.DefaultLayers;
|
|
10
|
+
constructor(element: HTMLElement, mapOptions: MapOptions);
|
|
11
|
+
get innerMap(): H.Map;
|
|
12
|
+
get coordType(): CoordType;
|
|
13
|
+
getCenter(): LatLng;
|
|
14
|
+
setCenter(latlng: LatLng): void;
|
|
15
|
+
setDraggable(draggable: boolean): void;
|
|
16
|
+
setDisableDoubleClickZoom(type: boolean): void;
|
|
17
|
+
fromContainerPointToLatLng(point: import('../types').Point): LatLng;
|
|
18
|
+
fromLatLngToContainerPoint(latLng: LatLng): import('../types').Point;
|
|
19
|
+
addElementOverlay(overlay: import('./overlay/element-overlay').ElementOverlay): void;
|
|
20
|
+
removeElementOverlay(overlay: import('./overlay/element-overlay').ElementOverlay): void;
|
|
21
|
+
createInfoBox(options: import('./overlay/info-box').InfoBoxOptions): import('./overlay/info-box').InfoBoxOverlay;
|
|
22
|
+
createLabel(options: import('./overlay/label').LabelOptions): import('./overlay/label').LabelOverlay;
|
|
23
|
+
fitBounds(bounds: import('../lat-lng').LatLngBounds, padding?: import('../types').Padding): void;
|
|
24
|
+
getBounds(): import('../lat-lng').LatLngBounds;
|
|
25
|
+
panTo(position: LatLng): void;
|
|
26
|
+
panBy(x: number, y: number): void;
|
|
27
|
+
setBuildInMapTypeId(id: import('./map-type').BuildInMapTypeId): void;
|
|
28
|
+
setMapType(mapType: import('./map-type').MapType): void;
|
|
29
|
+
getMapType(): import('./map-type').MapType;
|
|
30
|
+
addLayer(layer: import('./map-type').Layer): void;
|
|
31
|
+
removeLayer(layer: import('./map-type').Layer): void;
|
|
32
|
+
setGestureHandling(gestureHandling: import('./map-options').GestureHandlingOptions): void;
|
|
33
|
+
setMinZoom(zoom: number): void;
|
|
34
|
+
setMaxZoom(zoom: number): void;
|
|
35
|
+
setMapStyle(mapStyle: import('./map-options').MapStyle): void;
|
|
36
|
+
addOverlay(overlay: import('./overlay/overlay').Overlay<unknown>): void;
|
|
37
|
+
removeOverlay(overlay: import('./overlay/overlay').Overlay<unknown>): void;
|
|
38
|
+
createMarker(options: import('./overlay/marker').MarkerOptions): import('./overlay/marker').MarkerOverlay;
|
|
39
|
+
createMarkerClusterer(options: import('./extra/marker-clusterer').MarkerClustererOptions): import('./extra/marker-clusterer').MarkerClusterer;
|
|
40
|
+
createInfoWindow(options: import('./overlay/info-window').InfoWindowOptions): import('./overlay/info-window').InfoWindowOverlay;
|
|
41
|
+
createPolyline(options: import('./overlay/polyline').PolylineOptions): import('./overlay/polyline').PolylineOverlay;
|
|
42
|
+
createPolygon(options: import('./overlay/polygon').PolygonOptions): import('./overlay/polygon').PolygonOverlay;
|
|
43
|
+
createCircle(options: import('./overlay/circle').CircleOptions): import('./overlay/circle').CircleOverlay;
|
|
44
|
+
addCustomControl(control: import('./controls/control').CustomControl): void;
|
|
45
|
+
removeCustomControl(control: import('./controls/control').CustomControl): void;
|
|
46
|
+
createMapTypeControl(options: import('./controls/map-type.control').MapTypeControlOptions): import('./controls/map-type.control').MapTypeControl;
|
|
47
|
+
createZoomControl(options: import('./controls/zoom.control').ZoomControlOptions): import('./controls/zoom.control').ZoomControl;
|
|
48
|
+
createScaleControl(options: import('./controls/scale.control').ScaleControlOptions): import('./controls/zoom.control').ZoomControl;
|
|
49
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="googlemaps" />
|
|
2
|
+
import { LatLng } from '../lat-lng';
|
|
3
|
+
import type { BuildInMapTypeId } from './map-type';
|
|
4
|
+
export type InfoWindowMode = 'single' | 'multi';
|
|
5
|
+
/**
|
|
6
|
+
* 完全模仿google的模式, 合并如下配置:
|
|
7
|
+
* - draggable
|
|
8
|
+
* - scrollWheel
|
|
9
|
+
* - doubleClickZoom
|
|
10
|
+
*/
|
|
11
|
+
export declare enum GestureHandlingOptions {
|
|
12
|
+
/** 默认, 若页面可滚动, 则为cooperative, 否则为greedy */
|
|
13
|
+
auto = "auto",
|
|
14
|
+
/** 全部设为false */
|
|
15
|
+
none = "none",
|
|
16
|
+
/** 贪婪, 全部设为true */
|
|
17
|
+
greedy = "greedy",
|
|
18
|
+
/** 合作, 按住ctrl或者双指才能缩放地图 */
|
|
19
|
+
cooperative = "cooperative"
|
|
20
|
+
}
|
|
21
|
+
export interface MapOptions {
|
|
22
|
+
/** 中心点 */
|
|
23
|
+
center: LatLng;
|
|
24
|
+
/** 缩放等级, 必须是整数 */
|
|
25
|
+
zoom: number;
|
|
26
|
+
infoWindowMode?: InfoWindowMode;
|
|
27
|
+
gestureHandling?: GestureHandlingOptions;
|
|
28
|
+
minZoom?: number;
|
|
29
|
+
maxZoom?: number;
|
|
30
|
+
mapStyle?: MapStyle;
|
|
31
|
+
buildInMapTypeId?: BuildInMapTypeId;
|
|
32
|
+
}
|
|
33
|
+
export declare namespace MapOptions {
|
|
34
|
+
function create(options?: Partial<MapOptions>): MapOptions;
|
|
35
|
+
}
|
|
36
|
+
export interface MapStyle {
|
|
37
|
+
toBaidu(): BMap.MapStyleV2;
|
|
38
|
+
toGoogle(): google.maps.MapTypeStyle[];
|
|
39
|
+
}
|
|
40
|
+
export declare class SimpleMapStyle implements MapStyle {
|
|
41
|
+
baidu: BMap.MapStyleV2;
|
|
42
|
+
google: google.maps.MapTypeStyle[];
|
|
43
|
+
constructor(baidu: BMap.MapStyleV2, google: google.maps.MapTypeStyle[]);
|
|
44
|
+
toBaidu(): BMap.MapStyleV2;
|
|
45
|
+
toGoogle(): google.maps.MapTypeStyle[];
|
|
46
|
+
}
|