tg-map-core 4.1.4 → 4.1.5

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 (46) hide show
  1. package/dist/src/index.d.ts +3 -2
  2. package/dist/src/map/event-target.d.ts +2 -3
  3. package/dist/src/map/lat-lng.d.ts +2 -0
  4. package/dist/src/map/map/baidu-map.d.ts +2 -0
  5. package/dist/src/map/map/controls/control.d.ts +17 -0
  6. package/dist/src/map/map/controls/map-type.control.d.ts +5 -1
  7. package/dist/src/map/map/controls/scale.control.d.ts +3 -2
  8. package/dist/src/map/map/controls/zoom.control.d.ts +15 -2
  9. package/dist/src/map/map/extra/marker-clusterer.d.ts +75 -5
  10. package/dist/src/map/map/google-map.d.ts +2 -0
  11. package/dist/src/map/map/here-map.d.ts +2 -0
  12. package/dist/src/map/map/map-options.d.ts +24 -2
  13. package/dist/src/map/map/map.d.ts +7 -3
  14. package/dist/src/map/map/overlay/baidu-info-box.d.ts +15 -6
  15. package/dist/src/map/map/overlay/circle.d.ts +10 -1
  16. package/dist/src/map/map/overlay/icon.d.ts +34 -2
  17. package/dist/src/map/map/overlay/info-box.d.ts +36 -4
  18. package/dist/src/map/map/overlay/info-window.d.ts +28 -2
  19. package/dist/src/map/map/overlay/label.d.ts +19 -4
  20. package/dist/src/map/map/overlay/marker-label.d.ts +7 -0
  21. package/dist/src/map/map/overlay/marker.d.ts +46 -5
  22. package/dist/src/map/map/overlay/overlay.d.ts +9 -1
  23. package/dist/src/map/map/overlay/polygon.d.ts +8 -1
  24. package/dist/src/map/map/overlay/polyline.d.ts +8 -1
  25. package/dist/src/map/map/overlay/rectangle.d.ts +9 -1
  26. package/dist/src/map/map/overlay/shape.d.ts +12 -2
  27. package/dist/src/map/map/talks-map.d.ts +33 -29
  28. package/dist/src/map/map-config.d.ts +11 -2
  29. package/dist/src/map/map-factory.d.ts +5 -1
  30. package/dist/src/map/unions.d.ts +5 -1
  31. package/dist/src/utils/arrays.d.ts +8 -0
  32. package/dist/src/utils/baidu-utils.d.ts +25 -0
  33. package/dist/src/utils/objects.d.ts +2 -2
  34. package/dist/src/{map/talks → utils}/talks-layers.d.ts +3 -3
  35. package/dist/src/utils/talks-utils.d.ts +24 -0
  36. package/dist/src/utils/utils.d.ts +5 -0
  37. package/dist/src/utils/values.d.ts +6 -0
  38. package/dist/tg-map-core.cjs +6761 -5498
  39. package/dist/tg-map-core.css +1 -2
  40. package/dist/tg-map-core.mjs +6747 -5499
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +5 -3
  43. package/src/map/dts/baidu.d.ts +9 -0
  44. package/src/map/dts/maptalks.d.ts +74 -2
  45. package/src/map/dts/maptalks.markercluster.d.ts +35 -0
  46. package/dist/src/map/talks/talks-utils.d.ts +0 -7
@@ -35,10 +35,9 @@ export * from './map/map/overlay/polygon';
35
35
  export * from './map/map/overlay/polyline';
36
36
  export * from './map/map/overlay/rectangle';
37
37
  export * from './map/map/talks-map';
38
- export * from './map/talks/talks-layers';
39
- export * from './map/talks/talks-utils';
40
38
  export * from './map/types';
41
39
  export * from './utils/arrays';
40
+ export { hideBaiduMapUnauthWarn } from './utils/baidu-utils';
42
41
  export * from './utils/formatter';
43
42
  export * from './utils/map-utils';
44
43
  export * from './utils/mapped-types';
@@ -46,5 +45,7 @@ export * from './utils/maps-utils';
46
45
  export { Objects } from './utils/objects';
47
46
  export * from './utils/spherical-utils';
48
47
  export * from './utils/strings';
48
+ export * from './utils/talks-layers';
49
+ export * from './utils/talks-utils';
49
50
  export * from './utils/utils';
50
51
  export * from './utils/values';
@@ -1,8 +1,7 @@
1
- import * as maptalks from 'maptalks';
2
1
  import { type Tg } from './event';
3
2
  import { type CoordTypeSupplier } from './lat-lng';
4
3
  import type { AbstractMapEventMap, BaseMap } from './map/map';
