tg-map-vue3 3.1.9 → 3.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.
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/map/event-target.d.ts +2 -0
- package/dist/src/map/map/baidu-map.d.ts +2 -0
- package/dist/src/map/map/extra/autocomplete.d.ts +9 -3
- package/dist/src/map/map/extra/places-service.d.ts +10 -5
- package/dist/src/map/map/extra/search-box.d.ts +38 -0
- package/dist/src/map/map/google-map.d.ts +2 -0
- package/dist/src/map/map/here-map.d.ts +2 -0
- package/dist/src/map/map/map.d.ts +2 -0
- package/dist/src/map/unions.d.ts +1 -1
- package/dist/src/utils/google-utils.d.ts +3 -0
- package/dist/tg-map.js +759 -677
- package/dist/tg-map.js.map +1 -1
- package/dist/tg-map.umd.cjs +4 -4
- package/dist/tg-map.umd.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ export * from '../map/map/controls/zoom.control';
|
|
|
17
17
|
export * from '../map/map/extra/autocomplete';
|
|
18
18
|
export * from '../map/map/extra/marker-clusterer';
|
|
19
19
|
export * from '../map/map/extra/places-service';
|
|
20
|
+
export * from '../map/map/extra/search-box';
|
|
20
21
|
export * from '../map/map/map';
|
|
21
22
|
export * from '../map/map/overlay/circle';
|
|
22
23
|
export * from '../map/map/overlay/icon';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AbstractMap, AbstractMapEventMap } from '../components';
|
|
1
2
|
import { type Tg } from './event';
|
|
2
3
|
import { type CoordTypeSupplier } from './lat-lng';
|
|
3
4
|
import type { UnionBaiduEventTarget, UnionGoogleEventTarget } from './unions';
|
|
@@ -14,6 +15,7 @@ export interface RemoveEventListenerFunction {
|
|
|
14
15
|
export declare function addGoogleEventListener(target: UnionGoogleEventTarget, type: string, listener: (...args: any[]) => void): RemoveEventListenerFunction;
|
|
15
16
|
export declare function addBaiduEventListener(target: UnionBaiduEventTarget, type: string, listener: (...args: any[]) => void): RemoveEventListenerFunction;
|
|
16
17
|
export declare function addHtmlEventListener<K extends keyof EventMap, EventMap = HTMLElementEventMap, T extends EventTarget = HTMLElement>(target: T, type: K, listener: (this: T, ev: EventMap[K]) => any, options?: AddEventListenerOptions | boolean): RemoveEventListenerFunction;
|
|
18
|
+
export declare function addTgEventListener<K extends keyof EventMap, EventMap = AbstractMapEventMap, T extends Tg.EventTarget = AbstractMap>(target: T, type: K, listener: (this: T, ev: EventMap[K]) => any): RemoveEventListenerFunction;
|
|
17
19
|
/**
|
|
18
20
|
* ## Delegate(代理) VS Mixin(混合)
|
|
19
21
|
* Delegate相对于Mixin的优点是调用路径更明确, 缺点是js/ts原生不支持, 需要写样板代码
|
|
@@ -7,6 +7,7 @@ import { BaiduZoomControl } from './controls/zoom.control';
|
|
|
7
7
|
import { type Autocomplete, type AutocompleteOptions } from './extra/autocomplete';
|
|
8
8
|
import { BaiduMarkerClusterer, type MarkerClustererOptions } from './extra/marker-clusterer';
|
|
9
9
|
import { type PlaceServiceOptions, type PlacesService } from './extra/places-service';
|
|
10
|
+
import { type SearchBox, type SearchBoxOptions } from './extra/search-box';
|
|
10
11
|
import { AbstractMap, type AbstractMapEventMap } from './map';
|
|
11
12
|
import { GestureHandlingOptions, MapOptions, type MapStyle } from './map-options';
|
|
12
13
|
import { BuildInMapTypeId, MapType, type Layer } from './map-type';
|
|
@@ -68,5 +69,6 @@ export declare class BaiduMap extends AbstractMap {
|
|
|
68
69
|
createScaleControl: typeof BaiduScaleControl.create;
|
|
69
70
|
createMarkerClusterer(options: MarkerClustererOptions): BaiduMarkerClusterer;
|
|
70
71
|
createAutocomplete(options: AutocompleteOptions): Autocomplete;
|
|
72
|
+
createSearchBox(options: SearchBoxOptions): SearchBox;
|
|
71
73
|
createPlaceService(options: PlaceServiceOptions): PlacesService;
|
|
72
74
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="google.maps" />
|
|
2
|
-
import {
|
|
2
|
+
import type { EventCallback, LatLngBounds } from '../../../components';
|
|
3
3
|
import { type AddressFields } from '../../../utils/google-utils';
|
|
4
4
|
import { type RemoveEventListenerFunction } from '../../event-target';
|
|
5
5
|
import type { UnionAutocomplete } from '../../unions';
|
|
@@ -12,25 +12,31 @@ export interface AutocompleteResult extends AddressFields {
|
|
|
12
12
|
}
|
|
13
13
|
export interface AutocompleteOptions {
|
|
14
14
|
input: HTMLInputElement;
|
|
15
|
+
/** 将{@link Autocomplete.setBounds}自动设为地图的当前范围 */
|
|
15
16
|
bindToMap?: boolean;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* 该类没有太多事件, 故没有去实现{@link Tg.EventTarget}接口
|
|
19
20
|
*/
|
|
20
21
|
export declare abstract class Autocomplete {
|
|
21
|
-
map: AbstractMap;
|
|
22
22
|
abstract inner: UnionAutocomplete;
|
|
23
|
-
|
|
23
|
+
abstract map: AbstractMap;
|
|
24
24
|
abstract addResultListener(listener: EventCallback<AutocompleteResult>): RemoveEventListenerFunction;
|
|
25
|
+
abstract setBounds(bounds: LatLngBounds): void;
|
|
25
26
|
}
|
|
26
27
|
export declare class GoogleAutocomplete extends Autocomplete {
|
|
28
|
+
map: GoogleMap;
|
|
27
29
|
inner: google.maps.places.Autocomplete;
|
|
28
30
|
constructor(map: GoogleMap, options: AutocompleteOptions);
|
|
31
|
+
setBounds(bounds: LatLngBounds): void;
|
|
29
32
|
addResultListener(listener: EventCallback<AutocompleteResult>): RemoveEventListenerFunction;
|
|
30
33
|
}
|
|
31
34
|
export declare class BaiduAutocomplete extends Autocomplete {
|
|
35
|
+
map: BaiduMap;
|
|
32
36
|
inner: BMap.Autocomplete;
|
|
33
37
|
private input;
|
|
38
|
+
private removeableArray;
|
|
34
39
|
constructor(map: BaiduMap, options: AutocompleteOptions);
|
|
40
|
+
setBounds(bounds: LatLngBounds): void;
|
|
35
41
|
addResultListener(listener: EventCallback<AutocompleteResult>): RemoveEventListenerFunction;
|
|
36
42
|
}
|
|
@@ -16,27 +16,32 @@ export interface Place {
|
|
|
16
16
|
export interface PlaceServiceOptions {
|
|
17
17
|
}
|
|
18
18
|
export declare abstract class PlacesService {
|
|
19
|
-
map: AbstractMap;
|
|
20
19
|
abstract inner: UnionPlacesService;
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
abstract map: AbstractMap;
|
|
21
|
+
constructor();
|
|
22
|
+
/** 指定{@link location}搜索, 若不指定, 则默认使用地图的中心点 */
|
|
23
|
+
abstract search(query: string, location?: string | LatLng): Promise<Place[]>;
|
|
24
|
+
/** 在指定的bounds范围内搜索 */
|
|
23
25
|
abstract searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
|
|
26
|
+
/** 在指定的center+radius范围内搜索 */
|
|
24
27
|
abstract searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
|
|
25
28
|
}
|
|
26
29
|
export declare class GooglePlacesService extends PlacesService {
|
|
30
|
+
map: GoogleMap;
|
|
27
31
|
inner: google.maps.places.PlacesService;
|
|
28
32
|
constructor(map: GoogleMap, options: PlaceServiceOptions);
|
|
29
|
-
search(query: string): Promise<Place[]>;
|
|
33
|
+
search(query: string, location?: string | LatLng): Promise<Place[]>;
|
|
30
34
|
searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
|
|
31
35
|
searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
|
|
32
36
|
private searchImpl;
|
|
33
37
|
}
|
|
34
38
|
export declare class BaiduPlacesService extends PlacesService {
|
|
39
|
+
map: BaiduMap;
|
|
35
40
|
private searchRequestMap;
|
|
36
41
|
get inner(): BMap.LocalSearch;
|
|
37
42
|
currentSearch: BMap.LocalSearch | undefined;
|
|
38
43
|
constructor(map: BaiduMap, options: PlaceServiceOptions);
|
|
39
|
-
search(query: string): Promise<Place[]>;
|
|
44
|
+
search(query: string, location?: string | LatLng): Promise<Place[]>;
|
|
40
45
|
searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
|
|
41
46
|
searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
|
|
42
47
|
private newSearch;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { EventCallback } from '../../../utils/vue-utils';
|
|
2
|
+
import { type RemoveEventListenerFunction } from '../../event-target';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
import type { GoogleMap } from '../google-map';
|
|
5
|
+
import type { AbstractMap } from '../map';
|
|
6
|
+
import type { Place } from './places-service';
|
|
7
|
+
export interface SearchBoxOptions {
|
|
8
|
+
input: HTMLInputElement;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class SearchBox {
|
|
11
|
+
map: AbstractMap;
|
|
12
|
+
protected input: HTMLInputElement;
|
|
13
|
+
protected onData: EventCallback<Place[]> | undefined;
|
|
14
|
+
protected onError: ((e: any) => void) | undefined;
|
|
15
|
+
constructor(map: AbstractMap, input: HTMLInputElement);
|
|
16
|
+
/**
|
|
17
|
+
* 设置搜索结果监听
|
|
18
|
+
*
|
|
19
|
+
* @mustCallSuper 子类必须调用一次`super.setSearchListener`, 用来保存{@link onData}和{@link onError}
|
|
20
|
+
* */
|
|
21
|
+
setSearchListener(onData: EventCallback<Place[]>, onError?: (e: any) => void): RemoveEventListenerFunction;
|
|
22
|
+
/** 用输入框的内容执行一次搜索 */
|
|
23
|
+
abstract search(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare class GoogleSearchBox extends SearchBox {
|
|
26
|
+
private searchBox;
|
|
27
|
+
constructor(map: GoogleMap, options: SearchBoxOptions);
|
|
28
|
+
setSearchListener(onData: EventCallback<Place[]>, onError?: (e: any) => void): RemoveEventListenerFunction;
|
|
29
|
+
search(): void;
|
|
30
|
+
}
|
|
31
|
+
export declare class BaiduSearchBox extends SearchBox {
|
|
32
|
+
private autocomplete;
|
|
33
|
+
private placeService;
|
|
34
|
+
constructor(map: BaiduMap, options: SearchBoxOptions);
|
|
35
|
+
setSearchListener(onData: EventCallback<Place[]>, onError?: (e: any) => void): RemoveEventListenerFunction;
|
|
36
|
+
search(): void;
|
|
37
|
+
private searchImpl;
|
|
38
|
+
}
|
|
@@ -8,6 +8,7 @@ import { GoogleZoomControl } from './controls/zoom.control';
|
|
|
8
8
|
import { Autocomplete, type AutocompleteOptions } from './extra/autocomplete';
|
|
9
9
|
import { GoogleMarkerClusterer, type MarkerClustererOptions } from './extra/marker-clusterer';
|
|
10
10
|
import { type PlaceServiceOptions, type PlacesService } from './extra/places-service';
|
|
11
|
+
import { SearchBox, type SearchBoxOptions } from './extra/search-box';
|
|
11
12
|
import { AbstractMap } from './map';
|
|
12
13
|
import type { GestureHandlingOptions, MapOptions, MapStyle } from './map-options';
|
|
13
14
|
import { BuildInMapTypeId, MapType, type Layer, type OverlayMapType } from './map-type';
|
|
@@ -68,5 +69,6 @@ export declare class GoogleMap extends AbstractMap {
|
|
|
68
69
|
createScaleControl: typeof GoogleScaleControl.create;
|
|
69
70
|
createMarkerClusterer(options: MarkerClustererOptions): GoogleMarkerClusterer;
|
|
70
71
|
createAutocomplete(options: AutocompleteOptions): Autocomplete;
|
|
72
|
+
createSearchBox(options: SearchBoxOptions): SearchBox;
|
|
71
73
|
createPlaceService(options: PlaceServiceOptions): PlacesService;
|
|
72
74
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { CoordType, LatLng } from '../lat-lng';
|
|
3
3
|
import type { Autocomplete, AutocompleteOptions } from './extra/autocomplete';
|
|
4
4
|
import type { PlaceServiceOptions, PlacesService } from './extra/places-service';
|
|
5
|
+
import type { SearchBox, SearchBoxOptions } from './extra/search-box';
|
|
5
6
|
import { AbstractMap } from './map';
|
|
6
7
|
import type { MapOptions } from './map-options';
|
|
7
8
|
export declare class HereMap extends AbstractMap {
|
|
@@ -49,5 +50,6 @@ export declare class HereMap extends AbstractMap {
|
|
|
49
50
|
createZoomControl(options: import('./controls/zoom.control').ZoomControlOptions): import('./controls/zoom.control').ZoomControl;
|
|
50
51
|
createScaleControl(options: import('./controls/scale.control').ScaleControlOptions): import('./controls/zoom.control').ZoomControl;
|
|
51
52
|
createAutocomplete(options: AutocompleteOptions): Autocomplete;
|
|
53
|
+
createSearchBox(options: SearchBoxOptions): SearchBox;
|
|
52
54
|
createPlaceService(options: PlaceServiceOptions): PlacesService;
|
|
53
55
|
}
|
|
@@ -10,6 +10,7 @@ import type { ZoomControl, ZoomControlOptions } from './controls/zoom.control';
|
|
|
10
10
|
import type { Autocomplete, AutocompleteOptions } from './extra/autocomplete';
|
|
11
11
|
import type { MarkerClusterer, MarkerClustererOptions } from './extra/marker-clusterer';
|
|
12
12
|
import type { PlaceServiceOptions, PlacesService } from './extra/places-service';
|
|
13
|
+
import type { SearchBox, SearchBoxOptions } from './extra/search-box';
|
|
13
14
|
import type { GestureHandlingOptions, MapStyle } from './map-options';
|
|
14
15
|
import type { BuildInMapTypeId, Layer, MapType, OverlayMapType } from './map-type';
|
|
15
16
|
import type { CircleOptions, CircleOverlay } from './overlay/circle';
|
|
@@ -122,6 +123,7 @@ export declare abstract class AbstractMap implements CoordTypeSupplier, Tg.Event
|
|
|
122
123
|
abstract createMarker(options: MarkerOptions): MarkerOverlay;
|
|
123
124
|
abstract createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
|
|
124
125
|
abstract createAutocomplete(options: AutocompleteOptions): Autocomplete;
|
|
126
|
+
abstract createSearchBox(options: SearchBoxOptions): SearchBox;
|
|
125
127
|
abstract createPlaceService(options: PlaceServiceOptions): PlacesService;
|
|
126
128
|
abstract createInfoWindow(options: InfoWindowOptions): InfoWindowOverlay;
|
|
127
129
|
abstract createInfoBox(options: InfoBoxOptions): InfoBoxOverlay;
|
package/dist/src/map/unions.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { GoogleLabel } from './map/overlay/google-label';
|
|
|
10
10
|
export type UnionMap = google.maps.Map | BMap.Map | H.Map;
|
|
11
11
|
export type UnionIcon = google.maps.Icon | google.maps.Symbol | google.maps.UrlIcon | BMap.Icon;
|
|
12
12
|
export type UnionInfoWindow = google.maps.InfoWindow | BMap.InfoWindow;
|
|
13
|
-
export type UnionAutocomplete = google.maps.places.Autocomplete |
|
|
13
|
+
export type UnionAutocomplete = google.maps.places.Autocomplete | BMap.Autocomplete;
|
|
14
14
|
export type UnionPlacesService = google.maps.places.PlacesService | BMap.LocalSearch;
|
|
15
15
|
export type UnionGoogleOverlay = google.maps.Marker | google.maps.Polyline | google.maps.Polygon | google.maps.Circle | google.maps.Rectangle | GoogleLabel;
|
|
16
16
|
export type UnionBaiduOverlay = BMap.Marker | BMap.Polyline | BMap.Polygon | BMap.Circle | BMap.Label | BaiduInfoBox;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="google.maps" />
|
|
2
|
+
import { type CoordTypeSupplier } from '../map/lat-lng';
|
|
3
|
+
import type { Place } from '../map/map/extra/places-service';
|
|
2
4
|
/**
|
|
3
5
|
* Google地图官方提供的载入方式, 使用{@link google.map.importLibrary}动态载入依赖
|
|
4
6
|
*
|
|
@@ -29,3 +31,4 @@ export interface AddressFields {
|
|
|
29
31
|
streetNumber: string;
|
|
30
32
|
}
|
|
31
33
|
export declare function parseGoogleAddressComponents(addressComponents: google.maps.GeocoderAddressComponent[], outResult?: AddressFields): AddressFields;
|
|
34
|
+
export declare function parseGooglePlace(place: google.maps.places.PlaceResult, coordTypeSupplier: CoordTypeSupplier): Place;
|