tg-map-vue3 3.5.6 → 3.6.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.
package/CHANGELOG.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # 更新日志
2
2
 
3
+ ## 3.6.x
4
+
5
+ - feat: 添加[MapUrls], 支持打开地图网页
6
+ - ***BREAKING CHANGE***: `placeService` -> `placesService`
7
+
3
8
  ## 3.5.x
4
9
 
5
10
  - fix: [LatLngBounds]为空时中心点计算问题
11
+ - perf: 废弃`rightclick`事件, 使用`contextmenu`替代
6
12
  - ***BREAKING CHANGE***: `useTgMap` -> [useTgMapInner]
7
13
  - ***BREAKING CHANGE***: 统一[TgLabel]在google和baidu上的默认显示层级, 都位于overlay上方
8
14
 
@@ -44,6 +50,7 @@
44
50
  [SymbolIcon]: src/map/map/overlay/icon.ts#L55 "Svg图标"
45
51
  [PlacesService]: src/map/map/extra/places-service.ts "位置服务"
46
52
  [Autocomplete]: src/map/map/extra/autocomplete.ts "自动完成"
53
+ [MapUrls]: src/map/map/extra/map-urls.ts "地图网页"
47
54
  [SearchBox]: src/map/map/extra/search-box.ts "搜索框"
48
55
  [useTgMapInner]: src/components/map-hooks.ts
49
56
  [LatLngBounds]: src/map/lat-lng.ts#L157
@@ -60,6 +60,10 @@ declare const _default: import("vue").DefineComponent<{
60
60
  type: import("vue").PropType<number>;
61
61
  required: true;
62
62
  };
63
+ /**
64
+ * 该属性不会响应式更新, 要让它立即生效, 请参考{@link file://./../views/map/InfoDemo.vue#L3}
65
+ * @see MapOptions.infoWindowMode
66
+ */
63
67
  infoWindowMode: {
64
68
  type: import("vue").PropType<"single" | "multi">;
65
69
  };
@@ -150,6 +154,10 @@ declare const _default: import("vue").DefineComponent<{
150
154
  type: import("vue").PropType<number>;
151
155
  required: true;
152
156
  };
157
+ /**
158
+ * 该属性不会响应式更新, 要让它立即生效, 请参考{@link file://./../views/map/InfoDemo.vue#L3}
159
+ * @see MapOptions.infoWindowMode
160
+ */
153
161
  infoWindowMode: {
154
162
  type: import("vue").PropType<"single" | "multi">;
155
163
  };
@@ -195,6 +203,7 @@ declare const _default: import("vue").DefineComponent<{
195
203
  onClick?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
196
204
  onDblclick?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
197
205
  onRightclick?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
206
+ onContextmenu?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
198
207
  onMousedown?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
199
208
  onMouseup?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
200
209
  onMouseout?: ((event: import("../map/event").Tg.MouseEvent) => any) | undefined;
@@ -15,6 +15,7 @@ export * from '../map/map/controls/map-type.control';
15
15
  export * from '../map/map/controls/scale.control';
16
16
  export * from '../map/map/controls/zoom.control';
17
17
  export * from '../map/map/extra/autocomplete';
18
+ export * from '../map/map/extra/map-urls';
18
19
  export * from '../map/map/extra/marker-clusterer';
19
20
  export * from '../map/map/extra/places-service';
20
21
  export * from '../map/map/extra/search-box';
@@ -57,11 +57,10 @@ declare const TgMarker: import("vue").DefineComponent<{
57
57
  readonly offset?: any;
58
58
  style?: unknown;
59
59
  onClick?: ((event: import("../../map/event").Tg.Event) => any) | undefined;
60
- class?: unknown;
61
60
  ref?: import("vue").VNodeRef | undefined;
61
+ class?: unknown;
62
62
  ref_for?: boolean | undefined;
63
63
  ref_key?: string | undefined;
64
- readonly mapPane?: import("../../utils/mapped-types").StringEnumValue<typeof import("../../map/map/overlay/element-overlay").MapPane> | undefined;
65
64
  onVnodeBeforeMount?: ((vnode: import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
66
65
  [key: string]: any;
67
66
  }>) => void) | ((vnode: import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
@@ -100,6 +99,7 @@ declare const TgMarker: import("vue").DefineComponent<{
100
99
  }>) => void) | ((vnode: import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
101
100
  [key: string]: any;
102
101
  }>) => void)[] | undefined;