5
- import type { UnionBaiduEventTarget, UnionGoogleEventTarget } from './unions';
4
+ import type { UnionBaiduEventTarget, UnionGoogleEventTarget, UnionTalksEventTarget } from './unions';
6
5
  /**
7
6
  * 移除事件监听的函数
8
7
  *
@@ -62,7 +61,7 @@ export declare class BaiduEventTargetDelegate<T extends UnionBaiduEventTarget =
62
61
  addEventListener(type: string, listener: Tg.EventListener): void;
63
62
  removeEventListener(type: string, listener: Tg.EventListener): void;
64
63
  }
65
- export declare class TalksEventTargetDelegate<T extends maptalks.Eventable = maptalks.Eventable> extends AbstractEventTargetDelegate<T> {
64
+ export declare class TalksEventTargetDelegate<T extends UnionTalksEventTarget = UnionTalksEventTarget> extends AbstractEventTargetDelegate<T> {
66
65
  static EVENT_TYPE_MAP: {
67
66
  'center-changed': string;
68
67
  'zoom-changed': string;
@@ -117,6 +117,7 @@ export declare class LatLngBounds {
117
117
  static from(...positions: LatLng[]): LatLngBounds;
118
118
  static fromGoogle(bounds: google.maps.LatLngBounds, coord: CoordType): LatLngBounds;
119
119
  static fromBaidu(bounds: BMap.Bounds, coord: CoordType): LatLngBounds;
120
+ static fromTalks(extent: maptalks.Extent, coord: CoordType): LatLngBounds;
120
121
  static create(sw: LatLng, ne: LatLng): LatLngBounds;
121
122
  coord: CoordType;
122
123
  /**
@@ -138,6 +139,7 @@ export declare class LatLngBounds {
138
139
  toGoogle(coord: CoordType): google.maps.LatLngBounds;
139
140
  toBaidu(coord: CoordType): BMap.Bounds;
140
141
  toBaiduArray(coord: CoordType): BMap.Point[];
142
+ toTalks(coord: CoordType): maptalks.Extent;
141
143
  }
142
144
  export declare namespace LatLngBounds {
143
145
  class Builder {
@@ -36,6 +36,8 @@ export declare class BaiduMap extends BaseMap {
36
36
  removeEventListener<K extends keyof AbstractMapEventMap>(type: K, listener: (event: AbstractMapEventMap[K]) => void): void;
37
37
  fromContainerPointToLatLng(point: Point): LatLng;
38
38
  fromLatLngToContainerPoint(latLng: LatLng): Point;
39
+ setHideLogo(hideLogo: boolean): void;
40
+ setFractionalZoom(enabled: boolean): void;
39
41
  setDefaultCursor(cursor: string): void;
40
42
  setDraggable(draggable: boolean): void;
41
43
  setDoubleClickZoom(enable: boolean): void;
@@ -1,8 +1,10 @@
1
+ import * as maptalks from 'maptalks';
1
2
  import { KeyValue } from '../../../utils/values';
2
3
  import type { UnionControl } from '../../unions';
3
4
  import type { BaiduMap } from '../baidu-map';
4
5
  import type { GoogleMap } from '../google-map';
5
6
  import type { AbstractMap } from '../map';
7
+ import type { TalksMap } from '../talks-map';
6
8
  export declare enum ControlPosition {
7
9
  /** 左上 */
8
10
  TOP_LEFT = "top-left",
@@ -24,6 +26,7 @@ export declare enum ControlPosition {
24
26
  export declare namespace ControlPositionConverter {
25
27
  function getBaidu(): KeyValue<ControlPosition, number>;
26
28
  function getGoogle(): KeyValue<ControlPosition, google.maps.ControlPosition>;
29
+ function getTalks(): KeyValue<ControlPosition, maptalks.ControlPositionType>;
27
30
  }
28
31
  /**
29
32
  * 自定义的Control
@@ -110,3 +113,17 @@ export declare class GoogleControl extends AbstractControl {
110
113
  protected onCreateOptions(): any;
111
114
  protected tryUpdateOptions(): void;
112
115
  }
116
+ export declare class TalksControl<CONTROL extends maptalks.control.Control> extends AbstractControl {
117
+ protected inner: CONTROL;
118
+ /** {@link maptalks.DomPositionType}到ControlPosition的反向转换比较麻烦, 故直接保存设置的position */
119
+ private position;
120
+ constructor(inner: CONTROL,
121
+ /** {@link maptalks.DomPositionType}到ControlPosition的反向转换比较麻烦, 故直接保存设置的position */
122
+ position: ControlPosition);
123
+ isVisible(): boolean;
124
+ setVisible(visible: boolean): void;
125
+ getPosition(): ControlPosition;
126
+ setPosition(position: ControlPosition): void;
127
+ addTo(map: TalksMap): void;
128
+ removeFrom(): void;
129
+ }
@@ -1,7 +1,8 @@
1
1
  import type { BaiduMap } from '../baidu-map';
2
2
  import type { GoogleMap } from '../google-map';
3
3
  import { MapType } from '../map-type';
