tg-map-core 4.1.7 → 4.2.0

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.
@@ -66,6 +66,11 @@ export declare class TalksEventTargetDelegate<T extends UnionTalksEventTarget =
66
66
  'center-changed': string;
67
67
  'zoom-changed': string;
68
68
  } & Record<string, string | undefined>;
69
+ private eventTypeMap;
70
+ /**
71
+ * @param eventTypeMap 额外的事件类型映射
72
+ */
73
+ constructor(inner: T, coordTypeSupplier: CoordTypeSupplier, eventTypeMap?: Record<string, string>);
69
74
  addEventListener(type: string, listener: Tg.EventListener): void;
70
75
  removeEventListener(type: string, listener: Tg.EventListener): void;
71
76
  }
@@ -20,7 +20,6 @@ import { BaiduInfoBoxOverlay } from './overlay/info-box';
20
20
  import { BaiduInfoWindow } from './overlay/info-window';
21
21
  import { BaiduLabelOverlay } from './overlay/label';
22
22
  import { BaiduMarker } from './overlay/marker';
23
- import type { BaiduOverlay } from './overlay/overlay';
24
23
  import { BaiduPolygon } from './overlay/polygon';
25
24
  import { BaiduPolyline } from './overlay/polyline';
26
25
  import { BaiduRectangle } from './overlay/rectangle';
