tg-map-vue3 3.5.7 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
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]为空时中心点计算问题
@@ -45,6 +50,7 @@
45
50
  [SymbolIcon]: src/map/map/overlay/icon.ts#L55 "Svg图标"
46
51
  [PlacesService]: src/map/map/extra/places-service.ts "位置服务"
47
52
  [Autocomplete]: src/map/map/extra/autocomplete.ts "自动完成"
53
+ [MapUrls]: src/map/map/extra/map-urls.ts "地图网页"
48
54
  [SearchBox]: src/map/map/extra/search-box.ts "搜索框"
49
55
  [useTgMapInner]: src/components/map-hooks.ts
50
56
  [LatLngBounds]: src/map/lat-lng.ts#L157
@@ -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';
@@ -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
+ createMapUrls(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
+ createMapUrls(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
+ createMapUrls(options: MapUrlsOptions): MapUrls;
61
63
  createInfoWindow(options: InfoWindowOptions): InfoWindowOverlay;
62
64
  createInfoBox(options: InfoBoxOptions): InfoBoxOverlay;
63
65
  createPolyline(options: PolylineOptions): PolylineOverlay;
@@ -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';
@@ -136,7 +137,8 @@ export declare abstract class AbstractMap implements CoordTypeSupplier, Tg.Event
136
137
  abstract createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
137
138
  abstract createAutocomplete(options: AutocompleteOptions): Autocomplete;
138
139
  abstract createSearchBox(options: SearchBoxOptions): SearchBox;
139
- abstract createPlaceService(options: PlaceServiceOptions): PlacesService;
140
+ abstract createPlacesService(options: PlacesServiceOptions): PlacesService;
141
+ abstract createMapUrls(options: MapUrlsOptions): MapUrls;
140
142
  abstract createInfoWindow(options: InfoWindowOptions): InfoWindowOverlay;
141
143
  abstract createInfoBox(options: InfoBoxOptions): InfoBoxOverlay;
142
144
  abstract createPolyline(options: PolylineOptions): PolylineOverlay;
@@ -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>];