tg-map-core 0.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.
Files changed (66) hide show
  1. package/dist/index.cjs +6394 -0
  2. package/dist/index.css +77 -0
  3. package/dist/index.mjs +6277 -0
  4. package/dist/src/index.d.ts +50 -0
  5. package/dist/src/map/event-target.d.ts +80 -0
  6. package/dist/src/map/event.d.ts +50 -0
  7. package/dist/src/map/lat-lng.d.ts +160 -0
  8. package/dist/src/map/map/baidu-map.d.ts +82 -0
  9. package/dist/src/map/map/controls/control.d.ts +112 -0
  10. package/dist/src/map/map/controls/map-type.control.d.ts +29 -0
  11. package/dist/src/map/map/controls/scale.control.d.ts +19 -0
  12. package/dist/src/map/map/controls/street-view.control.d.ts +25 -0
  13. package/dist/src/map/map/controls/zoom.control.d.ts +19 -0
  14. package/dist/src/map/map/extra/autocomplete.d.ts +42 -0
  15. package/dist/src/map/map/extra/heatmap.d.ts +71 -0
  16. package/dist/src/map/map/extra/map-urls.d.ts +59 -0
  17. package/dist/src/map/map/extra/marker-clusterer.d.ts +73 -0
  18. package/dist/src/map/map/extra/places-service.d.ts +47 -0
  19. package/dist/src/map/map/extra/search-box.d.ts +38 -0
  20. package/dist/src/map/map/google-map.d.ts +81 -0
  21. package/dist/src/map/map/here-map.d.ts +78 -0
  22. package/dist/src/map/map/map-options.d.ts +60 -0
  23. package/dist/src/map/map/map-type.d.ts +110 -0
  24. package/dist/src/map/map/map.d.ts +198 -0
  25. package/dist/src/map/map/overlay/baidu-info-box.d.ts +82 -0
  26. package/dist/src/map/map/overlay/circle.d.ts +51 -0
  27. package/dist/src/map/map/overlay/element-overlay.d.ts +37 -0
  28. package/dist/src/map/map/overlay/google-label.d.ts +68 -0
  29. package/dist/src/map/map/overlay/icon.d.ts +122 -0
  30. package/dist/src/map/map/overlay/info-box.d.ts +60 -0
  31. package/dist/src/map/map/overlay/info-window.d.ts +111 -0
  32. package/dist/src/map/map/overlay/label.d.ts +102 -0
  33. package/dist/src/map/map/overlay/marker-label.d.ts +19 -0
  34. package/dist/src/map/map/overlay/marker.d.ts +144 -0
  35. package/dist/src/map/map/overlay/overlay.d.ts +46 -0
  36. package/dist/src/map/map/overlay/polygon.d.ts +42 -0
  37. package/dist/src/map/map/overlay/polyline.d.ts +71 -0
  38. package/dist/src/map/map/overlay/rectangle.d.ts +50 -0
  39. package/dist/src/map/map/overlay/shape.d.ts +76 -0
  40. package/dist/src/map/map/talks-map.d.ts +81 -0
  41. package/dist/src/map/map-config.d.ts +29 -0
  42. package/dist/src/map/map-factory.d.ts +33 -0
  43. package/dist/src/map/map-loader.d.ts +19 -0
  44. package/dist/src/map/talks/talks-layers.d.ts +9 -0
  45. package/dist/src/map/talks/talks-utils.d.ts +7 -0
  46. package/dist/src/map/types.d.ts +17 -0
  47. package/dist/src/map/unions.d.ts +20 -0
  48. package/dist/src/utils/arrays.d.ts +19 -0
  49. package/dist/src/utils/baidu-utils.d.ts +23 -0
  50. package/dist/src/utils/elements.d.ts +4 -0
  51. package/dist/src/utils/formatter.d.ts +1 -0
  52. package/dist/src/utils/google-utils.d.ts +34 -0
  53. package/dist/src/utils/here-utils.d.ts +10 -0
  54. package/dist/src/utils/map-utils.d.ts +7 -0
  55. package/dist/src/utils/mapped-types.d.ts +110 -0
  56. package/dist/src/utils/maps-utils/index.d.ts +2 -0
  57. package/dist/src/utils/maps-utils/math-util.d.ts +59 -0
  58. package/dist/src/utils/maps-utils/poly-util.d.ts +103 -0
  59. package/dist/src/utils/maps-utils/spherical-util.d.ts +67 -0
  60. package/dist/src/utils/objects.d.ts +27 -0
  61. package/dist/src/utils/spherical-utils.d.ts +27 -0
  62. package/dist/src/utils/strings.d.ts +21 -0
  63. package/dist/src/utils/utils.d.ts +14 -0
  64. package/dist/src/utils/values.d.ts +34 -0
  65. package/dist/tsconfig.tsbuildinfo +1 -0
  66. package/package.json +60 -0