102
+ readonly mapPane?: import("../../utils/mapped-types").StringEnumValue<typeof import("../../map/map/overlay/element-overlay").MapPane> | undefined;
103
103
  };
104
104
  $attrs: {
105
105
  [x: string]: unknown;
@@ -238,6 +238,7 @@ declare const TgMarker: import("vue").DefineComponent<{
238
238
  onClick?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
239
239
  onDblclick?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
240
240
  onRightclick?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
241
+ onContextmenu?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
241
242
  onMousedown?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
242
243
  onMouseup?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
243
244
  onMouseout?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
@@ -121,3 +121,9 @@ export declare namespace LatLngBounds {
121
121
  private delta;
122
122
  }
123
123
  }
124
+ /** 在导航/搜索等接口中使用的 位置 */
125
+ export type Location = string | LatLng;
126
+ export declare namespace Location {
127
+ function toString(place: Location | undefined, coordType: CoordType): string | undefined;
128
+ function getCoordType(place: Location | undefined): CoordType | undefined;
129
+ }
@@ -5,8 +5,9 @@ import { BaiduMapTypeControl } from './controls/map-type.control';
5
5
  import { BaiduScaleControl } from './controls/scale.control';
6
6
  import { BaiduZoomControl } from './controls/zoom.control';
7
7
  import { type Autocomplete, type AutocompleteOptions } from './extra/autocomplete';
8
+ import { type MapUrls, type MapUrlsOptions } from './extra/map-urls';
8
9
  import { BaiduMarkerClusterer, type MarkerClustererOptions } from './extra/marker-clusterer';
9
- import { type PlaceServiceOptions, type PlacesService } from './extra/places-service';
10
+ import { type PlacesService, type PlacesServiceOptions } from './extra/places-service';
10
11
  import { type SearchBox, type SearchBoxOptions } from './extra/search-box';
11
12
  import { AbstractMap, type AbstractMapEventMap } from './map';
12
13
  import { GestureHandlingOptions, MapOptions, type MapStyle } from './map-options';
@@ -72,5 +73,6 @@ export declare class BaiduMap extends AbstractMap {
72
73
  createMarkerClusterer(options: MarkerClustererOptions): BaiduMarkerClusterer;
73
74
  createAutocomplete(options: AutocompleteOptions): Autocomplete;
74
75
  createSearchBox(options: SearchBoxOptions): SearchBox;
75
- createPlaceService(options: PlaceServiceOptions): PlacesService;
76
+ createPlacesService(options: PlacesServiceOptions): PlacesService;
77
+ createMapUrlsService(options: MapUrlsOptions): MapUrls;
76
78
  }
@@ -0,0 +1,35 @@
1
+ import { Location } from '../../lat-lng';
2
+ export type DirectionMode = 'transit' | 'driving' | 'walking';
3
+ /** google多支持一种导航模式 */
4
+ type GoogleDirectionMode = DirectionMode | 'bicycling';
5
+ export interface MapUrlsOptions {
6
+ }
7
+ export declare abstract class MapUrls {
8
+ protected options: MapUrlsOptions;
9
+ constructor(options: MapUrlsOptions);
10
+ /**
11
+ * 导航
12
+ *
13
+ * ## {@link origin}为空时的行为差异
14
+ * - google: 用我的位置当做起点
15
+ * - baidu: 用{@link destination}当作起点
16
+ */
17
+ abstract directions(origin: Location | undefined, destination: Location, mode?: DirectionMode): URL;
18
+ }
19
+ /**
20
+ * @see https://developers.google.com/maps/documentation/urls/get-started
21
+ */
22
+ export declare class GoogleMapUrls extends MapUrls {
23
+ static BASE_URL: string;
24
+ /** @see https://developers.google.com/maps/documentation/urls/get-started#directions-action */
25
+ directions(origin: Location | undefined, destination: Location, mode?: GoogleDirectionMode): URL;
26
+ }
27
+ /**
28
+ * @see https://lbsyun.baidu.com/faq/api?title=webapi/uri
29
+ */
30
+ export declare class BaiduMapUrls extends MapUrls {
31
+ static BASE_URL: string;
32
+ /** @see https://lbsyun.baidu.com/faq/api?title=webapi/uri/web#:~:text=%E6%9C%8D%E5%8A%A1%E5%9C%B0%E5%9D%80-,http%3A//api.map.baidu.com/direction,-//PC%26Webapp%E6%9C%8D%E5%8A%A1 */
33
+ directions(origin: Location | undefined, destination: Location, mode?: DirectionMode): URL;
34
+ }
35
+ export {};
@@ -1,6 +1,6 @@
1
1
  /// <reference types="google.maps" />
2
2
  /// <reference types="baidumap-web-sdk" />
3
- import { LatLng, LatLngBounds, type AbstractMap } from '../../../components';
3
+ import { LatLng, LatLngBounds, Location, type AbstractMap } from '../../../components';
4
4
  import type { UnionPlacesService } from '../../unions';
5
5
  import type { BaiduMap } from '../baidu-map';
6
6
  import type { GoogleMap } from '../google-map';
@@ -13,14 +13,14 @@ export interface Place {
13
13
  title: string;
14
14
  address: string;
15
15
  }
16
- export interface PlaceServiceOptions {
16
+ export interface PlacesServiceOptions {
17
17
  }
18
18
  export declare abstract class PlacesService {
19
19
  abstract inner: UnionPlacesService;
20
20
  abstract map: AbstractMap;
21
21
  constructor();
22
22
  /** 指定{@link location}搜索, 若不指定, 则默认使用地图的中心点 */
23
- abstract search(query: string, location?: string | LatLng): Promise<Place[]>;
23
+ abstract search(query: string, location?: Location): Promise<Place[]>;
24
24
  /** 在指定的bounds范围内搜索 */
25
25
  abstract searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
26
26
  /** 在指定的center+radius范围内搜索 */
@@ -29,8 +29,8 @@ export declare abstract class PlacesService {
29
29
  export declare class GooglePlacesService extends PlacesService {
30
30
  map: GoogleMap;
31
31
  inner: google.maps.places.PlacesService;
32
- constructor(map: GoogleMap, _options: PlaceServiceOptions);
33
- search(query: string, location?: string | LatLng): Promise<Place[]>;
32
+ constructor(map: GoogleMap, _options: PlacesServiceOptions);
33
+ search(query: string, location?: Location): Promise<Place[]>;
34
34
  searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
35
35
  searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
36
36
  private searchImpl;
@@ -40,8 +40,8 @@ export declare class BaiduPlacesService extends PlacesService {
40
40
  private searchRequestMap;
41
41
  get inner(): BMap.LocalSearch;
42
42
  currentSearch: BMap.LocalSearch | undefined;
43
- constructor(map: BaiduMap, _options: PlaceServiceOptions);
44
- search(query: string, location?: string | LatLng): Promise<Place[]>;
43
+ constructor(map: BaiduMap, _options: PlacesServiceOptions);
44
+ search(query: string, location?: Location): Promise<Place[]>;
45
45
  searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
46
46
  searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
47
47
  private newSearch;
@@ -30,7 +30,7 @@ export declare class GoogleSearchBox extends SearchBox {
30
30
  }
31
31
  export declare class BaiduSearchBox extends SearchBox {
32
32
  private autocomplete;
33
- private placeService;
33
+ private placesService;
34
34
  constructor(map: BaiduMap, options: SearchBoxOptions);
35
35
  setSearchListener(onData: EventCallback<Place[]>, onError?: (e: any) => void): RemoveEventListenerFunction;
36
36
  search(): void;
@@ -6,8 +6,9 @@ import { GoogleMapTypeControl } from './controls/map-type.control';
6
6
  import { GoogleScaleControl } from './controls/scale.control';
7
7
  import { GoogleZoomControl } from './controls/zoom.control';
8
8
  import { Autocomplete, type AutocompleteOptions } from './extra/autocomplete';
9
+ import { type MapUrls, type MapUrlsOptions } from './extra/map-urls';
9
10
  import { GoogleMarkerClusterer, type MarkerClustererOptions } from './extra/marker-clusterer';
10
- import { type PlaceServiceOptions, type PlacesService } from './extra/places-service';
11
+ import { type PlacesService, type PlacesServiceOptions } from './extra/places-service';
11
12
  import { SearchBox, type SearchBoxOptions } from './extra/search-box';
12
13
  import { AbstractMap } from './map';
13
14
  import type { GestureHandlingOptions, MapOptions, MapStyle } from './map-options';
@@ -72,5 +73,6 @@ export declare class GoogleMap extends AbstractMap {
72
73
  createMarkerClusterer(options: MarkerClustererOptions): GoogleMarkerClusterer;
73
74
  createAutocomplete(options: AutocompleteOptions): Autocomplete;
74
75
  createSearchBox(options: SearchBoxOptions): SearchBox;
75
- createPlaceService(options: PlaceServiceOptions): PlacesService;
76
+ createPlacesService(options: PlacesServiceOptions): PlacesService;
77
+ createMapUrlsService(options: MapUrlsOptions): MapUrls;
76
78
  }
@@ -6,8 +6,9 @@ import type { MapTypeControl, MapTypeControlOptions } from './controls/map-type.
6
6
  import type { ScaleControlOptions } from './controls/scale.control';
7
7
  import type { ZoomControl, ZoomControlOptions } from './controls/zoom.control';
8
8
  import type { Autocomplete, AutocompleteOptions } from './extra/autocomplete';
9
+ import type { MapUrls, MapUrlsOptions } from './extra/map-urls';
9
10
  import type { MarkerClusterer, MarkerClustererOptions } from './extra/marker-clusterer';
10
- import type { PlaceServiceOptions, PlacesService } from './extra/places-service';
11
+ import type { PlacesService, PlacesServiceOptions } from './extra/places-service';
11
12
  import type { SearchBox, SearchBoxOptions } from './extra/search-box';
12
13
  import { AbstractMap } from './map';
13
14
  import type { GestureHandlingOptions, MapOptions, MapStyle } from './map-options';
@@ -57,7 +58,8 @@ export declare class HereMap extends AbstractMap {
57
58
  createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
58
59
  createAutocomplete(options: AutocompleteOptions): Autocomplete;
59
60
  createSearchBox(options: SearchBoxOptions): SearchBox;
60
- createPlaceService(options: PlaceServiceOptions): PlacesService;
61
+ createPlacesService(options: PlacesServiceOptions): PlacesService;
62
+ createMapUrlsService(options: MapUrlsOptions): MapUrls;
61
63
  createInfoWindow(options: InfoWindowOptions): InfoWindowOverlay;
62
64
  createInfoBox(options: InfoBoxOptions): InfoBoxOverlay;
63
65
  createPolyline(options: PolylineOptions): PolylineOverlay;
@@ -24,6 +24,15 @@ export interface MapOptions {
24
24
  center: LatLng;
25
25
  /** 缩放等级, 必须是整数 */
26
26
  zoom: number;
27
+ /**
28
+ * ## 不同行为
29
+ * - baidu: 只支持单窗口
30
+ * - google: 支持单窗口或多窗口, 默认多窗口
31
+ *
32
+ * 要显示多个弹窗, 推荐使用InfoBox替代
33
+ *
34
+ * {@macros info_window_vs_box}
35
+ */
27
36
  infoWindowMode?: InfoWindowMode;
28
37
  gestureHandling?: GestureHandlingOptions;
29
38
  minZoom?: number;
@@ -9,8 +9,9 @@ import type { MapTypeControl, MapTypeControlOptions } from './controls/map-type.
9
9
  import type { ScaleControlOptions } from './controls/scale.control';
10
10
  import type { ZoomControl, ZoomControlOptions } from './controls/zoom.control';
11
11
  import type { Autocomplete, AutocompleteOptions } from './extra/autocomplete';
12
+ import type { MapUrls, MapUrlsOptions } from './extra/map-urls';
12
13
  import type { MarkerClusterer, MarkerClustererOptions } from './extra/marker-clusterer';
13
- import type { PlaceServiceOptions, PlacesService } from './extra/places-service';
14
+ import type { PlacesService, PlacesServiceOptions } from './extra/places-service';
14
15
  import type { SearchBox, SearchBoxOptions } from './extra/search-box';
15
16
  import type { GestureHandlingOptions, MapStyle } from './map-options';
16
17
  import type { BuildInMapTypeId, Layer, MapType, OverlayMapType } from './map-type';
@@ -27,7 +28,9 @@ import type { RectangleOptions, RectangleOverlay } from './overlay/rectangle';
27
28
  export type AbstractMapEventMap = {
28
29
  click: Tg.MouseEvent;
29
30
  dblclick: Tg.MouseEvent;
31
+ /** @deprecated 使用`contextmenu`替代 */
30
32
  rightclick: Tg.MouseEvent;
33
+ contextmenu: Tg.MouseEvent;
31
34
  dragstart: Tg.Event;
32
35
  drag: Tg.Event;
33
36
  dragend: Tg.Event;
@@ -134,7 +137,8 @@ export declare abstract class AbstractMap implements CoordTypeSupplier, Tg.Event
134
137
  abstract createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
135
138
  abstract createAutocomplete(options: AutocompleteOptions): Autocomplete;
136
139
  abstract createSearchBox(options: SearchBoxOptions): SearchBox;
137
- abstract createPlaceService(options: PlaceServiceOptions): PlacesService;
140
+ abstract createPlacesService(options: PlacesServiceOptions): PlacesService;
141
+ abstract createMapUrlsService(options: MapUrlsOptions): MapUrls;
138
142
  abstract createInfoWindow(options: InfoWindowOptions): InfoWindowOverlay;
139
143
  abstract createInfoBox(options: InfoBoxOptions): InfoBoxOverlay;
140
144
  abstract createPolyline(options: PolylineOptions): PolylineOverlay;
@@ -36,10 +36,15 @@ export declare function createBaiduInfoBox(content: HTMLElement, position?: BMap
36
36
  }): void;
37
37
  };
38
38
  /**
39
+ * {@template info_window_vs_box}
39
40
  * baidu自带的InfoWindow有如下问题:
40
41
  * 1. 窗体不可自定义, 默认的窗体有点丑
41
42
  * 2. 一次只能显示一个
42
43
  * 3. 和MarkerClusterer的配合并不好, 重建聚合时会使InfoWindow消失
44
+ *
45
+ * 故重新实现了一个InfoBox, 解决上述问题, 用来替代InfoWindow, 但Info也点问题...:
46
+ * 1. 未实现InfoWindow的autoPan功能
47
+ * {@endtemplate }
43
48
  */
44
49
  declare function createBaiduInfoBoxClass(): {
45
50
  new (content: HTMLElement, position?: BMap.Point, offset?: Point, zIndex?: number, maxWidth?: number, borderClass?: string): {
@@ -21,6 +21,7 @@ export interface InfoBoxOptions {
21
21
  maxWidth?: number;
22
22
  borderClass?: string;
23
23
  }
24
+ /** {@macros info_window_vs_box} */
24
25
  export interface InfoBox extends Tg.EventTarget {
25
26
  open(anchor?: Marker): void;
26
27
  close(): void;
@@ -36,7 +36,9 @@ export interface MarkerOptions extends OverlayOptions {
36
36
  export type MarkerEventMap = {
37
37
  click: Tg.MouseEvent;
38
38
  dblclick: Tg.MouseEvent;
39
+ /** @deprecated 使用`contextmenu`替代 */
39
40
  rightclick: Tg.MouseEvent;
41
+ contextmenu: Tg.MouseEvent;
40
42
  mousedown: Tg.MouseEvent;
41
43
  mouseup: Tg.MouseEvent;
42
44
  mouseout: Tg.MouseEvent;
@@ -7,3 +7,10 @@ export declare function debug(msg?: any): any;
7
7
  export declare function noop(...args: any[]): void;
8
8
  /** 可以用在Array.filter(isDef)中, 用来过滤为空的值 */
9
9
  export declare function isDef<T>(v: T | undefined | null): v is T;
10
+ /**
11
+ * entry的value是否定义了
12
+ *
13
+ * 可以用在Array.filter(isEntryValueDef)中, 用来过滤值为空的元素
14
+ * @see isDef
15
+ */
16
+ export declare function isEntryValueDef<K, V>(entry: [K, V]): entry is [K, NonNullable<V>];