@@ -59,8 +58,6 @@ export declare class BaiduMap extends BaseMap {
59
58
  getBounds(): LatLngBounds;
60
59
  addElementOverlay(overlay: ElementOverlay): void;
61
60
  removeElementOverlay(overlay: ElementOverlay): void;
62
- addOverlay(overlay: BaiduOverlay): void;
63
- removeOverlay(overlay: BaiduOverlay): void;
64
61
  addCustomControl(control: CustomControl): void;
65
62
  removeCustomControl(control: CustomControl): void;
66
63
  createLabel: typeof BaiduLabelOverlay.create;
@@ -20,7 +20,6 @@ import { GoogleInfoBoxOverlay } from './overlay/info-box';
20
20
  import { GoogleInfoWindow } from './overlay/info-window';
21
21
  import { GoogleLabelOverlay } from './overlay/label';
22
22
  import { GoogleMarker } from './overlay/marker';
23
- import type { GoogleOverlay } from './overlay/overlay';
24
23
  import { GooglePolygon } from './overlay/polygon';
25
24
  import { GooglePolyline } from './overlay/polyline';
26
25
  import { GoogleRectangle } from './overlay/rectangle';
@@ -58,8 +57,6 @@ export declare class GoogleMap extends BaseMap {
58
57
  getBounds(): LatLngBounds;
59
58
  addElementOverlay(overlay: ElementOverlay): void;
60
59
  removeElementOverlay(overlay: ElementOverlay): void;
61
- addOverlay(overlay: GoogleOverlay): void;
62
- removeOverlay(overlay: GoogleOverlay): void;
63
60
  addCustomControl(control: CustomControl): void;
64
61
  removeCustomControl(control: CustomControl): void;
65
62
  createLabel: typeof GoogleLabelOverlay.create;
@@ -20,7 +20,6 @@ import type { InfoBoxOptions, InfoBoxOverlay } from './overlay/info-box';
20
20
  import type { InfoWindowOptions, InfoWindowOverlay } from './overlay/info-window';
21
21
  import type { LabelOptions, LabelOverlay } from './overlay/label';
22
22
  import type { MarkerOptions, MarkerOverlay } from './overlay/marker';
23
- import type { Overlay } from './overlay/overlay';
24
23
  import type { PolygonOptions, PolygonOverlay } from './overlay/polygon';
25
24
  import type { PolylineOptions, PolylineOverlay } from './overlay/polyline';
26
25
  import type { RectangleOptions, RectangleOverlay } from './overlay/rectangle';
@@ -55,8 +54,6 @@ export declare class HereMap extends BaseMap {
55
54
  getBounds(): LatLngBounds;
56
55
  addElementOverlay(overlay: ElementOverlay): void;
57
56
  removeElementOverlay(overlay: ElementOverlay): void;
58
- addOverlay(overlay: Overlay<unknown>): void;
59
- removeOverlay(overlay: Overlay<unknown>): void;
60
57
  createMarker(options: MarkerOptions): MarkerOverlay;
61
58
  createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
62
59
  createHeatmap(options: HeatmapOptions): Heatmap;
@@ -168,8 +168,8 @@ export declare abstract class BaseMap implements AbstractMap {
168
168
  abstract getBounds(): LatLngBounds;
169
169
  abstract addElementOverlay(overlay: ElementOverlay): void;
170
170
  abstract removeElementOverlay(overlay: ElementOverlay): void;
171
- abstract addOverlay(overlay: Overlay): void;
172
- abstract removeOverlay(overlay: Overlay): void;
171
+ addOverlay(overlay: Overlay): void;
172
+ removeOverlay(overlay: Overlay): void;
173
173
  abstract createMarker(options: MarkerOptions): MarkerOverlay;
174
174
  abstract createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
175
175
  abstract createHeatmap(options: HeatmapOptions): Heatmap;
@@ -1,6 +1,6 @@
1
1
  import * as maptalks from 'maptalks';
2
2
  import type { Tg } from '../../event';
3
- import { EventHubEventTargetDelegate } from '../../event-target';
3
+ import { EventHubEventTargetDelegate, type EventTargetDelegate } from '../../event-target';
4
4
  import { LatLng } from '../../lat-lng';
5
5
  import type { BaiduMap } from '../baidu-map';
6
6
  import type { GoogleMap } from '../google-map';
@@ -53,6 +53,12 @@ export declare class GoogleCircle extends GoogleShape<google.maps.Circle> implem
53
53
  }
54
54
  export declare class TalksCircle extends TalksShape<maptalks.Circle> implements Circle {
55
55
  static create(this: TalksMap, options: CircleOptions): TalksCircle;
56
+ private prevCenter?;
57
+ private prevRadius?;
58
+ private eventHubDelegate?;
59
+ protected createDelegate(): EventTargetDelegate;
60
+ private onRadiusChanged;
61
+ private onCenterChanged;
56
62
  setCenter(center: LatLng): void;
57
63
  getCenter(): LatLng;
58
64
  setRadius(radius: number): void;
@@ -107,6 +107,8 @@ export declare class GoogleLabelOverlay extends GoogleOverlay<GoogleLabel> imple
107
107
  export type TalksLabel = maptalks.ui.UIMarker;
108
108
  export declare class TalksLabelOverlay extends TalksOverlay<TalksLabel> implements Label {
109
109
  static create(this: TalksMap, options: LabelOptions): TalksLabelOverlay;
110
+ addTo(map: TalksMap): void;
111
+ remove(): void;
110
112
  setContent(content: LabelContent): void;
111
113
  getPosition(): LatLng;
112
114
  setPosition(position: LatLng): void;
@@ -9,6 +9,8 @@ import './marker-label.scss';
9
9
  export interface MarkerLabel {
10
10
  text: string;
11
11
  className?: string;
12
+ /** talks不支持{@link className}, 故需要同时设置该属性, 来为talks实现和className类似的效果 */
13
+ talksStyle?: maptalks.TextSymbol;
12
14
  color?: string;
13
15
  fontSize?: string;
14
16
  fontWeight?: string;
@@ -163,6 +163,8 @@ export declare class TalksMarker extends TalksOverlay<maptalks.Marker> implement
163
163
  private labelMapChangedListener;
164
164
  private labelVisibleChangeInCluster;
165
165
  constructor(innerOverlay: maptalks.Marker, coordType: CoordType, map: TalksMap, state: Pick<MarkerOptions, 'icon' | 'label' | 'title'>);
166
+ addTo(map: TalksMap): void;
167
+ remove(): void;
166
168
  getPosition(): LatLng;
167
169
  setPosition(position: LatLng): void;
168
170
  setTitle(title: string): void;
@@ -17,13 +17,20 @@ export declare abstract class Overlay<T = unknown> implements Tg.EventTarget {
17
17
  constructor(innerOverlay: T,
18
18
  /** 用于保存Overlay内部点的坐标, 它的值有可能和map的不同 */
19
19
  coordType: CoordType);
20
+ /** @see addTo */
20
21
  protected abstract map: BaseMap;
21
22
  protected abstract createDelegate(): EventTargetDelegate;
22
23
  private _delegate;
23
24
  private get delegate();
24
25
  addEventListener(type: string, listener: Tg.EventListener): void;
25
26
  removeEventListener(type: string, listener: Tg.EventListener): void;
26
- remove(): void;
27
+ /**
28
+ * 添加到地图
29
+ * @param map 应该和this.map是同一个对象, 目前没有处理两个对象不同的情况, 因此在{@link remove}中也没有清空this.map, 并且this.map也没被声明成可空
30
+ */
31
+ abstract addTo(map: BaseMap): void;
32
+ /** @see addTo */
33
+ abstract remove(): void;
27
34
  abstract isVisible(): boolean;
28
35
  abstract setVisible(visible: boolean): void;
29
36
  }
@@ -31,6 +38,8 @@ export declare class GoogleOverlay<T extends UnionGoogleOverlay = UnionGoogleOve
31
38
  protected map: GoogleMap;
32
39
  constructor(innerOverlay: T, coordType: CoordType, map: GoogleMap);
33
40
  protected createDelegate(): EventTargetDelegate;
41
+ addTo(map: GoogleMap): void;
42
+ remove(): void;
34
43
  isVisible(): boolean;
35
44
  setVisible(visible: boolean): void;
36
45
  }
@@ -38,6 +47,8 @@ export declare class BaiduOverlay<T extends UnionBaiduOverlay = UnionBaiduOverla
38
47
  protected map: BaiduMap;
39
48
  constructor(innerOverlay: T, coordType: CoordType, map: BaiduMap);
40
49
  protected createDelegate(): EventTargetDelegate;
50
+ addTo(map: BaiduMap): void;
51
+ remove(): void;
41
52
  /** 仅限内部使用; 设为private时, 生成的d.ts文件中, 方法返回值会变成any, 故改成了public */
42
53
  get overlay(): Required<Pick<UnionBaiduOverlay, "isVisible" | "show" | "hide">>;
43
54
  isVisible(): boolean;
@@ -45,7 +56,7 @@ export declare class BaiduOverlay<T extends UnionBaiduOverlay = UnionBaiduOverla
45
56
  /** 在创建BaiduOverlay时, 设置options.visible, 仅内部使用 */
46
57
  visibleOptionInternal(visible: boolean | undefined): this;
47
58
  }
48
- export declare class TalksOverlay<T extends UnionTalksOverlay = UnionTalksOverlay> extends Overlay<T> {
59
+ export declare abstract class TalksOverlay<T extends UnionTalksOverlay = UnionTalksOverlay> extends Overlay<T> {
49
60
  protected map: TalksMap;
50
61
  constructor(innerOverlay: T, coordType: CoordType, map: TalksMap);
51
62
  protected createDelegate(): EventTargetDelegate;
@@ -1,6 +1,6 @@
1
1
  import * as maptalks from 'maptalks';
2
2
  import type { Tg } from '../../event';
3
- import { EventHubEventTargetDelegate } from '../../event-target';
3
+ import { EventHubEventTargetDelegate, type EventTargetDelegate } from '../../event-target';
4
4
  import { LatLng } from '../../lat-lng';
5
5
  import type { BaiduMap } from '../baidu-map';
6
6
  import type { GoogleMap } from '../google-map';
@@ -44,6 +44,7 @@ export declare class GooglePolygon extends GoogleShape<google.maps.Polygon> impl
44
44
  }
45
45
  export declare class TalksPolygon extends TalksShape<maptalks.Polygon> implements Polygon {
46
46
  static create(this: TalksMap, options: PolygonOptions): TalksPolygon;
47
+ protected createDelegate(): EventTargetDelegate;
47
48
  getPaths(): LatLng[][];
48
49
  setPaths(paths: LatLng[][]): void;
49
50
  }
@@ -1,6 +1,6 @@
1
1
  import * as maptalks from 'maptalks';
2
2
  import type { Tg } from '../../event';
3
- import { EventHubEventTargetDelegate } from '../../event-target';
3
+ import { EventHubEventTargetDelegate, type EventTargetDelegate } from '../../event-target';
4
4
  import { LatLng } from '../../lat-lng';
5
5
  import type { BaiduMap } from '../baidu-map';
6
6
  import type { GoogleMap } from '../google-map';
@@ -73,6 +73,7 @@ export declare class GooglePolyline extends GoogleShape<google.maps.Polyline> im
73
73
  }
74
74
  export declare class TalksPolyline extends TalksShape<maptalks.LineString> implements Polyline {
75
75
  static create(this: TalksMap, options: PolylineOptions): TalksPolyline;
76
+ protected createDelegate(): EventTargetDelegate;
76
77
  getPath(): LatLng[];
77
78
  setPath(path: LatLng[]): void;
78
79
  }
@@ -1,5 +1,6 @@
1
1
  import * as maptalks from 'maptalks';
2
2
  import type { Tg } from '../../event';
3
+ import { type EventTargetDelegate } from '../../event-target';
3
4
  import { CoordType, LatLngBounds } from '../../lat-lng';
4
5
  import type { BaiduMap } from '../baidu-map';
5
6
  import type { GoogleMap } from '../google-map';
@@ -53,6 +54,7 @@ export declare class GoogleRectangle extends GoogleShape<google.maps.Rectangle>
53
54
  export declare class TalksRectangle extends TalksShape<maptalks.Rectangle> implements Rectangle {
54
55
  static create(this: TalksMap, options: RectangleOptions): TalksRectangle;
55
56
  private static convertBoundsToRect;
57
+ protected createDelegate(): EventTargetDelegate;
56
58
  getBounds(): LatLngBounds;
57
59
  setBounds(bounds: LatLngBounds): void;
58
60
  }
@@ -1,6 +1,7 @@
1
1
  import type { CoordType } from '../../lat-lng';
2
2
  import type { UnionBaiduShape, UnionGoogleShape, UnionTalksShape } from '../../unions';
3
3
  import type { BaiduMap } from '../baidu-map';
4
+ import type { TalksMap } from '../talks-map';
4
5
  import type { SymbolIcon } from './icon';
5
6
  import { BaiduOverlay, GoogleOverlay, TalksOverlay, type OverlayOptions } from './overlay';
6
7
  export interface ShapeOptions extends OverlayOptions {
@@ -75,6 +76,20 @@ export declare abstract class GoogleShape<T extends UnionGoogleShape> extends Go
75
76
  setZIndex(zIndex: number): void;
76
77
  }
77
78
  export declare abstract class TalksShape<T extends UnionTalksShape> extends TalksOverlay<T> implements Shape {
79
+ addTo(map: TalksMap): void;
80
+ remove(): void;
81
+ /**
82
+ * ## 编辑状态的映射
83
+ * tg-map的editable, 直接表示是否处于编辑状态
84
+ * talks的editable, 只是标记overlay是否可以编辑(默认为true), 要进入编辑状态(isEditing), 还需要执行startEdit()
85
+ * 也就是说我们需要想办法把talks的四个状态, 映射为tg-map的两个状态
86
+ *
87
+ * 我们的做法是, 用editable保存isEditing期望的值, 保证editable为true时isEditing也会为true, 为false时isEditing也会为false
88
+ * 这样就可以和tg-map的editable的语义简单对应上了
89
+ *
90
+ * @see addTo
91
+ * @see setEditable
92
+ */
78
93
  isEditable(): boolean;
79
94
  setEditable(editable: boolean): void;
80
95
  setStrokeColor(color: string): void;
@@ -24,15 +24,12 @@ import { TalksInfoBoxOverlay } from './overlay/info-box';
24
24
  import { TalksInfoWindow } from './overlay/info-window';
25
25
  import { TalksLabelOverlay } from './overlay/label';
26
26
  import { TalksMarker } from './overlay/marker';
27
- import type { TalksOverlay } from './overlay/overlay';
28
27
  import { TalksPolygon } from './overlay/polygon';
29
28
  import { TalksPolyline } from './overlay/polyline';
30
29
  import { TalksRectangle } from './overlay/rectangle';
31
30
  export declare class TalksMap extends BaseMap {
32
31
  mapOptions: MapOptions;
33
32
  private map;
34
- protected markerLayer: maptalks.VectorLayer;
35
- protected overlayLayer: maptalks.VectorLayer;
36
33
  constructor(element: HTMLElement, mapOptions: MapOptions, baseLayoutIds: [normal: TalksBaseLayerId] | [normal: TalksBaseLayerId, satellite: TalksBaseLayerId] | [normal: TalksBaseLayerId, satellite: TalksBaseLayerId, hybrid: TalksBaseLayerId]);
37
34
  setGestureHandling(gestureHandling?: GestureHandlingOptions): void;
38
35
  get innerMap(): maptalks.Map;
@@ -60,8 +57,6 @@ export declare class TalksMap extends BaseMap {
60
57
  getBounds(): LatLngBounds;
61
58
  addElementOverlay(overlay: ElementOverlay): void;
62
59
  removeElementOverlay(overlay: ElementOverlay): void;
63
- addOverlay(overlay: TalksOverlay): void;
64
- removeOverlay(overlay: TalksOverlay): void;
65
60
  createMarker: typeof TalksMarker.create;
66
61
  createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
67
62
  createHeatmap(options: HeatmapOptions): Heatmap;
@@ -1,9 +1,9 @@
1
1
  import * as maptalks from 'maptalks';
2
2
  import { CoordType } from '../map/lat-lng';
3
- export declare const talksBaseLayerIds: readonly ["osm", "osm-simple", "google", "baidu", "baidu-detail", "amap", "tencent", "geoq", "tianditu", "yandex", "bing"];
3
+ export declare const talksBaseLayerIds: readonly ["osm", "osm-light", "osm-dark", "google", "baidu", "baidu-detail", "amap", "tencent", "geoq", "tianditu", "yandex", "bing"];
4
4
  export type TalksBaseLayerId = typeof talksBaseLayerIds[number];
5
5
  export declare function talksBaseLayerIdToCoordType(layerId: TalksBaseLayerId): CoordType;
6
6
  export declare function createTalksBaseLayer(layerId: TalksBaseLayerId, { id, visible, }?: {
7
- id?: "google" | "osm" | "osm-simple" | "baidu" | "baidu-detail" | "amap" | "tencent" | "geoq" | "tianditu" | "yandex" | "bing" | undefined;
7
+ id?: "osm" | "osm-light" | "osm-dark" | "google" | "baidu" | "baidu-detail" | "amap" | "tencent" | "geoq" | "tianditu" | "yandex" | "bing" | undefined;
8
8
  visible?: boolean | undefined;
9
9
  }): maptalks.TileLayer;
@@ -1556,6 +1556,14 @@ class TalksEventTargetDelegate extends AbstractEventTargetDelegate {
1556
1556
  'center-changed': 'movestart moving moveend zoomend',
1557
1557
  'zoom-changed': 'zoomend',
1558
1558
  });
1559
+ eventTypeMap;
1560
+ /**
1561
+ * @param eventTypeMap 额外的事件类型映射
1562
+ */
1563
+ constructor(inner, coordTypeSupplier, eventTypeMap) {
1564
+ super(inner, coordTypeSupplier);
1565
+ this.eventTypeMap = { ...TalksEventTargetDelegate.EVENT_TYPE_MAP, ...eventTypeMap };
1566
+ }
1559
1567
  addEventListener(type, listener) {
1560
1568
  const key = generateEventKey(type, listener);
1561
1569
  if (this.eventMap.has(key)) {
@@ -1573,14 +1581,14 @@ class TalksEventTargetDelegate extends AbstractEventTargetDelegate {
1573
1581
  }
1574
1582
  listener.call(this.target, ev);
1575
1583
  };
1576
- this.inner.on(TalksEventTargetDelegate.EVENT_TYPE_MAP[type] ?? type, actualListener);
1584
+ this.inner.on(this.eventTypeMap[type] ?? type, actualListener);
1577
1585
  this.eventMap.set(key, actualListener);
1578
1586
  }
1579
1587
  removeEventListener(type, listener) {
1580
1588
  const key = generateEventKey(type, listener);
1581
1589
  const actualListener = this.eventMap.get(key);
1582
1590
  if (actualListener) {
1583
- this.inner.off(TalksEventTargetDelegate.EVENT_TYPE_MAP[type] ?? type, actualListener);
1591
+ this.inner.off(this.eventTypeMap[type] ?? type, actualListener);
1584
1592
  this.eventMap.delete(key);
1585
1593
  }
1586
1594
  else {
@@ -7656,6 +7664,12 @@ class BaseMap {
7656
7664
  removeOverlayMapType(mapType) {
7657
7665
  this.removeLayer(mapType);
7658
7666
  }
7667
+ addOverlay(overlay) {
7668
+ overlay.addTo(this);
7669
+ }
7670
+ removeOverlay(overlay) {
7671
+ overlay.remove();
7672
+ }
7659
7673
  addControl(control) {
7660
7674
  control.addTo(this);
7661
7675
  }
@@ -7692,9 +7706,6 @@ class Overlay {
7692
7706
  removeEventListener(type, listener) {
7693
7707
  this.delegate.removeEventListener(type, listener);
7694
7708
  }
7695
- remove() {
7696
- this.map.removeOverlay(this);
7697
- }
7698
7709
  }
7699
7710
  class GoogleOverlay extends Overlay {
7700
7711
  map;
@@ -7705,6 +7716,13 @@ class GoogleOverlay extends Overlay {
7705
7716
  createDelegate() {
7706
7717
  return new GoogleEventTargetDelegate(this.innerOverlay, this.map);
7707
7718
  }
7719
+ addTo(map) {
7720
+ this.map = map;
7721
+ this.innerOverlay.setMap(map.innerMap);
7722
+ }
7723
+ remove() {
7724
+ this.innerOverlay.setMap(null);
7725
+ }
7708
7726
  isVisible() {
7709
7727
  return this.innerOverlay.getVisible();
7710
7728
  }
@@ -7721,6 +7739,13 @@ class BaiduOverlay extends Overlay {
7721
7739
  createDelegate() {
7722
7740
  return new BaiduEventTargetDelegate(this.innerOverlay, this.map);
7723
7741
  }
7742
+ addTo(map) {
7743
+ this.map = map;
7744
+ this.map.innerMap.addOverlay(this.innerOverlay);
7745
+ }
7746
+ remove() {
7747
+ this.map.innerMap.removeOverlay(this.innerOverlay);
7748
+ }
7724
7749
  /** 仅限内部使用; 设为private时, 生成的d.ts文件中, 方法返回值会变成any, 故改成了public */
7725
7750
  get overlay() {
7726
7751
  // 这几个属性被声明成可选的, 这里将其强转成必选
@@ -7830,11 +7855,43 @@ class GoogleShape extends GoogleOverlay {
7830
7855
  }
7831
7856
  }
7832
7857
  class TalksShape extends TalksOverlay {
7858
+ addTo(map) {
7859
+ this.map = map;
7860
+ this.map.overlayLayer.addGeometry(this.innerOverlay);
7861
+ // 添加到地图中之后, startEdit()才有效
7862
+ if (this.isEditable() && !this.innerOverlay.isEditing()) {
7863
+ this.innerOverlay.startEdit();
7864
+ }
7865
+ }
7866
+ remove() {
7867
+ this.map.overlayLayer.removeGeometry(this.innerOverlay);
7868
+ }
7869
+ /**
7870
+ * ## 编辑状态的映射
7871
+ * tg-map的editable, 直接表示是否处于编辑状态
7872
+ * talks的editable, 只是标记overlay是否可以编辑(默认为true), 要进入编辑状态(isEditing), 还需要执行startEdit()
7873
+ * 也就是说我们需要想办法把talks的四个状态, 映射为tg-map的两个状态
7874
+ *
7875
+ * 我们的做法是, 用editable保存isEditing期望的值, 保证editable为true时isEditing也会为true, 为false时isEditing也会为false
7876
+ * 这样就可以和tg-map的editable的语义简单对应上了
7877
+ *
7878
+ * @see addTo
7879
+ * @see setEditable
7880
+ */
7833
7881
  isEditable() {
7834
- return this.innerOverlay.config().editable ?? true;
7882
+ return this.innerOverlay.config().editable ?? false;
7835
7883
  }
7836
7884
  setEditable(editable) {
7885
+ // 同步设置editable和isEditing
7886
+ // TODO: 2026/01/23 ipcjs 切换编辑状态时, 控制台会报重复注册事件警告, 已提PR: https://github.com/maptalks/maptalks.js/pull/2796
7837
7887
  this.innerOverlay.config({ editable: editable });
7888
+ const isEditing = this.innerOverlay.isEditing();
7889
+ if (editable) {
7890
+ !isEditing && this.innerOverlay.startEdit();
7891
+ }
7892
+ else {
7893
+ isEditing && this.innerOverlay.endEdit();
7894
+ }
7838
7895
  }
7839
7896
  setStrokeColor(color) {
7840
7897
  this.innerOverlay.updateSymbol({ lineColor: color });
@@ -8004,6 +8061,41 @@ class TalksCircle extends TalksShape {
8004
8061
  });
8005
8062
  return new TalksCircle(inner, coord, this);
8006
8063
  }
8064
+ prevCenter;
8065
+ prevRadius;
8066
+ eventHubDelegate;
8067
+ createDelegate() {
8068
+ return (this.eventHubDelegate = new EventHubEventTargetDelegate(super.createDelegate(), {
8069
+ types: ['radius-changed', 'center-changed'],
8070
+ onListen: (type) => {
8071
+ if (type === 'radius-changed') {
8072
+ this.prevRadius = this.innerOverlay.getRadius();
8073
+ this.innerOverlay.on('editrecord', this.onRadiusChanged);
8074
+ }
8075
+ else {
8076
+ this.prevCenter = this.innerOverlay.getCoordinates();
8077
+ this.innerOverlay.on('editrecord', this.onCenterChanged);
8078
+ }
8079
+ },
8080
+ onCancel: (type) => {
8081
+ this.innerOverlay.off('editrecord', type === 'radius-changed' ? this.onRadiusChanged : this.onCenterChanged);
8082
+ },
8083
+ }));
8084
+ }
8085
+ onRadiusChanged = () => {
8086
+ const radius = this.innerOverlay.getRadius();
8087
+ if (this.prevRadius !== radius) {
8088
+ this.eventHubDelegate?.notify({ type: 'radius-changed', target: this });
8089
+ this.prevRadius = radius;
8090
+ }
8091
+ };
8092
+ onCenterChanged = () => {
8093
+ const center = this.innerOverlay.getCoordinates();
8094
+ if (this.prevCenter !== center && !this.prevCenter?.equals(center)) {
8095
+ this.eventHubDelegate?.notify({ type: 'center-changed', target: this });
8096
+ this.prevCenter = center;
8097
+ }
8098
+ };
8007
8099
  setCenter(center) {
8008
8100
  this.coordType = this.map.coordType;
8009
8101
  this.innerOverlay.setCoordinates(center.toTalks(this.coordType));
@@ -9148,6 +9240,13 @@ class TalksLabelOverlay extends TalksOverlay {
9148
9240
  });
9149
9241
  return new TalksLabelOverlay(label, coord, this);
9150
9242
  }
9243
+ addTo(map) {
9244
+ this.map = map;
9245
+ this.innerOverlay.addTo(map.innerMap);
9246
+ }
9247
+ remove() {
9248
+ this.innerOverlay.remove();
9249
+ }
9151
9250
  setContent(content) {
9152
9251
  this.innerOverlay.setContent(content);
9153
9252
  }
@@ -9343,8 +9442,8 @@ const MarkerLabel = {
9343
9442
  },
9344
9443
  toGoogle: (label) => label,
9345
9444
  toTalks: (label, options) => {
9346
- if (process.env.NODE_ENV !== 'production' && label.className) {
9347
- console.warn('talks的MarkerLabel不支持设置className', label);
9445
+ if (process.env.NODE_ENV !== 'production' && label.className && !label.talksStyle) {
9446
+ console.warn('talks的MarkerLabel不支持设置className, 请为它设置talksStyle, 以实现类似的显示效果', label);
9348
9447
  }
9349
9448
  return {
9350
9449
  properties: {
@@ -9359,6 +9458,7 @@ const MarkerLabel = {
9359
9458
  textWeight: label.fontWeight,
9360
9459
  textFaceName: label.fontFamily ?? 'Roboto, Arial, sans-serif',
9361
9460
  ...options,
9461
+ ...label.talksStyle,
9362
9462
  },
9363
9463
  };
9364
9464
  },
@@ -9665,6 +9765,13 @@ class TalksMarker extends TalksOverlay {
9665
9765
  super(innerOverlay, coordType, map);
9666
9766
  this.state = state;
9667
9767
  }
9768
+ addTo(map) {
9769
+ this.map = map;
9770
+ this.map.markerLayer.addGeometry(this.innerOverlay);
9771
+ }
9772
+ remove() {
9773
+ this.map.markerLayer.removeGeometry(this.innerOverlay);
9774
+ }
9668
9775
  getPosition() {
9669
9776
  return LatLng.fromTalks(this.innerOverlay.getCoordinates(), this.coordType);
9670
9777
  }
@@ -9933,6 +10040,12 @@ class TalksPolyline extends TalksShape {
9933
10040
  });
9934
10041
  return new TalksPolyline(inner, coordType, this);
9935
10042
  }
10043
+ createDelegate() {
10044
+ return new TalksEventTargetDelegate(this.innerOverlay, this.map, {
10045
+ // https://maptalks.org/maptalks.js/api/1.x/Geometry.html#event:editrecord
10046
+ 'path-edited': 'editrecord',
10047
+ });
10048
+ }
9936
10049
  getPath() {
9937
10050
  return this.innerOverlay.getCoordinates().map(it => LatLng.fromTalks(it, this.coordType));
9938
10051
  }
@@ -10051,6 +10164,12 @@ class TalksPolygon extends TalksShape {
10051
10164
  });
10052
10165
  return new TalksPolygon(inner, coord, this);
10053
10166
  }
10167
+ createDelegate() {
10168
+ return new TalksEventTargetDelegate(this.innerOverlay, this.map, {
10169
+ // https://maptalks.org/maptalks.js/api/1.x/Geometry.html#event:editrecord
10170
+ 'paths-edited': 'editrecord',
10171
+ });
10172
+ }
10054
10173
  getPaths() {
10055
10174
  return this.innerOverlay.getCoordinates()
10056
10175
  .map(path => path.map(it => LatLng.fromTalks(it, this.coordType)));
@@ -10216,6 +10335,12 @@ class TalksRectangle extends TalksShape {
10216
10335
  height: computeDistanceBetween(nw, bounds.sw),
10217
10336
  };
10218
10337
  }
10338
+ createDelegate() {
10339
+ return new TalksEventTargetDelegate(this.innerOverlay, this.map, {
10340
+ // https://maptalks.org/maptalks.js/api/1.x/Geometry.html#event:editrecord
10341
+ 'bounds-changed': 'editrecord',
10342
+ });
10343
+ }
10219
10344
  getBounds() {
10220
10345
  return LatLngBounds.fromTalks(this.innerOverlay.getExtent(), this.coordType);
10221
10346
  }
@@ -10418,12 +10543,6 @@ class BaiduMap extends BaseMap {
10418
10543
  removeElementOverlay(overlay) {
10419
10544
  this.map.removeOverlay(overlay.asBaidu());
10420
10545
  }
10421
- addOverlay(overlay) {
10422
- this.map.addOverlay(overlay.innerOverlay);
10423
- }
10424
- removeOverlay(overlay) {
10425
- this.map.removeOverlay(overlay.innerOverlay);
10426
- }
10427
10546
  addCustomControl(control) {
10428
10547
  if (!control.inner) {
10429
10548
  const BaiduControl = class extends BMap.Control {
@@ -10644,12 +10763,6 @@ class GoogleMap extends BaseMap {
10644
10763
  removeElementOverlay(overlay) {
10645
10764
  overlay.asGoogle().setMap(null);
10646
10765
  }
10647
- addOverlay(overlay) {
10648
- overlay.innerOverlay.setMap(this.map);
10649
- }
10650
- removeOverlay(overlay) {
10651
- overlay.innerOverlay.setMap(null);
10652
- }
10653
10766
  addCustomControl(control) {
10654
10767
  if (!control.inner) {
10655
10768
  control.inner = control.onCreateElement();
@@ -10798,12 +10911,6 @@ class HereMap extends BaseMap {
10798
10911
  removeElementOverlay(overlay) {
10799
10912
  throw new Error('Method not implemented.');
10800
10913
  }
10801
- addOverlay(overlay) {
10802
- throw new Error('Method not implemented.');
10803
- }
10804
- removeOverlay(overlay) {
10805
- throw new Error('Method not implemented.');
10806
- }
10807
10914
  createMarker(options) {
10808
10915
  throw new Error('Method not implemented.');
10809
10916
  }
@@ -10885,7 +10992,8 @@ const quadKey = (z, x, y) => {
10885
10992
  };
10886
10993
  const talksBaseLayerIds = [
10887
10994
  'osm',
10888
- 'osm-simple',
10995
+ 'osm-light',
10996
+ 'osm-dark',
10889
10997
  'google',
10890
10998
  'baidu',
10891
10999
  'baidu-detail',
@@ -10901,7 +11009,8 @@ function talksBaseLayerIdToCoordType(layerId) {
10901
11009
  case 'baidu':
10902
11010
  case 'baidu-detail':
10903
11011
  return exports.CoordType.bd09;
10904
- case 'osm-simple':
11012
+ case 'osm-light':
11013
+ case 'osm-dark':
10905
11014
  case 'osm':
10906
11015
  case 'yandex':
10907
11016
  return exports.CoordType.wgs84;
@@ -11018,13 +11127,20 @@ function createTalksBaseLayer(layerId, { id = layerId, visible = true, } = {}) {
11018
11127
  subdomains: ['a', 'b', 'c'],
11019
11128
  attribution: '&copy; <a target="_blank" href="http://www.osm.org/copyright">OSM</a>',
11020
11129
  });
11021
- case 'osm-simple':
11130
+ case 'osm-light':
11022
11131
  return new maptalks__namespace.TileLayer(id, {
11023
11132
  visible,
11024
11133
  urlTemplate: 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
11025
11134
  subdomains: ['a', 'b', 'c', 'd'],
11026
11135
  attribution: '&copy; <a target="_blank" href="http://www.osm.org/copyright">OSM</a> contributors, &copy; <a target="_blank" href="https://carto.com/attributions">CARTO</a>',
11027
11136
  });
11137
+ case 'osm-dark':
11138
+ return new maptalks__namespace.TileLayer(id, {
11139
+ visible,
11140
+ urlTemplate: 'http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png',
11141
+ subdomains: ['a', 'b', 'c', 'd'],
11142
+ attribution: '&copy; <a target="_blank" href="http://www.osm.org/copyright">OSM</a> contributors, &copy; <a target="_blank" href="https://carto.com/attributions">CARTO</a>',
11143
+ });
11028
11144
  }
11029
11145
  }
11030
11146
 
@@ -11034,7 +11150,9 @@ class TalksMap extends BaseMap {
11034
11150
  map;
11035
11151
  /** @internal */
11036
11152
  currentBaseLayerId;
11153
+ /** @internal */
11037
11154
  markerLayer;
11155
+ /** @internal */
11038
11156
  overlayLayer;
11039
11157
  constructor(element, mapOptions, baseLayoutIds) {
11040
11158
  super(element);
@@ -11180,22 +11298,6 @@ class TalksMap extends BaseMap {
11180
11298
  removeElementOverlay(overlay) {
11181
11299
  // TODO: 2026/01/05 ipcjs 下一版再实现该功能
11182
11300
  }
11183
- addOverlay(overlay) {
11184
- if (overlay.innerOverlay instanceof maptalks__namespace.ui.UIComponent) {
11185
- overlay.innerOverlay.addTo(this.map);
11186
- return;
11187
- }
11188
- const layer = overlay instanceof TalksMarker ? this.markerLayer : this.overlayLayer;
11189
- layer.addGeometry(overlay.innerOverlay);
11190
- }
11191
- removeOverlay(overlay) {
11192
- if (overlay.innerOverlay instanceof maptalks__namespace.ui.UIComponent) {
11193
- overlay.innerOverlay.remove();
11194
- return;
11195
- }
11196
- const layer = overlay instanceof TalksMarker ? this.markerLayer : this.overlayLayer;
11197
- layer.removeGeometry(overlay.innerOverlay);
11198
- }
11199
11301
  createMarker = TalksMarker.create;
11200
11302
  createMarkerClusterer(options) {
11201
11303
  return new TalksMarkerClusterer(this, options);