@@ -0,0 +1,198 @@
1
+ import type * as CSS from 'csstype';
2
+ import type { Tg } from '../event';
3
+ import type { AbstractEventTargetDelegate } from '../event-target';
4
+ import type { CoordType, CoordTypeSupplier, LatLng, LatLngBounds } from '../lat-lng';
5
+ import type { Padding, Point } from '../types';
6
+ import type { UnionMap } from '../unions';
7
+ import type { AbstractControl, CustomControl } from './controls/control';
8
+ import type { MapTypeControl, MapTypeControlOptions } from './controls/map-type.control';
9
+ import type { ScaleControlOptions } from './controls/scale.control';
10
+ import type { StreetViewControl, StreetViewControlOptions } from './controls/street-view.control';
11
+ import type { ZoomControl, ZoomControlOptions } from './controls/zoom.control';
12
+ import type { Autocomplete, AutocompleteOptions } from './extra/autocomplete';
13
+ import type { Heatmap, HeatmapOptions } from './extra/heatmap';
14
+ import type { MapUrls, MapUrlsOptions } from './extra/map-urls';
15
+ import type { MarkerClusterer, MarkerClustererOptions } from './extra/marker-clusterer';
16
+ import type { PlacesService, PlacesServiceOptions } from './extra/places-service';
17
+ import type { SearchBox, SearchBoxOptions } from './extra/search-box';
18
+ import type { GestureHandlingOptions, MapStyle } from './map-options';
19
+ import type { BuildInMapTypeId, Layer, MapType, OverlayMapType } from './map-type';
20
+ import type { CircleOptions, CircleOverlay } from './overlay/circle';
21
+ import type { ElementOverlay } from './overlay/element-overlay';
22
+ import type { InfoBoxOptions, InfoBoxOverlay } from './overlay/info-box';
23
+ import type { InfoWindowOptions, InfoWindowOverlay } from './overlay/info-window';
24
+ import type { LabelOptions, LabelOverlay } from './overlay/label';
25
+ import type { MarkerOptions, MarkerOverlay } from './overlay/marker';
26
+ import type { Overlay } from './overlay/overlay';
27
+ import type { PolygonOptions, PolygonOverlay } from './overlay/polygon';
28
+ import type { PolylineOptions, PolylineOverlay } from './overlay/polyline';
29
+ import type { RectangleOptions, RectangleOverlay } from './overlay/rectangle';
30
+ export type AbstractMapEventMap = {
31
+ click: Tg.MouseEvent;
32
+ dblclick: Tg.MouseEvent;
33
+ /** @deprecated 使用`contextmenu`替代 */
34
+ rightclick: Tg.MouseEvent;
35
+ contextmenu: Tg.MouseEvent;
36
+ dragstart: Tg.Event;
37
+ drag: Tg.Event;
38
+ dragend: Tg.Event;
39
+ /**
40
+ * ## 不同行为
41
+ * - baidu: 不会触发
42
+ * - google: 正常触发
43
+ */
44
+ mouseover: Tg.MouseEvent;
45
+ /** @see mouseover */
46
+ mouseout: Tg.MouseEvent;
47
+ mousedown: Tg.MouseEvent;
48
+ mousemove: Tg.MouseEvent;
49
+ mouseup: Tg.MouseEvent;
50
+ tilesloaded: Tg.Event;
51
+ /**
52
+ * ## 不同实现
53
+ * - baidu: 同时监听movestart & moving & moveend & zoomend事件, 只要地图"移动"就会触发
54
+ * - google: 监听center_changed事件, 拖着地图移动时会不断触发, 松手后只触发一次, center的值直接变为地图停止时的最终值...
55
+ */
56
+ 'center-changed': Tg.Event;
57
+ /**
58
+ * ## 不同实现
59
+ * - baidu: 监听zoomend事件
60
+ * - google: 监听zoom_changed事件
61
+ */
62
+ 'zoom-changed': Tg.Event;
63
+ 'map-type-changed': Tg.Event;
64
+ };
65
+ /** 预设的几个地图Zoom等级 */
66
+ export declare const enum MapZoom {
67
+ /** 世界 */
68
+ WORLD = 1,
69
+ /** 大洲 */
70
+ STATE = 5,
71
+ /** 城市 */
72
+ CITY = 10,
73
+ /** 街道 */
74
+ STREET = 15,
75
+ /** 建筑 */
76
+ BUILDING = 20
77
+ }
78
+ /**
79
+ * Map通用操作接口, 外部使用
80
+ *
81
+ * 为了保证V1和V2兼容, 故依然使用了`AbstractMap`这个名字
82
+ * */
83
+ export interface AbstractMap extends CoordTypeSupplier, Tg.EventTargetTyped2<AbstractMap, AbstractMapEventMap> {
84
+ get innerMap(): UnionMap;
85
+ setBuildInMapTypeId(id: BuildInMapTypeId): void;
86
+ setMapType(mapType: MapType): void;
87
+ getMapType(): MapType;
88
+ fromContainerPointToLatLng(point: Point): LatLng;
89
+ fromLatLngToContainerPoint(latLng: LatLng): Point;
90
+ setDefaultCursor(cursor: CSS.Property.Cursor): void;
91
+ setDraggable(draggable: boolean): void;
92
+ setDoubleClickZoom(enable: boolean): void;
93
+ getCenter(): LatLng;
94
+ setCenter(latlng: LatLng): void;
95
+ getZoom(): number;
96
+ setZoom(zoom: number): void;
97
+ setMinZoom(zoom: number): void;
98
+ setMaxZoom(zoom: number): void;
99
+ panTo(position: LatLng): void;
100
+ panBy(x: number, y: number): void;
101
+ fitBounds(bounds: LatLngBounds, padding?: Padding): void;
102
+ getBounds(): LatLngBounds;
103
+ createAutocomplete(options: AutocompleteOptions): Autocomplete;
104
+ createSearchBox(options: SearchBoxOptions): SearchBox;
105
+ createPlacesService(options: PlacesServiceOptions): PlacesService;
106
+ createMapUrls(options: MapUrlsOptions): MapUrls;
107
+ }
108
+ /** V1版Map的基础类 */
109
+ export declare abstract class BaseMap implements AbstractMap {
110
+ element: HTMLElement;
111
+ private latestInfoWindow;
112
+ /** 使用{@link setEventTargetDelegate}初始化 */
113
+ private delegate;
114
+ constructor(element: HTMLElement);
115
+ abstract setGestureHandling(gestureHandling: GestureHandlingOptions): void;
116
+ abstract get innerMap(): UnionMap;
117
+ abstract get coordType(): CoordType;
118
+ protected setEventTargetDelegate(delegate: AbstractEventTargetDelegate): void;
119
+ /** 使用重载, 规范事件类型 */
120
+ addEventListener<K extends keyof AbstractMapEventMap>(type: K, listener: (event: AbstractMapEventMap[K]) => void): void;
121
+ addEventListener(type: string, listener: Tg.EventListener): void;
122
+ /** @see addEventListener */
123
+ removeEventListener<K extends keyof AbstractMapEventMap>(type: K, listener: (event: AbstractMapEventMap[K]) => void): void;
124
+ removeEventListener(type: string, listener: Tg.EventListener): void;
125
+ /** 最后一次显示的InfoWindow, 不保证当前它仍然是打开状态 */
126
+ getLatestInfoWindow(): InfoWindowOverlay | undefined;
127
+ /** 仅用于@tg/map内部使用, 外部不要调用 */
128
+ setLatestInfoWindowInternal(infoWindow: InfoWindowOverlay): void;
129
+ /** 地图容器内的坐标点到经纬度之间转换 */
130
+ abstract fromContainerPointToLatLng(point: Point): LatLng;
131
+ /** @see fromContainerPointToLatLng */
132
+ abstract fromLatLngToContainerPoint(latLng: LatLng): Point;
133
+ abstract setDefaultCursor(cursor: CSS.Property.Cursor): void;
134
+ /**
135
+ * ## 不同行为
136
+ * - baidu: 禁用拖拽后, 依然可以滚轮缩放
137
+ * - google: 禁用拖拽后, 不能滚轮缩放
138
+ */
139
+ abstract setDraggable(draggable: boolean): void;
140
+ /** 启用/禁用双击放大 */
141
+ abstract setDoubleClickZoom(enable: boolean): void;
142
+ abstract getCenter(): LatLng;
143
+ /**
144
+ * ## {@link setZoom}和{@link setCenter}的调用顺序问题
145
+ * - baidu: 这两个方法调用是区分顺序的, 若先调用`setCenter`再调用`setZoom`, 中心点会出现偏移
146
+ * - google: 不区分顺序
147
+ */
148
+ abstract setCenter(latlng: LatLng): void;
149
+ abstract setMinZoom(zoom: number): void;
150
+ abstract setMaxZoom(zoom: number): void;
151
+ abstract setMapStyle(mapStyle?: MapStyle): void;
152
+ /** setMapType的便利版, 只能够用来设置内置地图类型 */
153
+ abstract setBuildInMapTypeId(id: BuildInMapTypeId): void;
154
+ abstract setMapType(mapType: MapType): void;
155
+ abstract getMapType(): MapType;
156
+ abstract addLayer(layer: Layer): void;
157
+ abstract removeLayer(layer: Layer): void;
158
+ addOverlayMapType(mapType: OverlayMapType): void;
159
+ removeOverlayMapType(mapType: OverlayMapType): void;
160
+ abstract panTo(position: LatLng): void;
161
+ abstract panBy(x: number, y: number): void;
162
+ abstract fitBounds(bounds: LatLngBounds, padding?: Padding): void;
163
+ abstract getBounds(): LatLngBounds;
164
+ abstract addElementOverlay(overlay: ElementOverlay): void;
165
+ abstract removeElementOverlay(overlay: ElementOverlay): void;
166
+ abstract addOverlay(overlay: Overlay): void;
167
+ abstract removeOverlay(overlay: Overlay): void;
168
+ abstract createMarker(options: MarkerOptions): MarkerOverlay;
169
+ abstract createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
170
+ abstract createHeatmap(options: HeatmapOptions): Heatmap;
171
+ abstract createAutocomplete(options: AutocompleteOptions): Autocomplete;
172
+ abstract createSearchBox(options: SearchBoxOptions): SearchBox;
173
+ abstract createPlacesService(options: PlacesServiceOptions): PlacesService;
174
+ abstract createMapUrls(options: MapUrlsOptions): MapUrls;
175
+ abstract createInfoWindow(options: InfoWindowOptions): InfoWindowOverlay;
176
+ abstract createInfoBox(options: InfoBoxOptions): InfoBoxOverlay;
177
+ abstract createPolyline(options: PolylineOptions): PolylineOverlay;
178
+ abstract createPolygon(options: PolygonOptions): PolygonOverlay;
179
+ abstract createRectangle(options: RectangleOptions): RectangleOverlay;
180
+ abstract createCircle(options: CircleOptions): CircleOverlay;
181
+ abstract createLabel(options: LabelOptions): LabelOverlay;
182
+ /**
183
+ * ## 不同行为
184
+ * - baidu: 添加的同一个方位的自定义Control会重叠在一起
185
+ * - google: 添加的同一个方位的自定义Control不会重叠, 会平铺开来
186
+ */
187
+ abstract addCustomControl(control: CustomControl): void;
188
+ abstract removeCustomControl(control: CustomControl): void;
189
+ abstract createMapTypeControl(options: MapTypeControlOptions): MapTypeControl;
190
+ abstract createZoomControl(options: ZoomControlOptions): ZoomControl;
191
+ abstract createStreetViewControl(options: StreetViewControlOptions): StreetViewControl;
192
+ abstract createScaleControl(options: ScaleControlOptions): ZoomControl;
193
+ addControl(control: AbstractControl): void;
194
+ removeControl(control: AbstractControl): void;
195
+ getZoom(): number;
196
+ /** @see setCenter */
197
+ setZoom(zoom: number): void;
198
+ }
@@ -0,0 +1,82 @@
1
+ import { Point } from '../../types';
2
+ import './baidu-info-box.scss';
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
+ initialize(map: BMap.Map): HTMLElement;
15
+ draw(): void;
16
+ open(map: BMap.Map, anchor?: BMarker): void;
17
+ attachMarker(marker: BMarker): void;
18
+ detachMarker(marker: BMarker): void;
19
+ close(): void;
20
+ isOpen(): boolean | undefined;
21
+ onMarkerPositionChanged(): void;
22
+ setZIndex(zIndex: number): void;
23
+ setMaxWidth(maxWidth: number): void;
24
+ setPosition(position: BMap.Point): void;
25
+ getPosition(): BMap.Point;
26
+ setOffset(offset: Point): void;
27
+ getOffset(): Point;
28
+ isVisible(): boolean;
29
+ show(): void;
30
+ hide(): void;
31
+ addEventListener(event: string, handler: BMap.Callback): void;
32
+ removeEventListener(event: string, handler: BMap.Callback): void;
33
+ dispatchEvent(event: {
34
+ type: string;
35
+ }): void;
36
+ };
37
+ /**
38
+ * {@template info_window_vs_box}
39
+ * baidu自带的InfoWindow有如下问题:
40
+ * 1. 窗体不可自定义, 默认的窗体有点丑
41
+ * 2. 一次只能显示一个
42
+ * 3. 和MarkerClusterer的配合并不好, 重建聚合时会使InfoWindow消失
43
+ *
44
+ * 故重新实现了一个InfoBox, 解决上述问题, 用来替代InfoWindow, 但Info也点问题...:
45
+ * 1. 未实现InfoWindow的autoPan功能
46
+ * {@endtemplate }
47
+ */
48
+ declare function createBaiduInfoBoxClass(): {
49
+ new (content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: string): {
50
+ container: HTMLElement;
51
+ border: HTMLElement;
52
+ inner: HTMLElement;
53
+ map: BMap.Map | undefined;
54
+ marker: BMarker | undefined;
55
+ content: HTMLElement;
56
+ position: BMap.Point;
57
+ offset: Point;
58
+ initialize(map: BMap.Map): HTMLElement;
59
+ draw(): void;
60
+ open(map: BMap.Map, anchor?: BMarker): void;
61
+ attachMarker(marker: BMarker): void;
62
+ detachMarker(marker: BMarker): void;
63
+ close(): void;
64
+ isOpen(): boolean | undefined;
65
+ onMarkerPositionChanged(): void;
66
+ setZIndex(zIndex: number): void;
67
+ setMaxWidth(maxWidth: number): void;
68
+ setPosition(position: BMap.Point): void;
69
+ getPosition(): BMap.Point;
70
+ setOffset(offset: Point): void;
71
+ getOffset(): Point;
72
+ isVisible(): boolean;
73
+ show(): void;
74
+ hide(): void;
75
+ addEventListener(event: string, handler: BMap.Callback): void;
76
+ removeEventListener(event: string, handler: BMap.Callback): void;
77
+ dispatchEvent(event: {
78
+ type: string;
79
+ }): void;
80
+ };
81
+ };
82
+ export {};
@@ -0,0 +1,51 @@
1
+ import type { Tg } from '../../event';
2
+ import { EventHubEventTargetDelegate } from '../../event-target';
3
+ import { LatLng } from '../../lat-lng';
4
+ import type { BaiduMap } from '../baidu-map';
5
+ import type { GoogleMap } from '../google-map';
6
+ import type { Overlay } from './overlay';
7
+ import { BaiduShape, GoogleShape, type Shape, type ShapeOptions } from './shape';
8
+ export type CircleEventMap = {
9
+ click: Tg.Event;
10
+ dblclick: Tg.Event;
11
+ mousedown: Tg.MouseEvent;
12
+ mouseup: Tg.MouseEvent;
13
+ mouseout: Tg.MouseEvent;
14
+ mouseover: Tg.MouseEvent;
15
+ 'radius-changed': Tg.Event;
16
+ 'center-changed': Tg.Event;
17
+ };
18
+ export interface CircleOptions extends ShapeOptions {
19
+ center: LatLng;
20
+ radius: number;
21
+ }
22
+ export interface Circle extends Tg.EventTargetTyped<Circle, CircleEventMap>, Shape {
23
+ setCenter(center: LatLng): void;
24
+ getCenter(): LatLng;
25
+ setRadius(radius: number): void;
26
+ getRadius(): number;
27
+ }
28
+ export type CircleOverlay = Circle & Overlay;
29
+ export declare class BaiduCircle extends BaiduShape<BMap.Circle> implements Circle {
30
+ static create(this: BaiduMap, options: CircleOptions): BaiduCircle;
31
+ private prevCenter;
32
+ private prevRadius;
33
+ private isDoingSetCenter;
34
+ private isDoingSetRadius;
35
+ private eventHubDelegate;
36
+ protected createDelegate(): EventHubEventTargetDelegate<"center-changed" | "radius-changed">;
37
+ private onRadiusChanged;
38
+ private onCenterChanged;
39
+ private resetEditableTimeoutId;
40
+ setCenter(center: LatLng): void;
41
+ getCenter(): LatLng;
42
+ setRadius(radius: number): void;
43
+ getRadius(): number;
44
+ }
45
+ export declare class GoogleCircle extends GoogleShape<google.maps.Circle> implements Circle {
46
+ static create(this: GoogleMap, options: CircleOptions): GoogleCircle;
47
+ setCenter(center: LatLng): void;
48
+ getCenter(): LatLng;
49
+ setRadius(radius: number): void;
50
+ getRadius(): number;
51
+ }
@@ -0,0 +1,37 @@
1
+ import { LatLng } from '../../lat-lng';
2
+ import { Point } from '../../types';
3
+ import type { BaseMap } from '../map';
4
+ import './element-overlay.scss';
5
+ export declare enum MapPane {
6
+ map = "map",
7
+ overlay = "overlay",
8
+ overlayMouseTarget = "overlayMouseTarget",
9
+ float = "float"
10
+ }
11
+ export declare namespace MapPanes {
12
+ function toGoogle(mapPane: MapPane, panes: google.maps.MapPanes): Element;
13
+ function toBaidu(mapPane: MapPane, panes: BMap.MapPanes): HTMLElement | undefined;
14
+ }
15
+ export interface ElementOverlayOptions {
16
+ mapPane: MapPane;
17
+ }
18
+ export interface OverlayProjection {
19
+ fromLatLngToOverlayPoint(latLng: LatLng): Point;
20
+ fromOverlayPointToLatLng(point: Point): LatLng;
21
+ }
22
+ export declare abstract class ElementOverlay {
23
+ map: BaseMap;
24
+ private baidu;
25
+ private google;
26
+ private projection;
27
+ protected element: HTMLElement;
28
+ private mapPane;
29
+ constructor(map: BaseMap, options: ElementOverlayOptions);
30
+ create(): HTMLElement;
31
+ draw(): void;
32
+ protected abstract onCreate(): HTMLElement;
33
+ protected abstract onDraw(projection: OverlayProjection): void;
34
+ getProjection(): OverlayProjection | undefined;
35
+ asBaidu(): BMap.OverlayV3;
36
+ asGoogle(): google.maps.OverlayView;
37
+ }
@@ -0,0 +1,68 @@
1
+ import { type Nullable } from 'tg-commons';
2
+ import type { Point } from '../../types';
3
+ import { MapPane } from './element-overlay';
4
+ export type GoogleLabel = InstanceType<ReturnType<typeof createGoogleLabelClass>>;
5
+ export declare function createGoogleLabel(element: HTMLElement, position: Nullable<google.maps.LatLng>, offset?: Point, mapPane?: MapPane, zIndex?: number): {
6
+ container: HTMLElement;
7
+ position: Nullable<google.maps.LatLng>;
8
+ offset?: Point | undefined;
9
+ _mapPane: MapPane;
10
+ setZIndex(zIndex: number): void;
11
+ setElement(element: HTMLElement): void;
12
+ onAdd(): void;
13
+ draw(): void;
14
+ onRemove(): void;
15
+ setPosition(position: Nullable<google.maps.LatLng>): void;
16
+ getPosition(): Nullable<google.maps.LatLng>;
17
+ setOffset(offset: Point): void;
18
+ getOffset(): Point | undefined;
19
+ getVisible(): boolean;
20
+ setVisible(visible: boolean): void;
21
+ getMap(): google.maps.Map | null | google.maps.StreetViewPanorama;
22
+ getPanes(): google.maps.MapPanes | null;
23
+ getProjection(): google.maps.MapCanvasProjection;
24
+ setMap(map: google.maps.Map | null | google.maps.StreetViewPanorama): void;
25
+ addListener(eventName: string, handler: Function): google.maps.MapsEventListener;
26
+ bindTo(key: string, target: google.maps.MVCObject, targetKey?: string | null, noNotify?: boolean): void;
27
+ get(key: string): any;
28
+ notify(key: string): void;
29
+ set(key: string, value: any): void;
30
+ setValues(values?: object | null): void;
31
+ unbind(key: string): void;
32
+ unbindAll(): void;
33
+ };
34
+ /** 打开页面时 google.maps.OverlayView 并没有加载, 故需要将GoogleLabel类写到方法中去 */
35
+ declare function createGoogleLabelClass(): {
36
+ new (element: HTMLElement, position: Nullable<google.maps.LatLng>, offset?: Point | undefined, _mapPane?: MapPane, zIndex?: number): {
37
+ container: HTMLElement;
38
+ position: Nullable<google.maps.LatLng>;
39
+ offset?: Point | undefined;
40
+ _mapPane: MapPane;
41
+ setZIndex(zIndex: number): void;
42
+ setElement(element: HTMLElement): void;
43
+ onAdd(): void;
44
+ draw(): void;
45
+ onRemove(): void;
46
+ setPosition(position: Nullable<google.maps.LatLng>): void;
47
+ getPosition(): Nullable<google.maps.LatLng>;
48
+ setOffset(offset: Point): void;
49
+ getOffset(): Point | undefined;
50
+ getVisible(): boolean;
51
+ setVisible(visible: boolean): void;
52
+ getMap(): google.maps.Map | null | google.maps.StreetViewPanorama;
53
+ getPanes(): google.maps.MapPanes | null;
54
+ getProjection(): google.maps.MapCanvasProjection;
55
+ setMap(map: google.maps.Map | null | google.maps.StreetViewPanorama): void;
56
+ addListener(eventName: string, handler: Function): google.maps.MapsEventListener;
57
+ bindTo(key: string, target: google.maps.MVCObject, targetKey?: string | null, noNotify?: boolean): void;
58
+ get(key: string): any;
59
+ notify(key: string): void;
60
+ set(key: string, value: any): void;
61
+ setValues(values?: object | null): void;
62
+ unbind(key: string): void;
63
+ unbindAll(): void;
64
+ };
65
+ preventMapHitsAndGesturesFrom(this: any, element: Element): void;
66
+ preventMapHitsFrom(this: any, element: Element): void;
67
+ };
68
+ export {};
@@ -0,0 +1,122 @@
1
+ import type { Point, Size } from '../../types';
2
+ export type BaiduIcon = BMap.Icon & {
3
+ __icon__?: Icon;
4
+ };
5
+ export type BaiduSymbolIcon = BMap.Symbol & {
6
+ __icon__?: SymbolIcon;
7
+ };
8
+ export type BaiduUnionIcon = BaiduIcon | BaiduSymbolIcon;
9
+ export type UnionIcon = Icon | SymbolIcon;
10
+ export declare const UnionIcon: {
11
+ toGoogle: (icon: UnionIcon) => google.maps.Icon | google.maps.Symbol;
12
+ toBaidu: (icon: UnionIcon) => BaiduIcon | BaiduSymbolIcon;
13
+ };
14
+ /**
15
+ * 图片Icon
16
+ *
17
+ * 字面量形式, 使用起来会简单点, 目前没看出使用class形式的必要🤔
18
+ * */
19
+ export interface Icon {
20
+ readonly url: string;
21
+ /** 显示的图片区域大小 */
22
+ readonly size: Size;
23
+ /** 图片的显示区域的原点在图片中的坐标, 默认为(0, 0) */
24
+ readonly origin?: Point;
25
+ /** 图片显示到地图上的锚点, 默认为图标的底部中点 */
26
+ readonly anchor?: Point;
27
+ /** 缩放后的图片大小, 不传则不缩放 */
28
+ readonly scaledSize?: Size;
29
+ /** MarkerLabel的中心点相对图标左上角的坐标, 默认为图标的中心点 */
30
+ readonly labelOrigin?: Point;
31
+ }
32
+ export declare namespace Icon {
33
+ function toGoogle(icon: Icon): google.maps.Icon;
34
+ function toBaidu(icon: Icon): BaiduIcon;
35
+ }
36
+ /** 简单的矢量Icon */
37
+ export interface SymbolIcon {
38
+ readonly path: string | SymbolPath;
39
+ readonly anchor?: Point;
40
+ readonly fillColor?: string;
41
+ /** @default 0, 不显示填充色 */
42
+ readonly fillOpacity?: number;
43
+ readonly scale?: number;
44
+ readonly rotation?: number;
45
+ readonly strokeColor?: string;
46
+ /** @default 1, 显示stroke */
47
+ readonly strokeOpacity?: number;
48
+ /**
49
+ * 默认等于{@link scale}
50
+ * - google: 可以设为0
51
+ * - baidu: 不能设为0, 为0相当于使用默认值
52
+ */
53
+ readonly strokeWeight?: number;
54
+ /**
55
+ * baidu地图中Marker的Label的偏移量, 用来保证Label默认对齐到Marker的position
56
+ *
57
+ * 这个值的取值和如下参数相关, 但计算这个值的公式没找到...故只能运行时读取+手动设置:
58
+ * - {@link path}
59
+ * - {@link rotation}
60
+ * - {@link scale}
61
+ * - {@link strokeWeight}
62
+ * - {@link anchor}
63
+ *
64
+ * 详见{@link BaiduLabelOverlay.attachIcon}
65
+ *
66
+ * TODO: 使用矩阵运行时计算偏移量
67
+ */
68
+ readonly baiduLabelOffset?: Point;
69
+ }
70
+ export declare namespace SymbolIcon {
71
+ function toGoogle(icon: SymbolIcon): google.maps.Symbol;
72
+ function toBaidu(icon: SymbolIcon): BaiduSymbolIcon;
73
+ }
74
+ export interface SymbolPath {
75
+ baidu(): BMap.SymbolShapeType;
76
+ google(): google.maps.SymbolPath;
77
+ toString(): string;
78
+ }
79
+ /** 模拟一个SymbolPath的枚举对象 */
80
+ export declare const SymbolPath: {
81
+ readonly CIRCLE: {
82
+ readonly baidu: () => number;
83
+ readonly google: () => google.maps.SymbolPath.CIRCLE;
84
+ };
85
+ readonly BACKWARD_CLOSED_ARROW: {
86
+ readonly baidu: () => number;
87
+ readonly google: () => google.maps.SymbolPath.BACKWARD_CLOSED_ARROW;
88
+ };
89
+ readonly BACKWARD_OPEN_ARROW: {
90
+ readonly baidu: () => number;
91
+ readonly google: () => google.maps.SymbolPath.BACKWARD_OPEN_ARROW;
92
+ };
93
+ readonly FORWARD_CLOSED_ARROW: {
94
+ readonly baidu: () => number;
95
+ readonly google: () => google.maps.SymbolPath.FORWARD_CLOSED_ARROW;
96
+ };
97
+ readonly FORWARD_OPEN_ARROW: {
98
+ readonly baidu: () => number;
99
+ readonly google: () => google.maps.SymbolPath.FORWARD_OPEN_ARROW;
100
+ };
101
+ };
102
+ /** 矢量Icon序列 */
103
+ export interface IconSequence {
104
+ /** 矢量Icon */
105
+ icon: SymbolIcon;
106
+ /** @default false */
107
+ fixedRotation?: boolean;
108
+ /**
109
+ * 相对起点的位置, 取值可以是像素或百分比
110
+ * @default 100%
111
+ */
112
+ offset?: string;
113
+ /**
114
+ * 重复显示是的间距, 取值可以是像素或百分比;
115
+ * 若和{@link offset}同时设置, 只有{@link repeat}会生效
116
+ */
117
+ repeat?: string;
118
+ }
119
+ export declare namespace IconSequence {
120
+ function toGoogle(value: IconSequence): google.maps.IconSequence;
121
+ function toBaidu(value: IconSequence): BMap.IconSequence;
122
+ }
@@ -0,0 +1,60 @@
1
+ import type { Tg } from '../../event';
2
+ import { CoordType, LatLng } from '../../lat-lng';
3
+ import type { Point } from '../../types';
4
+ import type { BaiduMap } from '../baidu-map';
5
+ import type { GoogleMap } from '../google-map';
6
+ import { type BaiduInfoBox } from './baidu-info-box';
7
+ import './google-info.scss';
8
+ import { InfoWindow } from './info-window';
9
+ import type { BaiduMarker, GoogleMarker, Marker } from './marker';
10
+ import { BaiduOverlay } from './overlay';
11
+ export type InfoBoxEventMap = {
12
+ closeclick: Tg.Event;
13
+ };
14
+ /**
15
+ * 初始偏移量同{@link InfoWindow}, 底部中点对齐position
16
+ */
17
+ export interface InfoBoxOptions {
18
+ content: HTMLElement;
19
+ position?: LatLng;
20
+ offset?: Point;
21
+ zIndex?: number;
22
+ maxWidth?: number;
23
+ borderClass?: string;
24
+ }
25
+ /** {@macros info_window_vs_box} */
26
+ export interface InfoBox extends Tg.EventTarget {
27
+ open(anchor?: Marker): void;
28
+ close(): void;
29
+ getPosition(): LatLng;
30
+ setPosition(position: LatLng): void;
31
+ setMaxWidth(maxWidth: number): void;
32
+ setZIndex(zIndex: number): void;
33
+ }
34
+ /** 虽然叫"Overlay", 但并没有继承Overlay... */
35
+ export type InfoBoxOverlay = InfoBox & Tg.EventTargetTyped<InfoBox, InfoBoxEventMap>;
36
+ export declare class BaiduInfoBoxOverlay extends BaiduOverlay<BaiduInfoBox> implements InfoBox {
37
+ private baiduMap;
38
+ static create(this: BaiduMap, options: InfoBoxOptions): BaiduInfoBoxOverlay;
39
+ constructor(innerOverlay: BaiduInfoBox, coordType: CoordType, baiduMap: BaiduMap);
40
+ open(anchor?: BaiduMarker): void;
41
+ close(): void;
42
+ getPosition(): LatLng;
43
+ setPosition(position: LatLng): void;
44
+ setMaxWidth(maxWidth: number): void;
45
+ setZIndex(zIndex: number): void;
46
+ }
47
+ export declare class GoogleInfoBoxOverlay extends InfoWindow implements InfoBox {
48
+ inner: google.maps.InfoWindow;
49
+ private coordType;
50
+ private map;
51
+ static create(this: GoogleMap, options: InfoBoxOptions): GoogleInfoBoxOverlay;
52
+ constructor(inner: google.maps.InfoWindow, coordType: CoordType, map: GoogleMap);
53
+ open(anchor?: GoogleMarker | undefined): void;
54
+ close(): void;
55
+ getPosition(): LatLng;
56
+ setPosition(position: LatLng): void;
57
+ isOpen(): boolean;
58
+ setMaxWidth(maxWidth: number): void;
59
+ setZIndex(zIndex: number): void;
60
+ }