tg-map-core 0.0.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/dist/index.cjs +6394 -0
- package/dist/index.css +77 -0
- package/dist/index.mjs +6277 -0
- package/dist/src/index.d.ts +50 -0
- package/dist/src/map/event-target.d.ts +80 -0
- package/dist/src/map/event.d.ts +50 -0
- package/dist/src/map/lat-lng.d.ts +160 -0
- package/dist/src/map/map/baidu-map.d.ts +82 -0
- package/dist/src/map/map/controls/control.d.ts +112 -0
- package/dist/src/map/map/controls/map-type.control.d.ts +29 -0
- package/dist/src/map/map/controls/scale.control.d.ts +19 -0
- package/dist/src/map/map/controls/street-view.control.d.ts +25 -0
- package/dist/src/map/map/controls/zoom.control.d.ts +19 -0
- package/dist/src/map/map/extra/autocomplete.d.ts +42 -0
- package/dist/src/map/map/extra/heatmap.d.ts +71 -0
- package/dist/src/map/map/extra/map-urls.d.ts +59 -0
- package/dist/src/map/map/extra/marker-clusterer.d.ts +73 -0
- package/dist/src/map/map/extra/places-service.d.ts +47 -0
- package/dist/src/map/map/extra/search-box.d.ts +38 -0
- package/dist/src/map/map/google-map.d.ts +81 -0
- package/dist/src/map/map/here-map.d.ts +78 -0
- package/dist/src/map/map/map-options.d.ts +60 -0
- package/dist/src/map/map/map-type.d.ts +110 -0
- package/dist/src/map/map/map.d.ts +198 -0
- package/dist/src/map/map/overlay/baidu-info-box.d.ts +82 -0
- package/dist/src/map/map/overlay/circle.d.ts +51 -0
- package/dist/src/map/map/overlay/element-overlay.d.ts +37 -0
- package/dist/src/map/map/overlay/google-label.d.ts +68 -0
- package/dist/src/map/map/overlay/icon.d.ts +122 -0
- package/dist/src/map/map/overlay/info-box.d.ts +60 -0
- package/dist/src/map/map/overlay/info-window.d.ts +111 -0
- package/dist/src/map/map/overlay/label.d.ts +102 -0
- package/dist/src/map/map/overlay/marker-label.d.ts +19 -0
- package/dist/src/map/map/overlay/marker.d.ts +144 -0
- package/dist/src/map/map/overlay/overlay.d.ts +46 -0
- package/dist/src/map/map/overlay/polygon.d.ts +42 -0
- package/dist/src/map/map/overlay/polyline.d.ts +71 -0
- package/dist/src/map/map/overlay/rectangle.d.ts +50 -0
- package/dist/src/map/map/overlay/shape.d.ts +76 -0
- package/dist/src/map/map/talks-map.d.ts +81 -0
- package/dist/src/map/map-config.d.ts +29 -0
- package/dist/src/map/map-factory.d.ts +33 -0
- package/dist/src/map/map-loader.d.ts +19 -0
- package/dist/src/map/talks/talks-layers.d.ts +9 -0
- package/dist/src/map/talks/talks-utils.d.ts +7 -0
- package/dist/src/map/types.d.ts +17 -0
- package/dist/src/map/unions.d.ts +20 -0
- package/dist/src/utils/arrays.d.ts +19 -0
- package/dist/src/utils/baidu-utils.d.ts +23 -0
- package/dist/src/utils/elements.d.ts +4 -0
- package/dist/src/utils/formatter.d.ts +1 -0
- package/dist/src/utils/google-utils.d.ts +34 -0
- package/dist/src/utils/here-utils.d.ts +10 -0
- package/dist/src/utils/map-utils.d.ts +7 -0
- package/dist/src/utils/mapped-types.d.ts +110 -0
- package/dist/src/utils/maps-utils/index.d.ts +2 -0
- package/dist/src/utils/maps-utils/math-util.d.ts +59 -0
- package/dist/src/utils/maps-utils/poly-util.d.ts +103 -0
- package/dist/src/utils/maps-utils/spherical-util.d.ts +67 -0
- package/dist/src/utils/objects.d.ts +27 -0
- package/dist/src/utils/spherical-utils.d.ts +27 -0
- package/dist/src/utils/strings.d.ts +21 -0
- package/dist/src/utils/utils.d.ts +14 -0
- package/dist/src/utils/values.d.ts +34 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type AddressFields } from '../../../utils/google-utils';
|
|
2
|
+
import type { EventCallback } from '../../../utils/utils';
|
|
3
|
+
import { type RemoveEventListenerFunction } from '../../event-target';
|
|
4
|
+
import type { LatLngBounds } from '../../lat-lng';
|
|
5
|
+
import type { UnionAutocomplete } from '../../unions';
|
|
6
|
+
import type { BaiduMap } from '../baidu-map';
|
|
7
|
+
import type { GoogleMap } from '../google-map';
|
|
8
|
+
import type { AbstractMap } from '../map';
|
|
9
|
+
export interface AutocompleteResult extends AddressFields {
|
|
10
|
+
/** 名字 */
|
|
11
|
+
title: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AutocompleteOptions {
|
|
14
|
+
input: HTMLInputElement;
|
|
15
|
+
/** 将{@link Autocomplete.setBounds}自动设为地图的当前范围 */
|
|
16
|
+
bindToMap?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 该类没有太多事件, 故没有去实现{@link Tg.EventTarget}接口
|
|
20
|
+
*/
|
|
21
|
+
export declare abstract class Autocomplete {
|
|
22
|
+
abstract inner: UnionAutocomplete;
|
|
23
|
+
abstract map: AbstractMap;
|
|
24
|
+
abstract addResultListener(listener: EventCallback<AutocompleteResult>): RemoveEventListenerFunction;
|
|
25
|
+
abstract setBounds(bounds: LatLngBounds): void;
|
|
26
|
+
}
|
|
27
|
+
export declare class GoogleAutocomplete extends Autocomplete {
|
|
28
|
+
map: GoogleMap;
|
|
29
|
+
inner: google.maps.places.Autocomplete;
|
|
30
|
+
constructor(map: GoogleMap, options: AutocompleteOptions);
|
|
31
|
+
setBounds(bounds: LatLngBounds): void;
|
|
32
|
+
addResultListener(listener: EventCallback<AutocompleteResult>): RemoveEventListenerFunction;
|
|
33
|
+
}
|
|
34
|
+
export declare class BaiduAutocomplete extends Autocomplete {
|
|
35
|
+
map: BaiduMap;
|
|
36
|
+
inner: BMap.Autocomplete;
|
|
37
|
+
private input;
|
|
38
|
+
private removeableArray;
|
|
39
|
+
constructor(map: BaiduMap, options: AutocompleteOptions);
|
|
40
|
+
setBounds(bounds: LatLngBounds): void;
|
|
41
|
+
addResultListener(listener: EventCallback<AutocompleteResult>): RemoveEventListenerFunction;
|
|
42
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import BHeatMapOverlay from 'bmaplib.heatmap';
|
|
2
|
+
import type { LatLng, WeightedLatLng } from '../../lat-lng';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
import type { GoogleMap } from '../google-map';
|
|
5
|
+
import type { AbstractMap } from '../map';
|
|
6
|
+
type BHeatMapOverlayType = InstanceType<typeof BHeatMapOverlay>;
|
|
7
|
+
export interface HeatmapOptions {
|
|
8
|
+
data: HeatmapData;
|
|
9
|
+
/**
|
|
10
|
+
* 透明度
|
|
11
|
+
*
|
|
12
|
+
* ## 不同效果
|
|
13
|
+
* - google: 正常
|
|
14
|
+
* - baidu: 设置透明度后模糊效果有问题, 感觉是bug
|
|
15
|
+
*/
|
|
16
|
+
opacity?: number;
|
|
17
|
+
/**
|
|
18
|
+
* 半径
|
|
19
|
+
*
|
|
20
|
+
* ## 默认半径的区别
|
|
21
|
+
* - google: 默认半径是10
|
|
22
|
+
* - baidu: 默认半径是40
|
|
23
|
+
*
|
|
24
|
+
* 这里统一成默认半径{@link RADIUS_DEFAULT}
|
|
25
|
+
*/
|
|
26
|
+
radius?: number;
|
|
27
|
+
/**
|
|
28
|
+
* ## 不同实现
|
|
29
|
+
* - google: 接收颜色数组, 不能设置插值的位置
|
|
30
|
+
* - baidu: 接收`{.1: 'red', .9: 'green'}`形式的颜色对象, 可以指定插值的位置
|
|
31
|
+
*/
|
|
32
|
+
gradient?: Record<number, string>;
|
|
33
|
+
maxIntensity?: number;
|
|
34
|
+
}
|
|
35
|
+
export type HeatmapData = (LatLng | WeightedLatLng)[];
|
|
36
|
+
export declare abstract class Heatmap {
|
|
37
|
+
abstract inner: google.maps.visualization.HeatmapLayer | BHeatMapOverlayType;
|
|
38
|
+
abstract map: AbstractMap;
|
|
39
|
+
/** 只更新data */
|
|
40
|
+
abstract setData(data: HeatmapData): void;
|
|
41
|
+
/** 一次性更新所有options */
|
|
42
|
+
abstract setOptions(options: HeatmapOptions): void;
|
|
43
|
+
/**
|
|
44
|
+
* 从地图上移除
|
|
45
|
+
* 创建之后会被立即添加到地图上, 故只有remove方法
|
|
46
|
+
* */
|
|
47
|
+
abstract remove(): void;
|
|
48
|
+
}
|
|
49
|
+
export declare class GoogleHeatmap extends Heatmap {
|
|
50
|
+
map: GoogleMap;
|
|
51
|
+
inner: google.maps.visualization.HeatmapLayer;
|
|
52
|
+
constructor(map: GoogleMap, options: HeatmapOptions);
|
|
53
|
+
setData(data: HeatmapData): void;
|
|
54
|
+
setOptions(options: HeatmapOptions): void;
|
|
55
|
+
remove(): void;
|
|
56
|
+
}
|
|
57
|
+
export declare class BaiduHeatmap extends Heatmap {
|
|
58
|
+
map: BaiduMap;
|
|
59
|
+
inner: BHeatMapOverlayType;
|
|
60
|
+
/**
|
|
61
|
+
* 当前的最大值
|
|
62
|
+
* 直接读取/修改`inner.data.max`, 实现类似google那种, 可以直接设置最大值的效果
|
|
63
|
+
* */
|
|
64
|
+
private get innerDataMax();
|
|
65
|
+
private set innerDataMax(value);
|
|
66
|
+
constructor(map: BaiduMap, options: HeatmapOptions);
|
|
67
|
+
setData(data: HeatmapData): void;
|
|
68
|
+
setOptions(options: HeatmapOptions): void;
|
|
69
|
+
remove(): void;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Location, type LatLng } 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
|
+
*/
|
|
21
|
+
abstract search(location: Location): URL;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @see https://developers.google.com/maps/documentation/urls/get-started
|
|
25
|
+
*/
|
|
26
|
+
export declare class GoogleMapUrls extends MapUrls {
|
|
27
|
+
static BASE_URL: string;
|
|
28
|
+
/** @see https://developers.google.com/maps/documentation/urls/get-started#directions-action */
|
|
29
|
+
directions(origin: Location | undefined, destination: Location, mode?: GoogleDirectionMode): URL;
|
|
30
|
+
/** @see https://developers.google.com/maps/documentation/urls/get-started#search-action */
|
|
31
|
+
search(location: Location): URL;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @see https://lbsyun.baidu.com/faq/api?title=webapi/uri
|
|
35
|
+
*/
|
|
36
|
+
export declare class BaiduMapUrls extends MapUrls {
|
|
37
|
+
static BASE_URL: string;
|
|
38
|
+
/**
|
|
39
|
+
* 导航
|
|
40
|
+
* @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
|
|
41
|
+
* */
|
|
42
|
+
directions(origin: Location | undefined, destination: Location, mode?: DirectionMode): URL;
|
|
43
|
+
search(location: Location): URL;
|
|
44
|
+
/**
|
|
45
|
+
* 显示经纬度, {@link markerApi}中途跳转的url, 一定能够定位到
|
|
46
|
+
* */
|
|
47
|
+
latlngApi(location: LatLng): URL;
|
|
48
|
+
/**
|
|
49
|
+
* 显示marker点, 由于缓存等因素的存在, 不一定能够定位到点
|
|
50
|
+
* @see https://lbsyun.baidu.com/faq/api?title=webapi/uri/web#%E5%9B%BE%E5%8C%BA%E5%8A%9F%E8%83%BD
|
|
51
|
+
*/
|
|
52
|
+
markerApi(location: LatLng, title: string, content: string): URL;
|
|
53
|
+
/**
|
|
54
|
+
* 编码/反编码, 由于缓存等因素的存在, 不一定能够定位到点
|
|
55
|
+
* @see https://lbsyun.baidu.com/faq/api?title=webapi/uri/web#%E5%9B%BE%E5%8C%BA%E5%8A%9F%E8%83%BD:~:text=%E4%B8%8D%E4%BF%9D%E8%AF%81%E6%9C%8D%E5%8A%A1%E3%80%82-,2.1.2%20%E5%9C%B0%E5%9D%80%E8%A7%A3%E6%9E%90,-%E8%B0%83%E7%94%A8%E8%AF%A5
|
|
56
|
+
* */
|
|
57
|
+
geocoderApi(location: Location): URL;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import GMarkerClusterer from '@google/markerclusterer';
|
|
2
|
+
import BMarkerClusterer from 'bmaplib.markerclusterer';
|
|
3
|
+
import type { Point, Size } from '../../types';
|
|
4
|
+
import type { BaiduMap } from '../baidu-map';
|
|
5
|
+
import type { GoogleMap } from '../google-map';
|
|
6
|
+
import type { AbstractMap } from '../map';
|
|
7
|
+
import type { MarkerOverlay } from '../overlay/marker';
|
|
8
|
+
export interface MarkerClustererOptions {
|
|
9
|
+
markers?: MarkerOverlay[];
|
|
10
|
+
gridSize?: number;
|
|
11
|
+
maxZoom?: number;
|
|
12
|
+
minClusterSize?: number;
|
|
13
|
+
averageCenter?: boolean;
|
|
14
|
+
styles?: ClusterIconStyle[];
|
|
15
|
+
stylesIndexCalculator?: (markersLength: number, stylesLength: number) => number;
|
|
16
|
+
zIndex?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface ClusterIconStyle {
|
|
19
|
+
url: string;
|
|
20
|
+
size: Size;
|
|
21
|
+
anchor?: Point;
|
|
22
|
+
offset?: Point;
|
|
23
|
+
textColor?: string;
|
|
24
|
+
textSize?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* ## GMarkerClusterer 和 BMarkerClusterer 的区别
|
|
28
|
+
*
|
|
29
|
+
* GMarkerClusterer
|
|
30
|
+
* - resetViewport(): 移除
|
|
31
|
+
* - redraw(): 绘制新的
|
|
32
|
+
* - repaint(): 先移除, 再绘制
|
|
33
|
+
* - setXxx(): 只修改值, 不触发repaint()
|
|
34
|
+
* - add/removeMarker/s(): 接收`opt_nodraw`参数, 为true时不触发redraw/repaint()
|
|
35
|
+
* - clearMarkers(): 只有clear才会将marker从map上移除
|
|
36
|
+
*
|
|
37
|
+
* BMarkerClusterer
|
|
38
|
+
* - _clearLastClusters(): 移除
|
|
39
|
+
* - _createClusters(): 绘制新的
|
|
40
|
+
* - _redraw(): 先移除, 再重绘
|
|
41
|
+
* - setXxx(): 修改值, 同时触发_redraw()
|
|
42
|
+
* - add/removeMarker/s(): 每次都触发_redraw/_createClusters()
|
|
43
|
+
* - clearMarkers(): 同GMarkerClusterer
|
|
44
|
+
*
|
|
45
|
+
* H.clustering.Provider(here的点聚合工具类)
|
|
46
|
+
* - 和baidu/google的api有很大不同, 但总体倾向于baidu的实现, 每次修改坐标点都触发重新计算点聚合
|
|
47
|
+
*/
|
|
48
|
+
export declare abstract class MarkerClusterer {
|
|
49
|
+
map: AbstractMap;
|
|
50
|
+
abstract inner: any;
|
|
51
|
+
constructor(map: AbstractMap);
|
|
52
|
+
/** baidu/google 拥有相同的函数名 */
|
|
53
|
+
clearMarkers(): void;
|
|
54
|
+
/** @see clearMarkers */
|
|
55
|
+
addMarker(marker: MarkerOverlay): void;
|
|
56
|
+
/** @see clearMarkers */
|
|
57
|
+
removeMarker(marker: MarkerOverlay): boolean;
|
|
58
|
+
/** @see clearMarkers */
|
|
59
|
+
addMarkers(markers: MarkerOverlay[]): void;
|
|
60
|
+
/** @see clearMarkers */
|
|
61
|
+
removeMarkers(markers: MarkerOverlay[]): boolean;
|
|
62
|
+
abstract recreate(): void;
|
|
63
|
+
}
|
|
64
|
+
export declare class BaiduMarkerClusterer extends MarkerClusterer {
|
|
65
|
+
inner: BMarkerClusterer;
|
|
66
|
+
constructor(map: BaiduMap, options: MarkerClustererOptions);
|
|
67
|
+
recreate(): void;
|
|
68
|
+
}
|
|
69
|
+
export declare class GoogleMarkerClusterer extends MarkerClusterer {
|
|
70
|
+
inner: GMarkerClusterer;
|
|
71
|
+
constructor(map: GoogleMap, options: MarkerClustererOptions);
|
|
72
|
+
recreate(): void;
|
|
73
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LatLng, LatLngBounds, Location } from '../../lat-lng';
|
|
2
|
+
import type { UnionPlacesService } from '../../unions';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
import type { GoogleMap } from '../google-map';
|
|
5
|
+
import type { AbstractMap } from '../map';
|
|
6
|
+
export interface Place {
|
|
7
|
+
id: string;
|
|
8
|
+
position: LatLng;
|
|
9
|
+
country: string;
|
|
10
|
+
province: string;
|
|
11
|
+
city: string;
|
|
12
|
+
title: string;
|
|
13
|
+
address: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PlacesServiceOptions {
|
|
16
|
+
}
|
|
17
|
+
export declare abstract class PlacesService {
|
|
18
|
+
abstract inner: UnionPlacesService;
|
|
19
|
+
abstract map: AbstractMap;
|
|
20
|
+
constructor();
|
|
21
|
+
/** 指定{@link location}搜索, 若不指定, 则默认使用地图的中心点 */
|
|
22
|
+
abstract search(query: string, location?: Location): Promise<Place[]>;
|
|
23
|
+
/** 在指定的bounds范围内搜索 */
|
|
24
|
+
abstract searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
|
|
25
|
+
/** 在指定的center+radius范围内搜索 */
|
|
26
|
+
abstract searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
|
|
27
|
+
}
|
|
28
|
+
export declare class GooglePlacesService extends PlacesService {
|
|
29
|
+
map: GoogleMap;
|
|
30
|
+
inner: google.maps.places.PlacesService;
|
|
31
|
+
constructor(map: GoogleMap, _options: PlacesServiceOptions);
|
|
32
|
+
search(query: string, location?: Location): Promise<Place[]>;
|
|
33
|
+
searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
|
|
34
|
+
searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
|
|
35
|
+
private searchImpl;
|
|
36
|
+
}
|
|
37
|
+
export declare class BaiduPlacesService extends PlacesService {
|
|
38
|
+
map: BaiduMap;
|
|
39
|
+
private searchRequestMap;
|
|
40
|
+
get inner(): BMap.LocalSearch;
|
|
41
|
+
currentSearch: BMap.LocalSearch | undefined;
|
|
42
|
+
constructor(map: BaiduMap, _options: PlacesServiceOptions);
|
|
43
|
+
search(query: string, location?: Location): Promise<Place[]>;
|
|
44
|
+
searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
|
|
45
|
+
searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
|
|
46
|
+
private newSearch;
|
|
47
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { EventCallback } from '../../../utils/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 { BaseMap } 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: BaseMap;
|
|
12
|
+
protected input: HTMLInputElement;
|
|
13
|
+
protected onData: EventCallback<Place[]> | undefined;
|
|
14
|
+
protected onError: ((e: any) => void) | undefined;
|
|
15
|
+
constructor(map: BaseMap, 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 placesService;
|
|
34
|
+
constructor(map: BaiduMap, options: SearchBoxOptions);
|
|
35
|
+
setSearchListener(onData: EventCallback<Place[]>, onError?: (e: any) => void): RemoveEventListenerFunction;
|
|
36
|
+
search(): void;
|
|
37
|
+
private searchImpl;
|
|
38
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { LatLng, LatLngBounds } from '../lat-lng';
|
|
2
|
+
import { Point, type Padding } from '../types';
|
|
3
|
+
import { CustomControl } from './controls/control';
|
|
4
|
+
import { GoogleMapTypeControl } from './controls/map-type.control';
|
|
5
|
+
import { GoogleScaleControl } from './controls/scale.control';
|
|
6
|
+
import { GoogleStreetViewControl } from './controls/street-view.control';
|
|
7
|
+
import { GoogleZoomControl } from './controls/zoom.control';
|
|
8
|
+
import { Autocomplete, type AutocompleteOptions } from './extra/autocomplete';
|
|
9
|
+
import { type Heatmap, type HeatmapOptions } from './extra/heatmap';
|
|
10
|
+
import { type MapUrls, type MapUrlsOptions } from './extra/map-urls';
|
|
11
|
+
import { GoogleMarkerClusterer, type MarkerClustererOptions } from './extra/marker-clusterer';
|
|
12
|
+
import { type PlacesService, type PlacesServiceOptions } from './extra/places-service';
|
|
13
|
+
import { SearchBox, type SearchBoxOptions } from './extra/search-box';
|
|
14
|
+
import { BaseMap } from './map';
|
|
15
|
+
import type { GestureHandlingOptions, MapOptions, MapStyle } from './map-options';
|
|
16
|
+
import { BuildInMapTypeId, MapType, type Layer, type OverlayMapType } from './map-type';
|
|
17
|
+
import { GoogleCircle } from './overlay/circle';
|
|
18
|
+
import type { ElementOverlay } from './overlay/element-overlay';
|
|
19
|
+
import { GoogleInfoBoxOverlay } from './overlay/info-box';
|
|
20
|
+
import { GoogleInfoWindow } from './overlay/info-window';
|
|
21
|
+
import { GoogleLabelOverlay } from './overlay/label';
|
|
22
|
+
import { GoogleMarker } from './overlay/marker';
|
|
23
|
+
import type { GoogleOverlay } from './overlay/overlay';
|
|
24
|
+
import { GooglePolygon } from './overlay/polygon';
|
|
25
|
+
import { GooglePolyline } from './overlay/polyline';
|
|
26
|
+
import { GoogleRectangle } from './overlay/rectangle';
|
|
27
|
+
export declare class GoogleMap extends BaseMap {
|
|
28
|
+
mapOptions: MapOptions;
|
|
29
|
+
private buildInMapTypeId2BIMT;
|
|
30
|
+
private googleMapTypeId2BIMT;
|
|
31
|
+
private map;
|
|
32
|
+
constructor(element: HTMLElement, mapOptions: MapOptions);
|
|
33
|
+
setGestureHandling(gestureHandling?: GestureHandlingOptions): void;
|
|
34
|
+
get innerMap(): google.maps.Map;
|
|
35
|
+
get coordType(): import("../lat-lng").CoordType;
|
|
36
|
+
fromContainerPointToLatLng(point: Point): LatLng;
|
|
37
|
+
fromLatLngToContainerPoint(latLng: LatLng): Point;
|
|
38
|
+
setDefaultCursor(cursor: string): void;
|
|
39
|
+
setDraggable(draggable: boolean): void;
|
|
40
|
+
setDoubleClickZoom(enable: boolean): void;
|
|
41
|
+
getCenter(): LatLng;
|
|
42
|
+
setCenter(latlng: LatLng): void;
|
|
43
|
+
setMinZoom(zoom: number): void;
|
|
44
|
+
setMaxZoom(zoom: number): void;
|
|
45
|
+
setMapStyle(mapStyle?: MapStyle): void;
|
|
46
|
+
setBuildInMapTypeId(id: BuildInMapTypeId): void;
|
|
47
|
+
setMapType(mapType: MapType): void;
|
|
48
|
+
getMapType(): MapType;
|
|
49
|
+
addOverlayMapType(mapType: OverlayMapType): void;
|
|
50
|
+
removeOverlayMapType(mapType: OverlayMapType): void;
|
|
51
|
+
addLayer(layer: Layer): void;
|
|
52
|
+
removeLayer(layer: Layer): void;
|
|
53
|
+
panTo(position: LatLng): void;
|
|
54
|
+
panBy(x: number, y: number): void;
|
|
55
|
+
fitBounds(bounds: LatLngBounds, padding?: Padding): void;
|
|
56
|
+
getBounds(): LatLngBounds;
|
|
57
|
+
addElementOverlay(overlay: ElementOverlay): void;
|
|
58
|
+
removeElementOverlay(overlay: ElementOverlay): void;
|
|
59
|
+
addOverlay(overlay: GoogleOverlay): void;
|
|
60
|
+
removeOverlay(overlay: GoogleOverlay): void;
|
|
61
|
+
addCustomControl(control: CustomControl): void;
|
|
62
|
+
removeCustomControl(control: CustomControl): void;
|
|
63
|
+
createLabel: typeof GoogleLabelOverlay.create;
|
|
64
|
+
createCircle: typeof GoogleCircle.create;
|
|
65
|
+
createPolygon: typeof GooglePolygon.create;
|
|
66
|
+
createPolyline: typeof GooglePolyline.create;
|
|
67
|
+
createRectangle: typeof GoogleRectangle.create;
|
|
68
|
+
createInfoWindow: typeof GoogleInfoWindow.create;
|
|
69
|
+
createInfoBox: typeof GoogleInfoBoxOverlay.create;
|
|
70
|
+
createMarker: typeof GoogleMarker.create;
|
|
71
|
+
createMapTypeControl: typeof GoogleMapTypeControl.create;
|
|
72
|
+
createZoomControl: typeof GoogleZoomControl.create;
|
|
73
|
+
createStreetViewControl: typeof GoogleStreetViewControl.create;
|
|
74
|
+
createScaleControl: typeof GoogleScaleControl.create;
|
|
75
|
+
createMarkerClusterer(options: MarkerClustererOptions): GoogleMarkerClusterer;
|
|
76
|
+
createHeatmap(options: HeatmapOptions): Heatmap;
|
|
77
|
+
createAutocomplete(options: AutocompleteOptions): Autocomplete;
|
|
78
|
+
createSearchBox(options: SearchBoxOptions): SearchBox;
|
|
79
|
+
createPlacesService(options: PlacesServiceOptions): PlacesService;
|
|
80
|
+
createMapUrls(options: MapUrlsOptions): MapUrls;
|
|
81
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { CoordType, LatLng, LatLngBounds } from '../lat-lng';
|
|
2
|
+
import type { Padding, Point } from '../types';
|
|
3
|
+
import type { CustomControl } from './controls/control';
|
|
4
|
+
import type { MapTypeControl, MapTypeControlOptions } from './controls/map-type.control';
|
|
5
|
+
import type { ScaleControlOptions } from './controls/scale.control';
|
|
6
|
+
import type { StreetViewControl, StreetViewControlOptions } from './controls/street-view.control';
|
|
7
|
+
import type { ZoomControl, ZoomControlOptions } from './controls/zoom.control';
|
|
8
|
+
import type { Autocomplete, AutocompleteOptions } from './extra/autocomplete';
|
|
9
|
+
import type { Heatmap, HeatmapOptions } from './extra/heatmap';
|
|
10
|
+
import type { MapUrls, MapUrlsOptions } from './extra/map-urls';
|
|
11
|
+
import type { MarkerClusterer, MarkerClustererOptions } from './extra/marker-clusterer';
|
|
12
|
+
import type { PlacesService, PlacesServiceOptions } from './extra/places-service';
|
|
13
|
+
import type { SearchBox, SearchBoxOptions } from './extra/search-box';
|
|
14
|
+
import { BaseMap } from './map';
|
|
15
|
+
import type { GestureHandlingOptions, MapOptions, MapStyle } from './map-options';
|
|
16
|
+
import type { BuildInMapTypeId, Layer, MapType } from './map-type';
|
|
17
|
+
import type { CircleOptions, CircleOverlay } from './overlay/circle';
|
|
18
|
+
import type { ElementOverlay } from './overlay/element-overlay';
|
|
19
|
+
import type { InfoBoxOptions, InfoBoxOverlay } from './overlay/info-box';
|
|
20
|
+
import type { InfoWindowOptions, InfoWindowOverlay } from './overlay/info-window';
|
|
21
|
+
import type { LabelOptions, LabelOverlay } from './overlay/label';
|
|
22
|
+
import type { MarkerOptions, MarkerOverlay } from './overlay/marker';
|
|
23
|
+
import type { Overlay } from './overlay/overlay';
|
|
24
|
+
import type { PolygonOptions, PolygonOverlay } from './overlay/polygon';
|
|
25
|
+
import type { PolylineOptions, PolylineOverlay } from './overlay/polyline';
|
|
26
|
+
import type { RectangleOptions, RectangleOverlay } from './overlay/rectangle';
|
|
27
|
+
export declare class HereMap extends BaseMap {
|
|
28
|
+
mapOptions: MapOptions;
|
|
29
|
+
private map;
|
|
30
|
+
defaultLayers: H.service.DefaultLayers;
|
|
31
|
+
constructor(element: HTMLElement, mapOptions: MapOptions);
|
|
32
|
+
get innerMap(): H.Map;
|
|
33
|
+
get coordType(): CoordType;
|
|
34
|
+
getCenter(): LatLng;
|
|
35
|
+
setCenter(latlng: LatLng): void;
|
|
36
|
+
setGestureHandling(gestureHandling: GestureHandlingOptions): void;
|
|
37
|
+
fromContainerPointToLatLng(point: Point): LatLng;
|
|
38
|
+
fromLatLngToContainerPoint(latLng: LatLng): Point;
|
|
39
|
+
setDefaultCursor(cursor: string): void;
|
|
40
|
+
setDraggable(draggable: boolean): void;
|
|
41
|
+
setDoubleClickZoom(enable: boolean): void;
|
|
42
|
+
setMinZoom(zoom: number): void;
|
|
43
|
+
setMaxZoom(zoom: number): void;
|
|
44
|
+
setMapStyle(mapStyle?: MapStyle): void;
|
|
45
|
+
setBuildInMapTypeId(id: BuildInMapTypeId): void;
|
|
46
|
+
setMapType(mapType: MapType): void;
|
|
47
|
+
getMapType(): MapType;
|
|
48
|
+
addLayer(layer: Layer): void;
|
|
49
|
+
removeLayer(layer: Layer): void;
|
|
50
|
+
panTo(position: LatLng): void;
|
|
51
|
+
panBy(x: number, y: number): void;
|
|
52
|
+
fitBounds(bounds: LatLngBounds, padding?: Padding | undefined): void;
|
|
53
|
+
getBounds(): LatLngBounds;
|
|
54
|
+
addElementOverlay(overlay: ElementOverlay): void;
|
|
55
|
+
removeElementOverlay(overlay: ElementOverlay): void;
|
|
56
|
+
addOverlay(overlay: Overlay<unknown>): void;
|
|
57
|
+
removeOverlay(overlay: Overlay<unknown>): void;
|
|
58
|
+
createMarker(options: MarkerOptions): MarkerOverlay;
|
|
59
|
+
createMarkerClusterer(options: MarkerClustererOptions): MarkerClusterer;
|
|
60
|
+
createHeatmap(options: HeatmapOptions): Heatmap;
|
|
61
|
+
createAutocomplete(options: AutocompleteOptions): Autocomplete;
|
|
62
|
+
createSearchBox(options: SearchBoxOptions): SearchBox;
|
|
63
|
+
createPlacesService(options: PlacesServiceOptions): PlacesService;
|
|
64
|
+
createMapUrls(options: MapUrlsOptions): MapUrls;
|
|
65
|
+
createInfoWindow(options: InfoWindowOptions): InfoWindowOverlay;
|
|
66
|
+
createInfoBox(options: InfoBoxOptions): InfoBoxOverlay;
|
|
67
|
+
createPolyline(options: PolylineOptions): PolylineOverlay;
|
|
68
|
+
createPolygon(options: PolygonOptions): PolygonOverlay;
|
|
69
|
+
createRectangle(options: RectangleOptions): RectangleOverlay;
|
|
70
|
+
createCircle(options: CircleOptions): CircleOverlay;
|
|
71
|
+
createLabel(options: LabelOptions): LabelOverlay;
|
|
72
|
+
addCustomControl(control: CustomControl): void;
|
|
73
|
+
removeCustomControl(control: CustomControl): void;
|
|
74
|
+
createMapTypeControl(options: MapTypeControlOptions): MapTypeControl;
|
|
75
|
+
createZoomControl(options: ZoomControlOptions): ZoomControl;
|
|
76
|
+
createStreetViewControl(options: StreetViewControlOptions): StreetViewControl;
|
|
77
|
+
createScaleControl(options: ScaleControlOptions): ZoomControl;
|
|
78
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { LatLng } from '../lat-lng';
|
|
2
|
+
import type { BuildInMapTypeId } from './map-type';
|
|
3
|
+
export declare const InfoWindowModeValues: readonly ["single", "multi"];
|
|
4
|
+
export type InfoWindowMode = typeof InfoWindowModeValues[number];
|
|
5
|
+
/**
|
|
6
|
+
* 完全模仿google的模式, 合并如下配置:
|
|
7
|
+
* - draggable
|
|
8
|
+
* - scrollWheel
|
|
9
|
+
* - doubleClickZoom
|
|
10
|
+
*/
|
|
11
|
+
export declare enum GestureHandlingOptions {
|
|
12
|
+
/** 默认, 若页面可滚动, 则为cooperative, 否则为greedy */
|
|
13
|
+
auto = "auto",
|
|
14
|
+
/** 全部设为false */
|
|
15
|
+
none = "none",
|
|
16
|
+
/** 贪婪, 全部设为true */
|
|
17
|
+
greedy = "greedy",
|
|
18
|
+
/** 合作, 按住ctrl或者双指才能缩放地图 */
|
|
19
|
+
cooperative = "cooperative"
|
|
20
|
+
}
|
|
21
|
+
export interface MapOptions {
|
|
22
|
+
/** 中心点 */
|
|
23
|
+
center: LatLng;
|
|
24
|
+
/** 缩放等级, 必须是整数 */
|
|
25
|
+
zoom: number;
|
|
26
|
+
/**
|
|
27
|
+
* ## 不同行为
|
|
28
|
+
* - baidu: 只支持单窗口
|
|
29
|
+
* - google: 支持单窗口或多窗口, 默认多窗口
|
|
30
|
+
*
|
|
31
|
+
* 要显示多个弹窗, 推荐使用InfoBox替代
|
|
32
|
+
*
|
|
33
|
+
* {@macros info_window_vs_box}
|
|
34
|
+
*/
|
|
35
|
+
infoWindowMode?: InfoWindowMode;
|
|
36
|
+
gestureHandling?: GestureHandlingOptions;
|
|
37
|
+
minZoom?: number;
|
|
38
|
+
maxZoom?: number;
|
|
39
|
+
mapStyle?: MapStyle;
|
|
40
|
+
buildInMapTypeId?: BuildInMapTypeId;
|
|
41
|
+
}
|
|
42
|
+
export declare namespace MapOptions {
|
|
43
|
+
function create(options?: Partial<MapOptions>): MapOptions;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* ## 本地样式编辑器
|
|
47
|
+
* - google: https://mapstyle.withgoogle.com/
|
|
48
|
+
* - baidu: https://lbsyun.baidu.com/apiconsole/custommap
|
|
49
|
+
*
|
|
50
|
+
* ## 关于云端样式
|
|
51
|
+
* - google: mapId只有创建时有效, 之后再更改无效
|
|
52
|
+
* - baidu: styleId无效, 原因未知
|
|
53
|
+
*/
|
|
54
|
+
export interface MapStyle {
|
|
55
|
+
baidu: BMap.MapStyleV2;
|
|
56
|
+
google: {
|
|
57
|
+
styles?: google.maps.MapTypeStyle[];
|
|
58
|
+
mapId?: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { FastFindValues } from '../../utils/values';
|
|
2
|
+
import { CoordType } from '../lat-lng';
|
|
3
|
+
import type { Point } from '../types';
|
|
4
|
+
import type { GoogleLayer } from '../unions';
|
|
5
|
+
/**
|
|
6
|
+
* 内置地图的id
|
|
7
|
+
*/
|
|
8
|
+
export declare enum BuildInMapTypeId {
|
|
9
|
+
normal = "normal",
|
|
10
|
+
satellite = "satellite",
|
|
11
|
+
hybrid = "hybrid"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 包括不兼容的地图类型
|
|
15
|
+
* - 'terrain': google中为地形图, baidu中为三维图
|
|
16
|
+
* */
|
|
17
|
+
export type BuildInMapTypeIdIncludeIncompatible = BuildInMapTypeId | 'terrain';
|
|
18
|
+
/**
|
|
19
|
+
* ## 注意
|
|
20
|
+
* `asXxx()`多次调用时应返回同一个对象
|
|
21
|
+
*/
|
|
22
|
+
export interface MapType {
|
|
23
|
+
/** MapType的唯一标识符, 命名时推荐包含`-`, 防止和BuildInMapTypeId冲突 */
|
|
24
|
+
id: string;
|
|
25
|
+
getBaiduCoordType(): CoordType;
|
|
26
|
+
asBaiduMapType(): BaiduMapType;
|
|
27
|
+
getGoogleCoordType(): CoordType;
|
|
28
|
+
asGoogleMapType(): GoogleMapType;
|
|
29
|
+
}
|
|
30
|
+
export interface Layer {
|
|
31
|
+
asBaiduLayer(): BMap.TileLayer;
|
|
32
|
+
asGoogleLayer(): GoogleLayer;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 同时实现`MapType`和`Layer`的对象被称作`OverlayMapType`
|
|
36
|
+
* - 往google中添加`OverlayMapType`, 将被看作`MapType`
|
|
37
|
+
* - 往baidu中添加`OverlayMapType`, 将被看作`Layer`
|
|
38
|
+
* @see TgMap.addOverlayMapType
|
|
39
|
+
* @see TgMap.removeOverlayMapType
|
|
40
|
+
* @see ImageMapType
|
|
41
|
+
*/
|
|
42
|
+
export type OverlayMapType = MapType & Layer;
|
|
43
|
+
export declare class BuildInMapType implements MapType {
|
|
44
|
+
id: BuildInMapTypeIdIncludeIncompatible;
|
|
45
|
+
private baidu;
|
|
46
|
+
private google;
|
|
47
|
+
private googleCoordType;
|
|
48
|
+
constructor(id: BuildInMapTypeIdIncludeIncompatible, baidu: () => BMap.MapType, // 需要延迟初始化, 故写成方法
|
|
49
|
+
google: () => google.maps.MapTypeId, // 同上
|
|
50
|
+
googleCoordType: CoordType);
|
|
51
|
+
getId(): BuildInMapTypeIdIncludeIncompatible;
|
|
52
|
+
getBaiduCoordType(): CoordType;
|
|
53
|
+
asBaiduMapType(): BaiduMapType;
|
|
54
|
+
getGoogleCoordType(): CoordType;
|
|
55
|
+
/** 内置地图的id和google的id是不一样的 */
|
|
56
|
+
getGoogleMapTypeId(): google.maps.MapTypeId;
|
|
57
|
+
asGoogleMapType(): GoogleMapType;
|
|
58
|
+
}
|
|
59
|
+
export type GoogleMapType = google.maps.MapType & {
|
|
60
|
+
/** 需要在创建实例时设置该值 */
|
|
61
|
+
__google_map_type__?: MapType;
|
|
62
|
+
};
|
|
63
|
+
export type BaiduMapType = BMap.MapType & {
|
|
64
|
+
/** 需要在创建实例时设置该值 */
|
|
65
|
+
__baidu_map_type__?: MapType;
|
|
66
|
+
};
|
|
67
|
+
export interface ImageMapTypeOptions {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
/**
|
|
70
|
+
* @param tileCoord 统一成google的瓦片坐标, 原点在左上角
|
|
71
|
+
* @returns 返回值可以为空
|
|
72
|
+
*/
|
|
73
|
+
getTileUrl: (tileCoord: Point, zoom: number) => string | null;
|
|
74
|
+
maxZoom: number;
|
|
75
|
+
minZoom?: number;
|
|
76
|
+
name: string;
|
|
77
|
+
describe?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* ImageMapType应该同时实现MapType和Layer接口
|
|
81
|
+
*/
|
|
82
|
+
export declare class ImageMapType implements OverlayMapType {
|
|
83
|
+
coordType: CoordType;
|
|
84
|
+
options: ImageMapTypeOptions;
|
|
85
|
+
private baiduLayerCached;
|
|
86
|
+
private baiduMapTypeCached;
|
|
87
|
+
private googleCached;
|
|
88
|
+
constructor(coordType: CoordType, options: ImageMapTypeOptions);
|
|
89
|
+
get id(): string;
|
|
90
|
+
getBaiduCoordType(): CoordType;
|
|
91
|
+
asBaiduMapType(): BaiduMapType;
|
|
92
|
+
asBaiduLayer(): BMap.TileLayer;
|
|
93
|
+
getGoogleCoordType(): CoordType;
|
|
94
|
+
asGoogleMapType(): GoogleMapType;
|
|
95
|
+
asGoogleLayer(): GoogleLayer;
|
|
96
|
+
}
|
|
97
|
+
/** 交通流量图层 */
|
|
98
|
+
export declare class TrafficLayer implements Layer {
|
|
99
|
+
private baiduCache;
|
|
100
|
+
private googleCache;
|
|
101
|
+
asBaiduLayer(): BMap.TileLayer;
|
|
102
|
+
asGoogleLayer(): GoogleLayer;
|
|
103
|
+
}
|
|
104
|
+
export declare namespace MapType {
|
|
105
|
+
const NORMAL: BuildInMapType;
|
|
106
|
+
const SATELLITE: BuildInMapType;
|
|
107
|
+
const HYBRID: BuildInMapType;
|
|
108
|
+
const TERRAIN: BuildInMapType;
|
|
109
|
+
const BUILD_IN_MAP_TYPES: FastFindValues<BuildInMapType>;
|
|
110
|
+
}
|