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,113 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
/// <reference types="baidumap-web-sdk" />
|
|
3
|
+
/// <reference types="googlemaps" />
|
|
4
|
+
import type { GoogleLayer } from '../unions';
|
|
5
|
+
import type { Point } from '../types';
|
|
6
|
+
import { CoordType } from '../lat-lng';
|
|
7
|
+
import { FastFindValues } from '../../utils/values';
|
|
8
|
+
/**
|
|
9
|
+
* 内置地图的id
|
|
10
|
+
*/
|
|
11
|
+
export declare enum BuildInMapTypeId {
|
|
12
|
+
normal = "normal",
|
|
13
|
+
satellite = "satellite",
|
|
14
|
+
hybrid = "hybrid"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 包括不兼容的地图类型
|
|
18
|
+
* - 'terrain': google中为地形图, baidu中为三维图
|
|
19
|
+
* */
|
|
20
|
+
export type BuildInMapTypeIdIncludeIncompatible = BuildInMapTypeId | 'terrain';
|
|
21
|
+
/**
|
|
22
|
+
* ## 注意
|
|
23
|
+
* `asXxx()`多次调用时应返回同一个对象
|
|
24
|
+
*/
|
|
25
|
+
export interface MapType {
|
|
26
|
+
/** MapType的唯一标识符, 命名时推荐包含`-`, 防止和BuildInMapTypeId冲突 */
|
|
27
|
+
id: string;
|
|
28
|
+
getBaiduCoordType(): CoordType;
|
|
29
|
+
asBaiduMapType(): BaiduMapType;
|
|
30
|
+
getGoogleCoordType(): CoordType;
|
|
31
|
+
asGoogleMapType(): GoogleMapType;
|
|
32
|
+
}
|
|
33
|
+
export interface Layer {
|
|
34
|
+
asBaiduLayer(): BMap.TileLayer;
|
|
35
|
+
asGoogleLayer(): GoogleLayer;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 同时实现`MapType`和`Layer`的对象被称作`OverlayMapType`
|
|
39
|
+
* - 往google中添加`OverlayMapType`, 将被看作`MapType`
|
|
40
|
+
* - 往baidu中添加`OverlayMapType`, 将被看作`Layer`
|
|
41
|
+
* @see TgMap.addOverlayMapType
|
|
42
|
+
* @see TgMap.removeOverlayMapType
|
|
43
|
+
* @see ImageMapType
|
|
44
|
+
*/
|
|
45
|
+
export type OverlayMapType = MapType & Layer;
|
|
46
|
+
export declare class BuildInMapType implements MapType {
|
|
47
|
+
id: BuildInMapTypeIdIncludeIncompatible;
|
|
48
|
+
private baidu;
|
|
49
|
+
private google;
|
|
50
|
+
private googleCoordType;
|
|
51
|
+
constructor(id: BuildInMapTypeIdIncludeIncompatible, baidu: () => BMap.MapType, // 需要延迟初始化, 故写成方法
|
|
52
|
+
google: () => google.maps.MapTypeId, // 同上
|
|
53
|
+
googleCoordType: CoordType);
|
|
54
|
+
getId(): BuildInMapTypeIdIncludeIncompatible;
|
|
55
|
+
getBaiduCoordType(): CoordType;
|
|
56
|
+
asBaiduMapType(): BaiduMapType;
|
|
57
|
+
getGoogleCoordType(): CoordType;
|
|
58
|
+
/** 内置地图的id和google的id是不一样的 */
|
|
59
|
+
getGoogleMapTypeId(): google.maps.MapTypeId;
|
|
60
|
+
asGoogleMapType(): GoogleMapType;
|
|
61
|
+
}
|
|
62
|
+
export type GoogleMapType = google.maps.MapType & {
|
|
63
|
+
/** 需要在创建实例时设置该值 */
|
|
64
|
+
__google_map_type__?: MapType;
|
|
65
|
+
};
|
|
66
|
+
export type BaiduMapType = BMap.MapType & {
|
|
67
|
+
/** 需要在创建实例时设置该值 */
|
|
68
|
+
__baidu_map_type__?: MapType;
|
|
69
|
+
};
|
|
70
|
+
export interface ImageMapTypeOptions {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
/**
|
|
73
|
+
* @param tileCoord 统一成google的瓦片坐标, 原点在左上角
|
|
74
|
+
* @returns 返回值可以为空
|
|
75
|
+
*/
|
|
76
|
+
getTileUrl: (tileCoord: Point, zoom: number) => string | null;
|
|
77
|
+
maxZoom: number;
|
|
78
|
+
minZoom?: number;
|
|
79
|
+
name: string;
|
|
80
|
+
describe?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* ImageMapType应该同时实现MapType和Layer接口
|
|
84
|
+
*/
|
|
85
|
+
export declare class ImageMapType implements OverlayMapType {
|
|
86
|
+
coordType: CoordType;
|
|
87
|
+
options: ImageMapTypeOptions;
|
|
88
|
+
private baiduLayerCached;
|
|
89
|
+
private baiduMapTypeCached;
|
|
90
|
+
private googleCached;
|
|
91
|
+
constructor(coordType: CoordType, options: ImageMapTypeOptions);
|
|
92
|
+
get id(): string;
|
|
93
|
+
getBaiduCoordType(): CoordType;
|
|
94
|
+
asBaiduMapType(): BaiduMapType;
|
|
95
|
+
asBaiduLayer(): BMap.TileLayer;
|
|
96
|
+
getGoogleCoordType(): CoordType;
|
|
97
|
+
asGoogleMapType(): GoogleMapType;
|
|
98
|
+
asGoogleLayer(): GoogleLayer;
|
|
99
|
+
}
|
|
100
|
+
/** 交通流量图层 */
|
|
101
|
+
export declare class TrafficLayer implements Layer {
|
|
102
|
+
private baiduCache;
|
|
103
|
+
private googleCache;
|
|
104
|
+
asBaiduLayer(): BMap.TileLayer;
|
|
105
|
+
asGoogleLayer(): GoogleLayer;
|
|
106
|
+
}
|
|
107
|
+
export declare namespace MapType {
|
|
108
|
+
const NORMAL: BuildInMapType;
|
|
109
|
+
const SATELLITE: BuildInMapType;
|
|
110
|
+
const HYBRID: BuildInMapType;
|
|
111
|
+
const TERRAIN: BuildInMapType;
|
|
112
|
+
const BUILD_IN_MAP_TYPES: FastFindValues<BuildInMapType>;
|
|
113
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { CoordType, CoordTypeSupplier, LatLng, LatLngBounds } from '../lat-lng';
|
|
2
|
+
import type { MarkerOverlay, MarkerOptions } from './overlay/marker';
|
|
3
|
+
import type { Overlay } from './overlay/overlay';
|
|
4
|
+
import type { UnionMap } from '../unions';
|
|
5
|
+
import type { MarkerClustererOptions, MarkerClusterer } from './extra/marker-clusterer';
|
|
6
|
+
import type { InfoWindowOverlay, InfoWindowOptions } from './overlay/info-window';
|
|
7
|
+
import type { PolylineOptions, PolylineOverlay } from './overlay/polyline';
|
|
8
|
+
import type { PolygonOptions, PolygonOverlay } from './overlay/polygon';
|
|
9
|
+
import type { CircleOptions, CircleOverlay } from './overlay/circle';
|
|
10
|
+
import type { Tg } from '../event';
|
|
11
|
+
import type { AbstractEventTargetDelegate } from '../event-target';
|
|
12
|
+
import type { CustomControl, AbstractControl } from './controls/control';
|
|
13
|
+
import type { MapTypeControlOptions, MapTypeControl } from './controls/map-type.control';
|
|
14
|
+
import type { ZoomControlOptions, ZoomControl } from './controls/zoom.control';
|
|
15
|
+
import type { ScaleControlOptions } from './controls/scale.control';
|
|
16
|
+
import type { GestureHandlingOptions, MapStyle } from './map-options';
|
|
17
|
+
import type { BuildInMapTypeId, MapType, Layer, OverlayMapType } from './map-type';
|
|
18
|
+
import type { Padding, Point } from '../types';
|
|
19
|
+
import type { LabelOptions, LabelOverlay } from './overlay/label';
|
|
20
|
+
import type { InfoBoxOptions, InfoBoxOverlay } from './overlay/info-box';
|
|
21
|
+
import type { ElementOverlay } from './overlay/element-overlay';
|
|
22
|
+
export type AbstractMapEventMap = {
|
|
23
|
+
click: Tg.MouseEvent;
|
|
24
|
+
dblclick: Tg.MouseEvent;
|
|
25
|
+
rightclick: Tg.MouseEvent;
|
|
26
|
+
dragstart: Tg.Event;
|
|
27
|
+
drag: Tg.Event;
|
|
28
|
+
dragend: Tg.Event;
|
|
29
|
+
/**
|
|
30
|
+
* ## 不同行为
|
|
31
|
+
* - baidu: 貌似不会触发
|
|
32
|
+
* - google: 正常触发
|
|
33
|
+
*/
|
|
34
|
+
mouseover: Tg.Event;
|
|
35
|
+
mousemove: Tg.MouseEvent;
|
|
36
|
+
/** @see mouseover */
|
|
37
|
+
mouseout: Tg.Event;
|
|
38
|
+
tilesloaded: Tg.Event;
|
|
39
|
+
/**
|
|
40
|
+
* ## 不同实现
|
|
41
|
+
* - baidu: 同时监听movestart & moving & moveend & zoomend事件, 只要地图"移动"就会触发
|
|
42
|
+
* - google: 监听center_changed事件, 拖着地图移动时会不断触发, 松手后只触发一次, center的值直接变为地图停止时的最终值...
|
|
43
|
+
*/
|
|
44
|
+
'center-changed': Tg.Event;
|
|
45
|
+
/**
|
|
46
|
+
* ## 不同实现
|
|
47
|
+
* - baidu: 监听zoomend事件
|
|
48
|
+
* - google: 监听zoom_changed事件
|
|
49
|
+
*/
|
|
50
|
+
'zoom-changed': Tg.Event;
|
|
51
|
+
'map-type-changed': Tg.Event;
|
|
52
|
+
};
|
|
53
|
+
/** 抽象出来的Map类 */
|
|
54
|
+
export declare abstract class AbstractMap implements CoordTypeSupplier, Tg.EventTarget {
|
|
55
|
+
element: HTMLElement;
|
|
56
|
+
private latestInfoWindow;
|
|
57
|
+
/** 使用{@link setEventTargetDelegate}初始化 */
|
|
58
|
+
private delegate;
|
|
59
|
+
constructor(element: HTMLElement);
|
|
60
|
+
abstract setGestureHandling(gestureHandling: GestureHandlingOptions): void;
|
|
61
|
+
abstract get innerMap(): UnionMap;
|
|
62
|
+
abstract get coordType(): CoordType;
|
|
63
|
+
protected setEventTargetDelegate(delegate: AbstractEventTargetDelegate): void;
|
|
64
|
+
/** 使用重载, 规范事件类型 */
|
|
65
|
+
addEventListener<K extends keyof AbstractMapEventMap>(type: K, listener: (event: AbstractMapEventMap[K]) => void): void;
|
|
66
|
+
addEventListener(type: string, listener: Tg.EventListener): void;
|
|
67
|
+
/** @see addEventListener */
|
|
68
|
+
removeEventListener<K extends keyof AbstractMapEventMap>(type: K, listener: (event: AbstractMapEventMap[K]) => void): void;
|
|
69
|
+
removeEventListener(type: string, listener: Tg.EventListener): void;
|
|
70
|
+
/** 最后一次显示的InfoWindow, 不保证当前它仍然是打开状态 */
|
|
71
|
+
getLatestInfoWindow(): InfoWindowOverlay | undefined;
|
|
72
|
+
/** 仅用于@tg/map内部使用, 外部不要调用 */
|
|
73
|
+
setLatestInfoWindowInternal(infoWindow: InfoWindowOverlay): void;
|
|
74
|
+
/** 地图容器内的坐标点到经纬度之间转换 */
|
|
75
|
+
abstract fromContainerPointToLatLng(point: Point): LatLng;
|
|
76
|
+
/** @see fromContainerPointToLatLng */
|
|
77
|
+
abstract fromLatLngToContainerPoint(latLng: LatLng): Point;
|
|
78
|
+
/**
|
|
79
|
+
* ## 不同行为
|
|
80
|
+
* - baidu: 禁用拖拽后, 依然可以滚轮缩放
|
|
81
|
+
* - google: 禁用拖拽后, 不能滚轮缩放
|
|
82
|
+
*/
|
|
83
|
+
abstract setDraggable(draggable: boolean): void;
|
|
84
|
+
abstract setDefaultCursor(cursor: string): void;
|
|
85
|
+
abstract setDisableDoubleClickZoom(type: boolean): void;
|
|
86
|
+
abstract getCenter(): LatLng;
|
|
87
|
+
abstract setCenter(latlng: LatLng): void;
|
|
88
|
+
abstract setMinZoom(zoom: number): void;
|
|
89
|
+
abstract setMaxZoom(zoom: number): void;
|
|
90
|
+
abstract setMapStyle(mapStyle: MapStyle): void;
|
|
91
|
+
/** setMapType的便利版, 只能够用来设置内置地图类型 */
|
|
92
|
+
abstract setBuildInMapTypeId(id: BuildInMapTypeId): void;
|
|
93
|
+
abstract setMapType(mapType: MapType): void;
|
|
94
|
+
abstract getMapType(): MapType;
|
|
95
|
+
abstract addLayer(layer: Layer): void;
|
|
96
|
+
abstract removeLayer(layer: Layer): void;
|
|
97
|
+
addOverlayMapType(mapType: OverlayMapType): void;
|
|
98
|
+
removeOverlayMapType(mapType: OverlayMapType): void;
|
|
99
|
+
abstract panTo(position: LatLng): void;
|
|
100
|
+
abstract panBy(x: number, y: number): void;
|
|
101
|
+
abstract fitBounds(bounds: LatLngBounds, padding?: Padding): void;
|
|
102
|
+
abstract getBounds(): LatLngBounds;
|
|
103
|
+
abstract addElementOverlay(overlay: ElementOverlay): void;
|
|
104
|
+
abstract removeElementOverlay(overlay: ElementOverlay): void;
|
|
105
|
+
abstract addOverlay(overlay: Overlay): void;
|
|
106
|
+
abstract removeOverlay(overlay: Overlay): void;
|
|
107
|
+
abstract createMarker(options: MarkerOptions): MarkerOverlay;
|
|
108
|
+
abstract createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
|
|
109
|
+
abstract createInfoWindow(options: InfoWindowOptions): InfoWindowOverlay;
|
|
110
|
+
abstract createInfoBox(options: InfoBoxOptions): InfoBoxOverlay;
|
|
111
|
+
abstract createPolyline(options: PolylineOptions): PolylineOverlay;
|
|
112
|
+
abstract createPolygon(options: PolygonOptions): PolygonOverlay;
|
|
113
|
+
abstract createCircle(options: CircleOptions): CircleOverlay;
|
|
114
|
+
abstract createLabel(options: LabelOptions): LabelOverlay;
|
|
115
|
+
/**
|
|
116
|
+
* ## 不同行为
|
|
117
|
+
* - baidu: 添加的同一个方位的自定义Control会重叠在一起
|
|
118
|
+
* - google: 添加的同一个方位的自定义Control不会重叠, 会平铺开来
|
|
119
|
+
*/
|
|
120
|
+
abstract addCustomControl(control: CustomControl): void;
|
|
121
|
+
abstract removeCustomControl(control: CustomControl): void;
|
|
122
|
+
abstract createMapTypeControl(options: MapTypeControlOptions): MapTypeControl;
|
|
123
|
+
abstract createZoomControl(options: ZoomControlOptions): ZoomControl;
|
|
124
|
+
abstract createScaleControl(options: ScaleControlOptions): ZoomControl;
|
|
125
|
+
addControl(control: AbstractControl): void;
|
|
126
|
+
removeControl(control: AbstractControl): void;
|
|
127
|
+
getZoom(): number;
|
|
128
|
+
setZoom(zoom: number): void;
|
|
129
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
import { Point } from '../../types';
|
|
3
|
+
import type { BMarker } from './marker';
|
|
4
|
+
export type BaiduInfoBox = InstanceType<ReturnType<typeof createBaiduInfoBoxClass>>;
|
|
5
|
+
export declare function createBaiduInfoBox(content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: String): {
|
|
6
|
+
container: HTMLElement;
|
|
7
|
+
border: HTMLElement;
|
|
8
|
+
inner: HTMLElement;
|
|
9
|
+
map: BMap.Map | undefined;
|
|
10
|
+
marker: BMarker | undefined;
|
|
11
|
+
content: HTMLElement;
|
|
12
|
+
position: BMap.Point;
|
|
13
|
+
offset: Point;
|
|
14
|
+
/** @override */
|
|
15
|
+
initialize(map: BMap.Map): HTMLElement;
|
|
16
|
+
/** @override */
|
|
17
|
+
draw(): void;
|
|
18
|
+
open(map: BMap.Map, anchor?: BMarker | undefined): void;
|
|
19
|
+
attachMarker(marker: BMarker): void;
|
|
20
|
+
detachMarker(marker: BMarker): void;
|
|
21
|
+
close(): void;
|
|
22
|
+
isOpen(): boolean | undefined;
|
|
23
|
+
onMarkerPositionChanged(): void;
|
|
24
|
+
setZIndex(zIndex: number): void;
|
|
25
|
+
setMaxWidth(maxWidth: number): void;
|
|
26
|
+
setPosition(position: BMap.Point): void;
|
|
27
|
+
getPosition(): BMap.Point;
|
|
28
|
+
setOffset(offset: Point): void;
|
|
29
|
+
getOffset(): Point;
|
|
30
|
+
isVisible(): boolean;
|
|
31
|
+
show(): void;
|
|
32
|
+
hide(): void;
|
|
33
|
+
addEventListener(event: string, handler: BMap.Callback): void;
|
|
34
|
+
removeEventListener(event: string, handler: BMap.Callback): void;
|
|
35
|
+
dispatchEvent(event: {
|
|
36
|
+
type: string;
|
|
37
|
+
}): void;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* baidu自带的InfoWindow有如下问题:
|
|
41
|
+
* 1. 窗体不可自定义, 默认的窗体有点丑
|
|
42
|
+
* 2. 一次只能显示一个
|
|
43
|
+
* 3. 和MarkerClusterer的配合并不好, 重建聚合时会使InfoWindow消失
|
|
44
|
+
*/
|
|
45
|
+
declare function createBaiduInfoBoxClass(): {
|
|
46
|
+
new (content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: String): {
|
|
47
|
+
container: HTMLElement;
|
|
48
|
+
border: HTMLElement;
|
|
49
|
+
inner: HTMLElement;
|
|
50
|
+
map: BMap.Map | undefined;
|
|
51
|
+
marker: BMarker | undefined;
|
|
52
|
+
content: HTMLElement;
|
|
53
|
+
position: BMap.Point;
|
|
54
|
+
offset: Point;
|
|
55
|
+
/** @override */
|
|
56
|
+
initialize(map: BMap.Map): HTMLElement;
|
|
57
|
+
/** @override */
|
|
58
|
+
draw(): void;
|
|
59
|
+
open(map: BMap.Map, anchor?: BMarker): void;
|
|
60
|
+
attachMarker(marker: BMarker): void;
|
|
61
|
+
detachMarker(marker: BMarker): void;
|
|
62
|
+
close(): void;
|
|
63
|
+
isOpen(): boolean | undefined;
|
|
64
|
+
onMarkerPositionChanged(): void;
|
|
65
|
+
setZIndex(zIndex: number): void;
|
|
66
|
+
setMaxWidth(maxWidth: number): void;
|
|
67
|
+
setPosition(position: BMap.Point): void;
|
|
68
|
+
getPosition(): BMap.Point;
|
|
69
|
+
setOffset(offset: Point): void;
|
|
70
|
+
getOffset(): Point;
|
|
71
|
+
isVisible(): boolean;
|
|
72
|
+
show(): void;
|
|
73
|
+
hide(): void;
|
|
74
|
+
addEventListener(event: string, handler: BMap.Callback): void;
|
|
75
|
+
removeEventListener(event: string, handler: BMap.Callback): void;
|
|
76
|
+
dispatchEvent(event: {
|
|
77
|
+
type: string;
|
|
78
|
+
}): void;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
/// <reference types="googlemaps" />
|
|
3
|
+
import type { Tg } from '../../event';
|
|
4
|
+
import type { Overlay } from './overlay';
|
|
5
|
+
import { type Shape, type ShapeOptions, BaiduShape, GoogleShape } from './shape';
|
|
6
|
+
import { LatLng } from '../../lat-lng';
|
|
7
|
+
import type { BaiduMap } from '../baidu-map';
|
|
8
|
+
import type { GoogleMap } from '../google-map';
|
|
9
|
+
type CircleEventMap = {
|
|
10
|
+
click: Tg.Event;
|
|
11
|
+
dblclick: Tg.Event;
|
|
12
|
+
mousedown: Tg.MouseEvent;
|
|
13
|
+
mouseup: Tg.MouseEvent;
|
|
14
|
+
mouseout: Tg.MouseEvent;
|
|
15
|
+
mouseover: Tg.MouseEvent;
|
|
16
|
+
};
|
|
17
|
+
export interface CircleOptions extends ShapeOptions {
|
|
18
|
+
center: LatLng;
|
|
19
|
+
radius: number;
|
|
20
|
+
}
|
|
21
|
+
export interface Circle extends Tg.EventTargetTyped<Circle, CircleEventMap>, Shape {
|
|
22
|
+
setCenter(center: LatLng): void;
|
|
23
|
+
getCenter(): LatLng;
|
|
24
|
+
setRadius(radius: number): void;
|
|
25
|
+
getRadius(): number;
|
|
26
|
+
}
|
|
27
|
+
export type CircleOverlay = Circle & Overlay;
|
|
28
|
+
export declare class BaiduCircle extends BaiduShape<BMap.Circle> implements Circle {
|
|
29
|
+
static create(this: BaiduMap, options: CircleOptions): BaiduCircle;
|
|
30
|
+
setCenter(center: LatLng): void;
|
|
31
|
+
getCenter(): LatLng;
|
|
32
|
+
setRadius(radius: number): void;
|
|
33
|
+
getRadius(): number;
|
|
34
|
+
}
|
|
35
|
+
export declare class GoogleCircle extends GoogleShape<google.maps.Circle> implements Circle {
|
|
36
|
+
static create(this: GoogleMap, options: CircleOptions): GoogleCircle;
|
|
37
|
+
setCenter(center: LatLng): void;
|
|
38
|
+
getCenter(): LatLng;
|
|
39
|
+
setRadius(radius: number): void;
|
|
40
|
+
getRadius(): number;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="googlemaps" />
|
|
2
|
+
import { LatLng } from '../../lat-lng';
|
|
3
|
+
import type { Point } from '../../types';
|
|
4
|
+
import type { AbstractMap } from '../map';
|
|
5
|
+
export declare enum MapPane {
|
|
6
|
+
map = "map",
|
|
7
|
+
overlay = "overlay",
|
|
8
|
+
overlayMouseTarget = "overlayMouseTarget",
|
|
9
|
+
float = "float"
|
|
10
|
+
}
|
|
11
|
+
export interface ElementOverlayOptions {
|
|
12
|
+
mapPane: MapPane;
|
|
13
|
+
}
|
|
14
|
+
export interface OverlayProjection {
|
|
15
|
+
fromLatLngToOverlayPoint(latLng: LatLng): Point;
|
|
16
|
+
fromOverlayPointToLatLng(point: Point): LatLng;
|
|
17
|
+
}
|
|
18
|
+
export declare abstract class ElementOverlay {
|
|
19
|
+
map: AbstractMap;
|
|
20
|
+
private baidu;
|
|
21
|
+
private google;
|
|
22
|
+
private projection;
|
|
23
|
+
protected element: HTMLElement;
|
|
24
|
+
private mapPane;
|
|
25
|
+
constructor(map: AbstractMap, options: ElementOverlayOptions);
|
|
26
|
+
create(): HTMLElement;
|
|
27
|
+
draw(): void;
|
|
28
|
+
protected abstract onCreate(): HTMLElement;
|
|
29
|
+
protected abstract onDraw(projection: OverlayProjection): void;
|
|
30
|
+
getProjection(): OverlayProjection | undefined;
|
|
31
|
+
asBaidu(): BMap.OverlayV3;
|
|
32
|
+
asGoogle(): google.maps.OverlayView;
|
|
33
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="googlemaps" />
|
|
2
|
+
import type { Point } from '../../types';
|
|
3
|
+
import type { Nullable } from '../../../components';
|
|
4
|
+
export type GoogleLabel = InstanceType<ReturnType<typeof createGoogleLabelClass>>;
|
|
5
|
+
export declare function createGoogleLabel(element: HTMLElement, position: Nullable<google.maps.LatLng>, offset?: Point, zIndex?: number): {
|
|
6
|
+
container: HTMLElement;
|
|
7
|
+
position: Nullable<google.maps.LatLng>;
|
|
8
|
+
offset?: Point | undefined;
|
|
9
|
+
zIndex?: number | undefined;
|
|
10
|
+
setZIndex(zIndex: number): void;
|
|
11
|
+
setElement(element: HTMLElement): void;
|
|
12
|
+
/** @override */
|
|
13
|
+
onAdd(): void;
|
|
14
|
+
/** @override */
|
|
15
|
+
draw(): void;
|
|
16
|
+
/** @override */
|
|
17
|
+
onRemove(): void;
|
|
18
|
+
setPosition(position: Nullable<google.maps.LatLng>): void;
|
|
19
|
+
getPosition(): Nullable<google.maps.LatLng>;
|
|
20
|
+
setOffset(offset: Point): void;
|
|
21
|
+
getOffset(): Point | undefined;
|
|
22
|
+
getVisible(): boolean;
|
|
23
|
+
setVisible(visible: boolean): void;
|
|
24
|
+
getMap(): google.maps.Map | google.maps.StreetViewPanorama;
|
|
25
|
+
getPanes(): google.maps.MapPanes;
|
|
26
|
+
getProjection(): google.maps.MapCanvasProjection;
|
|
27
|
+
setMap(map: google.maps.Map | google.maps.StreetViewPanorama | null): void;
|
|
28
|
+
addListener(eventName: string, handler: (...args: any[]) => void): google.maps.MapsEventListener;
|
|
29
|
+
bindTo(key: string, target: google.maps.MVCObject, targetKey?: string | undefined, noNotify?: boolean | undefined): void;
|
|
30
|
+
changed(key: string): void;
|
|
31
|
+
get(key: string): any;
|
|
32
|
+
notify(key: string): void;
|
|
33
|
+
set(key: string, value: any): void;
|
|
34
|
+
setValues(values: any): void;
|
|
35
|
+
unbind(key: string): void;
|
|
36
|
+
unbindAll(): void;
|
|
37
|
+
};
|
|
38
|
+
/** 打开页面时 google.maps.OverlayView 并没有加载, 故需要将GoogleLabel类写到方法中去 */
|
|
39
|
+
declare function createGoogleLabelClass(): {
|
|
40
|
+
new (element: HTMLElement, position: Nullable<google.maps.LatLng>, offset?: Point, zIndex?: number): {
|
|
41
|
+
container: HTMLElement;
|
|
42
|
+
position: Nullable<google.maps.LatLng>;
|
|
43
|
+
offset?: Point;
|
|
44
|
+
zIndex?: number;
|
|
45
|
+
setZIndex(zIndex: number): void;
|
|
46
|
+
setElement(element: HTMLElement): void;
|
|
47
|
+
/** @override */
|
|
48
|
+
onAdd(): void;
|
|
49
|
+
/** @override */
|
|
50
|
+
draw(): void;
|
|
51
|
+
/** @override */
|
|
52
|
+
onRemove(): void;
|
|
53
|
+
setPosition(position: Nullable<google.maps.LatLng>): void;
|
|
54
|
+
getPosition(): Nullable<google.maps.LatLng>;
|
|
55
|
+
setOffset(offset: Point): void;
|
|
56
|
+
getOffset(): Point | undefined;
|
|
57
|
+
getVisible(): boolean;
|
|
58
|
+
setVisible(visible: boolean): void;
|
|
59
|
+
getMap(): google.maps.Map | google.maps.StreetViewPanorama;
|
|
60
|
+
getPanes(): google.maps.MapPanes;
|
|
61
|
+
getProjection(): google.maps.MapCanvasProjection;
|
|
62
|
+
setMap(map: google.maps.Map | google.maps.StreetViewPanorama | null): void;
|
|
63
|
+
addListener(eventName: string, handler: (...args: any[]) => void): google.maps.MapsEventListener;
|
|
64
|
+
bindTo(key: string, target: google.maps.MVCObject, targetKey?: string | undefined, noNotify?: boolean | undefined): void;
|
|
65
|
+
changed(key: string): void;
|
|
66
|
+
get(key: string): any;
|
|
67
|
+
notify(key: string): void;
|
|
68
|
+
set(key: string, value: any): void;
|
|
69
|
+
setValues(values: any): void;
|
|
70
|
+
unbind(key: string): void;
|
|
71
|
+
unbindAll(): void;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="googlemaps" />
|
|
2
|
+
/// <reference types="baidumap-web-sdk" />
|
|
3
|
+
import type { Size, Point } from '../../types';
|
|
4
|
+
/** 字面量形式, 使用起来会简单点, 目前没看出使用class形式的必要🤔 */
|
|
5
|
+
export interface Icon {
|
|
6
|
+
readonly url: string;
|
|
7
|
+
readonly size: Size;
|
|
8
|
+
/** 图片的显示区域的原点在图片中的坐标, 默认为(0, 0) */
|
|
9
|
+
readonly origin?: Point;
|
|
10
|
+
/** 图片显示到地图上的锚点, 默认为图标的底部中点 */
|
|
11
|
+
readonly anchor?: Point;
|
|
12
|
+
}
|
|
13
|
+
export declare namespace Icon {
|
|
14
|
+
function toGoogle(icon: Icon): google.maps.Icon;
|
|
15
|
+
function toBaidu(icon: Icon): BMap.Icon;
|
|
16
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { BaiduOverlay } from './overlay';
|
|
2
|
+
import { type BaiduInfoBox } from './baidu-info-box';
|
|
3
|
+
import { LatLng, CoordType } from '../../lat-lng';
|
|
4
|
+
import type { Point } from '../../types';
|
|
5
|
+
import { InfoWindow } from './info-window';
|
|
6
|
+
import type { GoogleMap } from '../google-map';
|
|
7
|
+
import type { Marker, GoogleMarker, BaiduMarker } from './marker';
|
|
8
|
+
import type { BaiduMap } from '../baidu-map';
|
|
9
|
+
import type { Tg } from '../../event';
|
|
10
|
+
export type InfoBoxEventMap = {
|
|
11
|
+
closeclick: Tg.Event;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 初始偏移量同{@link InfoWindow}, 底部中点对齐position
|
|
15
|
+
*/
|
|
16
|
+
export interface InfoBoxOptions {
|
|
17
|
+
content: HTMLElement;
|
|
18
|
+
position?: LatLng;
|
|
19
|
+
offset?: Point;
|
|
20
|
+
zIndex?: number;
|
|
21
|
+
maxWidth?: number;
|
|
22
|
+
borderClass?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface InfoBox extends Tg.EventTarget {
|
|
25
|
+
open(anchor?: Marker): void;
|
|
26
|
+
close(): void;
|
|
27
|
+
getPosition(): LatLng;
|
|
28
|
+
setPosition(position: LatLng): void;
|
|
29
|
+
setMaxWidth(maxWidth: number): void;
|
|
30
|
+
setZIndex(zIndex: number): void;
|
|
31
|
+
}
|
|
32
|
+
/** 虽然叫"Overlay", 但并没有继承Overlay... */
|
|
33
|
+
export type InfoBoxOverlay = InfoBox & Tg.EventTargetTyped<InfoBox, InfoBoxEventMap>;
|
|
34
|
+
export declare class BaiduInfoBoxOverlay extends BaiduOverlay<BaiduInfoBox> implements InfoBox {
|
|
35
|
+
private baiduMap;
|
|
36
|
+
static create(this: BaiduMap, options: InfoBoxOptions): BaiduInfoBoxOverlay;
|
|
37
|
+
constructor(innerOverlay: BaiduInfoBox, coordType: CoordType, baiduMap: BaiduMap);
|
|
38
|
+
open(anchor?: BaiduMarker): void;
|
|
39
|
+
close(): void;
|
|
40
|
+
getPosition(): LatLng;
|
|
41
|
+
setPosition(position: LatLng): void;
|
|
42
|
+
setMaxWidth(maxWidth: number): void;
|
|
43
|
+
setZIndex(zIndex: number): void;
|
|
44
|
+
}
|
|
45
|
+
export declare class GoogleInfoBoxOverlay extends InfoWindow implements InfoBox {
|
|
46
|
+
inner: google.maps.InfoWindow;
|
|
47
|
+
private coordType;
|
|
48
|
+
private map;
|
|
49
|
+
static create(this: GoogleMap, options: InfoBoxOptions): GoogleInfoBoxOverlay;
|
|
50
|
+
constructor(inner: google.maps.InfoWindow, coordType: CoordType, map: GoogleMap);
|
|
51
|
+
open(anchor?: GoogleMarker | undefined): void;
|
|
52
|
+
close(): void;
|
|
53
|
+
getPosition(): LatLng;
|
|
54
|
+
setPosition(position: LatLng): void;
|
|
55
|
+
isOpen(): boolean;
|
|
56
|
+
setMaxWidth(maxWidth: number): void;
|
|
57
|
+
setZIndex(zIndex: number): void;
|
|
58
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
import type { Tg } from '../../event';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
import type { GoogleMap } from '../google-map';
|
|
5
|
+
import { AbstractEventTargetDelegate } from '../../event-target';
|
|
6
|
+
import type { UnionInfoWindow } from '../../unions';
|
|
7
|
+
import type { Marker, BaiduMarker, GoogleMarker } from './marker';
|
|
8
|
+
import { LatLng } from '../../lat-lng';
|
|
9
|
+
import type { Point } from '../../types';
|
|
10
|
+
/**
|
|
11
|
+
* ## InfoWindow的初始偏移, 不同实现
|
|
12
|
+
* - baidu: 根据Icon的infoWindowAnchor选项, 确定相对Icon左上角的偏移
|
|
13
|
+
* - google: 根据Marker的anchorPoint选项, 确定相对marker的position的偏移
|
|
14
|
+
*
|
|
15
|
+
* 统一成: InfoWindow的底部中点对齐Marker的position, 需要多少偏移使用offset选项来设置
|
|
16
|
+
*/
|
|
17
|
+
export interface InfoWindowOptions {
|
|
18
|
+
content: string | HTMLElement;
|
|
19
|
+
/** @default {LatLng.ZERO} */
|
|
20
|
+
position?: LatLng;
|
|
21
|
+
maxWidth?: number;
|
|
22
|
+
offset?: Point;
|
|
23
|
+
disableAutoPan?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* cSpell:words clickclose, statechange
|
|
27
|
+
* ## 打开/关闭InfoWindow的不同行为
|
|
28
|
+
* - google
|
|
29
|
+
* 0. 添加时, 默认不显示
|
|
30
|
+
* 1. close(), 不发送事件
|
|
31
|
+
* 2. 点击x, 发送`closeclick`事件
|
|
32
|
+
* 3. open(), 不发送事件
|
|
33
|
+
* 4. 可以同时打开多个InfoWindow
|
|
34
|
+
* - baidu:
|
|
35
|
+
* 0. 添加时, 默认不显示
|
|
36
|
+
* 1. close(), 发送`close`事件
|
|
37
|
+
* 2. 点击x, 先后发送`clickclose`, `close`事件
|
|
38
|
+
* 3. 点击地图的空白区域, 发送`close`事件
|
|
39
|
+
* 4. open(), 发送`open`事件
|
|
40
|
+
* 5. 同时只能打开一个, 之前的会自动关闭(发送`close`事件)
|
|
41
|
+
* - here(InfoBubble)
|
|
42
|
+
* 0. 添加时, 默认显示, 不发送事件
|
|
43
|
+
* 1. close(), 发送`statechange`事件
|
|
44
|
+
* 2. 点击x, 发送`statechange`事件
|
|
45
|
+
* 3. open(), 发送`statechange`事件
|
|
46
|
+
* 4. 可以同时打开多个InfoBubble
|
|
47
|
+
*
|
|
48
|
+
* 结论: 在baidu以外的地图上模拟open/close事件, 保证行为一致
|
|
49
|
+
*/
|
|
50
|
+
type InfoWindowEventMap = {
|
|
51
|
+
closeclick: Tg.Event;
|
|
52
|
+
/**
|
|
53
|
+
* ## 不同实现
|
|
54
|
+
* baidu: 原生支持open/close事件
|
|
55
|
+
* google: 通过拦截open()/close()/closeclick, 实现open/close事件
|
|
56
|
+
*/
|
|
57
|
+
open: Tg.Event;
|
|
58
|
+
/** @see open */
|
|
59
|
+
close: Tg.Event;
|
|
60
|
+
};
|
|
61
|
+
/** 之所以需要这个type, 是为了将event的类型信息合并进去, 通过实现interface的方式似乎做不到这一点, 使用函数重载其实也可以做到 */
|
|
62
|
+
export type InfoWindowOverlay = InfoWindow & Tg.EventTargetTyped<InfoWindow, InfoWindowEventMap>;
|
|
63
|
+
/** 在@tg/map中 InfoWindow 不继承 Overlay... */
|
|
64
|
+
export declare abstract class InfoWindow implements Tg.EventTarget {
|
|
65
|
+
private delegate;
|
|
66
|
+
constructor(delegate: AbstractEventTargetDelegate<UnionInfoWindow>);
|
|
67
|
+
addEventListener(type: string, listener: Tg.EventListener): void;
|
|
68
|
+
removeEventListener(type: string, listener: Tg.EventListener): void;
|
|
69
|
+
abstract inner: UnionInfoWindow;
|
|
70
|
+
/**
|
|
71
|
+
* 若anchor为空, 则添加到地图上
|
|
72
|
+
*
|
|
73
|
+
* ## 不同行为
|
|
74
|
+
* - baidu: 一定要anchor添加到地图上之后, 才能正常打开infoWindow
|
|
75
|
+
* - google: 没有上述限制
|
|
76
|
+
**/
|
|
77
|
+
abstract open(anchor?: Marker): void;
|
|
78
|
+
abstract close(): void;
|
|
79
|
+
abstract getPosition(): LatLng;
|
|
80
|
+
abstract setPosition(position: LatLng): void;
|
|
81
|
+
abstract isOpen(): boolean;
|
|
82
|
+
}
|
|
83
|
+
export declare class BaiduInfoWindow extends InfoWindow {
|
|
84
|
+
inner: BMap.InfoWindow;
|
|
85
|
+
private map;
|
|
86
|
+
private state;
|
|
87
|
+
static create(this: BaiduMap, options: InfoWindowOptions): BaiduInfoWindow;
|
|
88
|
+
constructor(inner: BMap.InfoWindow, map: BaiduMap, state: {
|
|
89
|
+
position?: LatLng;
|
|
90
|
+
});
|
|
91
|
+
isOpen(): boolean;
|
|
92
|
+
open(anchor?: BaiduMarker): void;
|
|
93
|
+
close(): void;
|
|
94
|
+
getPosition(): LatLng;
|
|
95
|
+
setPosition(position: LatLng): void;
|
|
96
|
+
}
|
|
97
|
+
export declare class GoogleInfoWindow extends InfoWindow {
|
|
98
|
+
inner: google.maps.InfoWindow;
|
|
99
|
+
private map;
|
|
100
|
+
static create(this: GoogleMap, options: InfoWindowOptions): GoogleInfoWindow;
|
|
101
|
+
private eventHub;
|
|
102
|
+
private isOpened;
|
|
103
|
+
constructor(inner: google.maps.InfoWindow, map: GoogleMap);
|
|
104
|
+
isOpen(): boolean;
|
|
105
|
+
addEventListener<K extends keyof InfoWindowEventMap>(type: K, listener: (event: InfoWindowEventMap[K]) => void): void;
|
|
106
|
+
removeEventListener<K extends keyof InfoWindowEventMap>(type: K, listener: (event: InfoWindowEventMap[K]) => void): void;
|
|
107
|
+
open(anchor?: GoogleMarker): void;
|
|
108
|
+
close(): void;
|
|
109
|
+
getPosition(): LatLng;
|
|
110
|
+
setPosition(position: LatLng): void;
|
|
111
|
+
}
|
|
112
|
+
export {};
|