4
- import { AbstractControl, BaiduControl, ControlPosition, GoogleControl } from './control';
4
+ import type { TalksMap } from '../talks-map';
5
+ import { AbstractControl, BaiduControl, ControlPosition, EmptyControl, GoogleControl } from './control';
5
6
  export interface MapTypeControl extends AbstractControl {
6
7
  }
7
8
  export declare enum MapTypeControlType {
@@ -27,3 +28,6 @@ export declare class GoogleMapTypeControl extends GoogleControl implements MapTy
27
28
  onCreateOptions(): any;
28
29
  addTo(map: GoogleMap): void;
29
30
  }
31
+ export declare class TalksMapTypeControl extends EmptyControl implements MapTypeControl {
32
+ static create(this: TalksMap, options: MapTypeControlOptions): TalksMapTypeControl;
33
+ }
@@ -1,7 +1,8 @@
1
+ import * as maptalks from 'maptalks';
1
2
  import type { BaiduMap } from '../baidu-map';
2
3
  import type { GoogleMap } from '../google-map';
3
4
  import type { TalksMap } from '../talks-map';
4
- import { AbstractControl, BaiduControl, ControlPosition, EmptyControl, GoogleControl } from './control';
5
+ import { AbstractControl, BaiduControl, ControlPosition, GoogleControl, TalksControl } from './control';
5
6
  export interface ScaleControl extends AbstractControl {
6
7
  }
7
8
  export interface ScaleControlOptions {
@@ -14,6 +15,6 @@ export declare class GoogleScaleControl extends GoogleControl implements ScaleCo
14
15
  static create(this: GoogleMap, options: ScaleControlOptions): GoogleScaleControl;
15
16
  constructor(position?: ControlPosition);
16
17
  }
17
- export declare class TalksScaleControl extends EmptyControl implements ScaleControl {
18
+ export declare class TalksScaleControl extends TalksControl<maptalks.control.Scale> implements ScaleControl {
18
19
  static create(this: TalksMap, options: ScaleControlOptions): TalksScaleControl;
19
20
  }
@@ -1,19 +1,32 @@
1
+ import * as maptalks from 'maptalks';
1
2
  import type { BaiduMap } from '../baidu-map';
2
3
  import type { GoogleMap } from '../google-map';
3
4
  import type { TalksMap } from '../talks-map';
4
- import { AbstractControl, BaiduControl, ControlPosition, EmptyControl, GoogleControl } from './control';
5
+ import { AbstractControl, BaiduControl, ControlPosition, GoogleControl, TalksControl } from './control';
5
6
  export interface ZoomControl extends AbstractControl {
7
+ setShowZoomLevel(show: boolean): void;
6
8
  }
7
9
  export interface ZoomControlOptions {
8
10
  position?: ControlPosition;
11
+ /**
12
+ * 显示当前zoom等级
13
+ * ## 不同行为
14
+ * - baidu: 不支持
15
+ * - google: 不支持
16
+ * - talks: 支持,默认显示
17
+ */
18
+ showZoomLevel?: boolean;
9
19
  }
10
20
  export declare class BaiduZoomControl extends BaiduControl<BMap.NavigationControl> implements ZoomControl {
11
21
  static create(this: BaiduMap, options: ZoomControlOptions): BaiduZoomControl;
22
+ setShowZoomLevel(_show: boolean): void;
12
23
  }
13
24
  export declare class GoogleZoomControl extends GoogleControl implements ZoomControl {
14
25
  static create(this: GoogleMap, options: ZoomControlOptions): GoogleZoomControl;
15
26
  constructor(position?: ControlPosition);
27
+ setShowZoomLevel(_show: boolean): void;
16
28
  }
17
- export declare class TalksZoomControl extends EmptyControl implements ZoomControl {
29
+ export declare class TalksZoomControl extends TalksControl<maptalks.control.Zoom> implements ZoomControl {
18
30
  static create(this: TalksMap, options: ZoomControlOptions): TalksZoomControl;
31
+ setShowZoomLevel(show: boolean): void;
19
32
  }
@@ -1,27 +1,86 @@
1
1
  import GMarkerClusterer from '@google/markerclusterer';
2
2
  import BMarkerClusterer from 'bmaplib.markerclusterer';
3
+ import { ClusterLayer } from 'maptalks.markercluster';
3
4
  import type { Point, Size } from '../../types';
4
5
  import type { BaiduMap } from '../baidu-map';
5
6
  import type { GoogleMap } from '../google-map';
6
7
  import type { AbstractMap } from '../map';
7
- import type { MarkerOverlay } from '../overlay/marker';
8
+ import type { MarkerOverlay, TalksMarker } from '../overlay/marker';
9
+ import type { TalksMap } from '../talks-map';
8
10
  export interface MarkerClustererOptions {
9
11
  markers?: MarkerOverlay[];
12
+ /**
13
+ * {@template marker_clusterer_grid_size}
14
+ * ## 不同行为
15
+ * - baidu: 默认60
16
+ * - google: 默认60
17
+ * - talks: 百度底图 默认60, 其他底图 默认100, 这样的默认值效果跟baidu/google的比较接近
18
+ * {@endtemplate}
19
+ */
10
20
  gridSize?: number;
11
21
  maxZoom?: number;
22
+ /**
23
+ * 生成聚合的最小数量, 默认为2
24
+ * ## 不同行为
25
+ * - baidu: 支持
26
+ * - google: 支持
27
+ * - talks: 不支持修改, 恒为2
28
+ */
12
29
  minClusterSize?: number;
30
+ /**
31
+ * ## 不同行为
32
+ * - baidu: 支持
33
+ * - google: 支持
34
+ * - talks: 不支持
35
+ */
13
36
  averageCenter?: boolean;
14
37
  styles?: ClusterIconStyle[];
38
+ /**
39
+ * 计算应该显示的{@link styles}的index, 若不设置, 则使用{@link ClusterIconStyle.minMarkersLength}中设置的值, 来决定应用哪个样式
40
+ *
41
+ * ## 不同行为
42
+ * - baidu: 支持
43
+ * - google: 支持
44
+ * - talks: 不支持, 请使用{@link ClusterIconStyle.minMarkersLength}替代
45
+ *
46
+ * @see createDefaultStylesIndexCalculator
47
+ * @see ClusterIconStyle.minMarkersLength
48
+ * */
15
49
  stylesIndexCalculator?: (markersLength: number, stylesLength: number) => number;
16
50
  zIndex?: number;
17
51
  }
18
52
  export interface ClusterIconStyle {
19
53
  url: string;
20
54
  size: Size;
55
+ /**
56
+ * 聚合图标的锚点, 默认居中
57
+ * @see Icon.anchor
58
+ * */
21
59
  anchor?: Point;
60
+ /**
61
+ * 图片的偏移值, 相当于CSS中的background-position属性
62
+ * @see Icon.origin
63
+ * */
22
64
  offset?: Point;
23
65
  textColor?: string;
24
66
  textSize?: number;
67
+ /**
68
+ * 样式生效的最小marker数量
69
+ * @see MarkerClustererOptions.stylesIndexCalculator
70
+ */
71
+ minMarkersLength?: number;
72
+ }
73
+ export interface MarkerClusterer {
74
+ /**
75
+ * 清除所有Marker
76
+ * @param removeFromMap 是否将Clusterer从地图上彻底移除, 默认true
77
+ */
78
+ clearMarkers(removeFromMap?: boolean): void;
79
+ addMarker(marker: MarkerOverlay): void;
80
+ removeMarker(marker: MarkerOverlay): boolean;
81
+ addMarkers(markers: MarkerOverlay[]): void;
82
+ removeMarkers(markers: MarkerOverlay[]): boolean;
83
+ recreate(): void;
25
84
  }
26
85
  /**
27
86
  * ## GMarkerClusterer 和 BMarkerClusterer 的区别
@@ -45,12 +104,12 @@ export interface ClusterIconStyle {
45
104
  * H.clustering.Provider(here的点聚合工具类)
46
105
  * - 和baidu/google的api有很大不同, 但总体倾向于baidu的实现, 每次修改坐标点都触发重新计算点聚合
47
106
  */
48
- export declare abstract class MarkerClusterer {
107
+ export declare abstract class AbstractMarkerClusterer implements MarkerClusterer {
49
108
  map: AbstractMap;
50
109
  abstract inner: any;
51
110
  constructor(map: AbstractMap);
52
111
  /** baidu/google 拥有相同的函数名 */
53
- clearMarkers(): void;
112
+ clearMarkers(_removeFromMap?: boolean): void;
54
113
  /** @see clearMarkers */
55
114
  addMarker(marker: MarkerOverlay): void;
56
115
  /** @see clearMarkers */
@@ -61,13 +120,24 @@ export declare abstract class MarkerClusterer {
61
120
  removeMarkers(markers: MarkerOverlay[]): boolean;
62
121
  abstract recreate(): void;
63
122
  }
64
- export declare class BaiduMarkerClusterer extends MarkerClusterer {
123
+ export declare class BaiduMarkerClusterer extends AbstractMarkerClusterer {
65
124
  inner: BMarkerClusterer;
66
125
  constructor(map: BaiduMap, options: MarkerClustererOptions);
67
126
  recreate(): void;
68
127
  }
69
- export declare class GoogleMarkerClusterer extends MarkerClusterer {
128
+ export declare class GoogleMarkerClusterer extends AbstractMarkerClusterer {
70
129
  inner: GMarkerClusterer;
71
130
  constructor(map: GoogleMap, options: MarkerClustererOptions);
72
131
  recreate(): void;
73
132
  }
133
+ export declare class TalksMarkerClusterer implements MarkerClusterer {
134
+ private map;
135
+ inner: ClusterLayer;
136
+ constructor(map: TalksMap, options: MarkerClustererOptions);
137
+ clearMarkers(removeFromMap?: boolean): void;
138
+ addMarker(marker: TalksMarker): void;
139
+ removeMarker(marker: TalksMarker): boolean;
140
+ addMarkers(markers: TalksMarker[]): void;
141
+ removeMarkers(markers: TalksMarker[]): boolean;
142
+ recreate(): void;
143
+ }
@@ -35,6 +35,8 @@ export declare class GoogleMap extends BaseMap {
35
35
  get coordType(): import("../lat-lng").CoordType;
36
36
  fromContainerPointToLatLng(point: Point): LatLng;
37
37
  fromLatLngToContainerPoint(latLng: LatLng): Point;
38
+ setHideLogo(hideLogo: boolean): void;
39
+ setFractionalZoom(enabled: boolean): void;
38
40
  setDefaultCursor(cursor: string): void;
39
41
  setDraggable(draggable: boolean): void;
40
42
  setDoubleClickZoom(enable: boolean): void;
@@ -33,6 +33,8 @@ export declare class HereMap extends BaseMap {
33
33
  get coordType(): CoordType;
34
34
  getCenter(): LatLng;
35
35
  setCenter(latlng: LatLng): void;
36
+ setHideLogo(hideLogo: boolean): void;
37
+ setFractionalZoom(enabled: boolean): void;
36
38
  setGestureHandling(gestureHandling: GestureHandlingOptions): void;
37
39
  fromContainerPointToLatLng(point: Point): LatLng;
38
40
  fromLatLngToContainerPoint(latLng: LatLng): Point;
@@ -21,16 +21,29 @@ export declare enum GestureHandlingOptions {
21
21
  export interface MapOptions {
22
22
  /** 中心点 */
23
23
  center: LatLng;
24
- /** 缩放等级, 必须是整数 */
24
+ /** 缩放等级 */
25
25
  zoom: number;
26
+ /**
27
+ * 小数级的zoom缩放
28
+ *
29
+ * ## 不同行为
30
+ * - baidu: 不支持
31
+ * - baidu-gl: 支持, 但不能关闭
32
+ * - google: 支持
33
+ * - talks: 支持
34
+ *
35
+ * @default false
36
+ */
37
+ fractionalZoom?: boolean;
26
38
  /**
27
39
  * ## 不同行为
28
40
  * - baidu: 只支持单窗口
29
41
  * - google: 支持单窗口或多窗口, 默认多窗口
42
+ * - talks: 支持单窗口或多窗口, 默认多窗口
30
43
  *
31
44
  * 要显示多个弹窗, 推荐使用InfoBox替代
32
45
  *
33
- * {@macros info_window_vs_box}
46
+ * {@macro info_window_vs_box}
34
47
  */
35
48
  infoWindowMode?: InfoWindowMode;
36
49
  gestureHandling?: GestureHandlingOptions;
@@ -38,6 +51,15 @@ export interface MapOptions {
38
51
  maxZoom?: number;
39
52
  mapStyle?: MapStyle;
40
53
  buildInMapTypeId?: BuildInMapTypeId;
54
+ /**
55
+ * 隐藏Logo
56
+ *
57
+ * ## 不同行为
58
+ * - baidu: 不支持, 目前通过在TgMap中通过修改class来实现类似效果
59
+ * - google: 不支持, 目前通过在TgMap中通过修改class来实现类似效果
60
+ * - talks: 支持
61
+ */
62
+ hideLogo?: boolean;
41
63
  }
42
64
  export declare namespace MapOptions {
43
65
  function create(options?: Partial<MapOptions>): MapOptions;
@@ -6,7 +6,7 @@ import type { Padding, Point } from '../types';
6
6
  import type { UnionMap } from '../unions';
7
7
  import type { AbstractControl, CustomControl } from './controls/control';
8
8
  import type { MapTypeControl, MapTypeControlOptions } from './controls/map-type.control';
9
- import type { ScaleControlOptions } from './controls/scale.control';
9
+ import type { ScaleControl, ScaleControlOptions } from './controls/scale.control';
10
10
  import type { StreetViewControl, StreetViewControlOptions } from './controls/street-view.control';
11
11
  import type { ZoomControl, ZoomControlOptions } from './controls/zoom.control';
12
12
  import type { Autocomplete, AutocompleteOptions } from './extra/autocomplete';
@@ -15,7 +15,7 @@ import type { MapUrls, MapUrlsOptions } from './extra/map-urls';
15
15
  import type { MarkerClusterer, MarkerClustererOptions } from './extra/marker-clusterer';
16
16
  import type { PlacesService, PlacesServiceOptions } from './extra/places-service';
17
17
  import type { SearchBox, SearchBoxOptions } from './extra/search-box';
18
- import type { GestureHandlingOptions, MapStyle } from './map-options';
18
+ import { type GestureHandlingOptions, type MapStyle } from './map-options';
19
19
  import type { BuildInMapTypeId, Layer, MapType, OverlayMapType } from './map-type';
20
20
  import type { CircleOptions, CircleOverlay } from './overlay/circle';
21
21
  import type { ElementOverlay } from './overlay/element-overlay';
@@ -131,6 +131,10 @@ export declare abstract class BaseMap implements AbstractMap {
131
131
  abstract fromContainerPointToLatLng(point: Point): LatLng;
132
132
  /** @see fromContainerPointToLatLng */
133
133
  abstract fromLatLngToContainerPoint(latLng: LatLng): Point;
134
+ /** @see MapOptions.hideLogo */
135
+ abstract setHideLogo(hideLogo: boolean): void;
136
+ /** @see MapOptions.fractionalZoom */
137
+ abstract setFractionalZoom(enabled: boolean): void;
134
138
  abstract setDefaultCursor(cursor: CSS.Property.Cursor): void;
135
139
  /**
136
140
  * ## 不同行为
@@ -190,7 +194,7 @@ export declare abstract class BaseMap implements AbstractMap {
190
194
  abstract createMapTypeControl(options: MapTypeControlOptions): MapTypeControl;
191
195
  abstract createZoomControl(options: ZoomControlOptions): ZoomControl;
192
196
  abstract createStreetViewControl(options: StreetViewControlOptions): StreetViewControl;
193
- abstract createScaleControl(options: ScaleControlOptions): ZoomControl;
197
+ abstract createScaleControl(options: ScaleControlOptions): ScaleControl;
194
198
  addControl(control: AbstractControl): void;
195
199
  removeControl(control: AbstractControl): void;
196
200
  getZoom(): number;
@@ -3,9 +3,7 @@ import './baidu-info-box.scss';
3
3
  import type { BMarker } from './marker';
4
4
  export type BaiduInfoBox = InstanceType<ReturnType<typeof createBaiduInfoBoxClass>>;
5
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;
6
+ elements: InfoBoxElements;
9
7
  map: BMap.Map | undefined;
10
8
  marker: BMarker | undefined;
11
9
  content: HTMLElement;
@@ -34,6 +32,19 @@ export declare function createBaiduInfoBox(content: HTMLElement, position?: BMap
34
32
  type: string;
35
33
  }): void;
36
34
  };
35
+ export declare class InfoBoxElements {
36
+ content: HTMLElement;
37
+ static OFFSET_Y: number;
38
+ container: HTMLElement;
39
+ border: HTMLElement;
40
+ inner: HTMLElement;
41
+ close: HTMLElement;
42
+ constructor(content: HTMLElement, zIndex?: number, maxWidth?: number, // google的InfoWindow的默认maxWidth就是654
43
+ borderClass?: string);
44
+ setZIndex(zIndex: number): void;
45
+ setMaxWidth(maxWidth: number): void;
46
+ setPosition(x: number, y: number): void;
47
+ }
37
48
  /**
38
49
  * {@template info_window_vs_box}
39
50
  * baidu自带的InfoWindow有如下问题:
@@ -47,9 +58,7 @@ export declare function createBaiduInfoBox(content: HTMLElement, position?: BMap
47
58
  */
48
59
  declare function createBaiduInfoBoxClass(): {
49
60
  new (content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: string): {
50
- container: HTMLElement;
51
- border: HTMLElement;
52
- inner: HTMLElement;
61
+ elements: InfoBoxElements;
53
62
  map: BMap.Map | undefined;
54
63
  marker: BMarker | undefined;
55
64
  content: HTMLElement;
@@ -1,10 +1,12 @@
1
+ import * as maptalks from 'maptalks';
1
2
  import type { Tg } from '../../event';
2
3
  import { EventHubEventTargetDelegate } from '../../event-target';
3
4
  import { LatLng } from '../../lat-lng';
4
5
  import type { BaiduMap } from '../baidu-map';
5
6
  import type { GoogleMap } from '../google-map';
7
+ import type { TalksMap } from '../talks-map';
6
8
  import type { Overlay } from './overlay';
7
- import { BaiduShape, GoogleShape, type Shape, type ShapeOptions } from './shape';
9
+ import { BaiduShape, GoogleShape, TalksShape, type Shape, type ShapeOptions } from './shape';
8
10
  export type CircleEventMap = {
9
11
  click: Tg.Event;
10
12
  dblclick: Tg.Event;
@@ -49,3 +51,10 @@ export declare class GoogleCircle extends GoogleShape<google.maps.Circle> implem
49
51
  setRadius(radius: number): void;
50
52
  getRadius(): number;
51
53
  }
54
+ export declare class TalksCircle extends TalksShape<maptalks.Circle> implements Circle {
55
+ static create(this: TalksMap, options: CircleOptions): TalksCircle;
56
+ setCenter(center: LatLng): void;
57
+ getCenter(): LatLng;
58
+ setRadius(radius: number): void;
59
+ getRadius(): number;
60
+ }
@@ -1,15 +1,19 @@
1
+ import type { maptalks } from '../../dts/maptalks';
1
2
  import type { Point, Size } from '../../types';
2
3
  export type BaiduIcon = BMap.Icon & {
3
4
  __icon__?: Icon;
4
5
  };
5
6
  export type BaiduSymbolIcon = BMap.Symbol & {
6
7
  __icon__?: SymbolIcon;
8
+ infoWindowAnchor?: BMap.Size;
9
+ infoWindowOffset?: BMap.Size;
7
10
  };
8
11
  export type BaiduUnionIcon = BaiduIcon | BaiduSymbolIcon;
9
12
  export type UnionIcon = Icon | SymbolIcon;
10
13
  export declare const UnionIcon: {
11
14
  toGoogle: (icon: UnionIcon) => google.maps.Icon | google.maps.Symbol;
12
15
  toBaidu: (icon: UnionIcon) => BaiduIcon | BaiduSymbolIcon;
16
+ toTalks: (icon: UnionIcon) => maptalks.FileMarkerSymbol | ((maptalks.VectorMarkerSymbol | maptalks.PathMarkerSymbol) & Pick<maptalks.VectorMarkerSymbol, "markerLineColor" | "markerLineOpacity" | "markerLineWidth" | "markerFill" | "markerFillOpacity">);
13
17
  };
14
18
  /**
15
19
  * 图片Icon
@@ -17,14 +21,32 @@ export declare const UnionIcon: {
17
21
  * 字面量形式, 使用起来会简单点, 目前没看出使用class形式的必要🤔
18
22
  * */
19
23
  export interface Icon {
24
+ /**
25
+ * 注意: talks, 若图片位于其他域名, 可能会影响点击事件的判断, 控制台报如下警告:
26
+ * `hit detect failed with tainted canvas, some geometries have external resources in another domain`
27
+ */
20
28
  readonly url: string;
21
29
  /** 显示的图片区域大小 */
22
30
  readonly size: Size;
23
- /** 图片的显示区域的原点在图片中的坐标, 默认为(0, 0) */
31
+ /**
32
+ * 图片的显示区域的原点在图片中的坐标, 默认为(0, 0)
33
+ *
34
+ * ## 不同行为
35
+ * - baidu: 支持
36
+ * - google: 支持
37
+ * - talks: 不支持
38
+ * */
24
39
  readonly origin?: Point;
25
40
  /** 图片显示到地图上的锚点, 默认为图标的底部中点 */
26
41
  readonly anchor?: Point;
27
- /** 缩放后的图片大小, 不传则不缩放 */
42
+ /**
43
+ * 缩放后的图片大小
44
+ *
45
+ * ## 不同行为
46
+ * - baidu: 支持, 默认不缩放
47
+ * - google: 支持, 默认不缩放
48
+ * - talks: 不支持, 总是缩放到和{@link size}一样
49
+ * */
28
50
  readonly scaledSize?: Size;
29
51
  /** MarkerLabel的中心点相对图标左上角的坐标, 默认为图标的中心点 */
30
52
  readonly labelOrigin?: Point;
@@ -32,6 +54,7 @@ export interface Icon {
32
54
  export declare namespace Icon {
33
55
  function toGoogle(icon: Icon): google.maps.Icon;
34
56
  function toBaidu(icon: Icon): BaiduIcon;
57
+ function toTalks(icon: Icon): maptalks.FileMarkerSymbol;
35
58
  }
36
59
  /** 简单的矢量Icon */
37
60
  export interface SymbolIcon {
@@ -66,14 +89,18 @@ export interface SymbolIcon {
66
89
  * TODO: 使用矩阵运行时计算偏移量
67
90
  */
68
91
  readonly baiduLabelOffset?: Point;
92
+ /** talks需要设置pathSize才能正确显示, 对应svg的viewBox属性, 默认24x24 */
93
+ readonly talksPathSize?: Size;
69
94
  }
70
95
  export declare namespace SymbolIcon {
71
96
  function toGoogle(icon: SymbolIcon): google.maps.Symbol;
72
97
  function toBaidu(icon: SymbolIcon): BaiduSymbolIcon;
98
+ function toTalks(icon: SymbolIcon): (maptalks.PathMarkerSymbol | maptalks.VectorMarkerSymbol) & Pick<maptalks.VectorMarkerSymbol, 'markerLineColor' | 'markerLineOpacity' | 'markerLineWidth' | 'markerFill' | 'markerFillOpacity'>;
73
99
  }
74
100
  export interface SymbolPath {
75
101
  baidu(): BMap.SymbolShapeType;
76
102
  google(): google.maps.SymbolPath;
103
+ talks(): maptalks.VectorMarkerSymbol['markerType'];
77
104
  toString(): string;
78
105
  }
79
106
  /** 模拟一个SymbolPath的枚举对象 */
@@ -81,22 +108,27 @@ export declare const SymbolPath: {
81
108
  readonly CIRCLE: {
82
109
  readonly baidu: () => number;
83
110
  readonly google: () => google.maps.SymbolPath.CIRCLE;
111
+ readonly talks: () => "ellipse";
84
112
  };
85
113
  readonly BACKWARD_CLOSED_ARROW: {
86
114
  readonly baidu: () => number;
87
115
  readonly google: () => google.maps.SymbolPath.BACKWARD_CLOSED_ARROW;
116
+ readonly talks: () => "triangle";
88
117
  };
89
118
  readonly BACKWARD_OPEN_ARROW: {
90
119
  readonly baidu: () => number;
91
120
  readonly google: () => google.maps.SymbolPath.BACKWARD_OPEN_ARROW;
121
+ readonly talks: () => "triangle";
92
122
  };
93
123
  readonly FORWARD_CLOSED_ARROW: {
94
124
  readonly baidu: () => number;
95
125
  readonly google: () => google.maps.SymbolPath.FORWARD_CLOSED_ARROW;
126
+ readonly talks: () => "triangle";
96
127
  };
97
128
  readonly FORWARD_OPEN_ARROW: {
98
129
  readonly baidu: () => number;
99
130
  readonly google: () => google.maps.SymbolPath.FORWARD_OPEN_ARROW;
131
+ readonly talks: () => "triangle";
100
132
  };
101
133
  };
102
134
  /** 矢量Icon序列 */
@@ -1,12 +1,14 @@
1
+ import * as maptalks from 'maptalks';
1
2
  import type { Tg } from '../../event';
2
3
  import { CoordType, LatLng } from '../../lat-lng';
3
- import type { Point } from '../../types';
4
+ import { Point } from '../../types';
4
5
  import type { BaiduMap } from '../baidu-map';
5
6
  import type { GoogleMap } from '../google-map';
6
- import { type BaiduInfoBox } from './baidu-info-box';
7
+ import type { TalksMap } from '../talks-map';
8
+ import { InfoBoxElements, type BaiduInfoBox } from './baidu-info-box';
7
9
  import './google-info.scss';
8
10
  import { InfoWindow } from './info-window';
9
- import type { BaiduMarker, GoogleMarker, Marker } from './marker';
11
+ import type { BaiduMarker, GoogleMarker, Marker, TalksMarker } from './marker';
10
12
  import { BaiduOverlay } from './overlay';
11
13
  export type InfoBoxEventMap = {
12
14
  closeclick: Tg.Event;
@@ -21,8 +23,15 @@ export interface InfoBoxOptions {
21
23
  zIndex?: number;
22
24
  maxWidth?: number;
23
25
  borderClass?: string;
26
+ /**
27
+ * ## 不同行为
28
+ * - baidu: 不支持autoPan
29
+ * - google: 支持
30
+ * - talks: 支持
31
+ */
32
+ disableAutoPan?: boolean;
24
33
  }
25
- /** {@macros info_window_vs_box} */
34
+ /** {@macro info_window_vs_box} */
26
35
  export interface InfoBox extends Tg.EventTarget {
27
36
  open(anchor?: Marker): void;
28
37
  close(): void;
@@ -58,3 +67,26 @@ export declare class GoogleInfoBoxOverlay extends InfoWindow implements InfoBox
58
67
  setMaxWidth(maxWidth: number): void;
59
68
  setZIndex(zIndex: number): void;
60
69
  }
70
+ export declare class TalksInfoBoxOverlay extends InfoWindow implements InfoBox {
71
+ inner: maptalks.ui.InfoWindow;
72
+ private coordType;
73
+ private map;
74
+ private elements;
75
+ private state;
76
+ static create(this: TalksMap, options: InfoBoxOptions): TalksInfoBoxOverlay;
77
+ private marker;
78
+ private pendingShowAction;
79
+ private onVisibleChangeInCluster;
80
+ constructor(inner: maptalks.ui.InfoWindow, coordType: CoordType, map: TalksMap, elements: InfoBoxElements, state: {
81
+ position?: LatLng;
82
+ offset: Point;
83
+ });
84
+ open(anchor?: TalksMarker): void;
85
+ private detachMarker;
86
+ close(): void;
87
+ getPosition(): LatLng;
88
+ setPosition(position: LatLng): void;
89
+ isOpen(): boolean;
90
+ setMaxWidth(maxWidth: number): void;
91
+ setZIndex(zIndex: number): void;
92
+ }