expo-gaode-map-search 1.3.3 → 1.3.5

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.
@@ -1,6 +1,20 @@
1
1
 
2
2
  import { requireNativeModule } from 'expo-modules-core';
3
3
 
4
+ import {
5
+ AlongSearchOptions,
6
+ InputTipsOptions,
7
+ InputTipsResult,
8
+ NearbySearchOptions,
9
+ POI,
10
+ POISearchOptions,
11
+ PolygonSearchOptions,
12
+ ReGeocodeOptions,
13
+ ReGeocodeResult,
14
+ SearchResult,
15
+ } from './ExpoGaodeMapSearch.types';
16
+
17
+
4
18
  /**
5
19
  * 在加载原生搜索模块前,强制校验基础地图组件是否已安装。
6
20
  * 支持两种“基础地图提供者”:expo-gaode-map 或 expo-gaode-map-navigation(导航内置地图)。
@@ -36,11 +50,81 @@ function ensureBaseInstalled() {
36
50
 
37
51
  ensureBaseInstalled();
38
52
 
53
+ declare class ExpoGaodeMapSearchModuleType {
54
+ /**
55
+ * 初始化搜索模块(可选)
56
+ *
57
+ * 如果 API Key 已通过以下方式设置,则无需调用此方法:
58
+ * 1. app.json 的 plugins 中配置了 iosKey(推荐)
59
+ * 2. 调用了 ExpoGaodeMap.initSDK()
60
+ * 3. 在 AppDelegate 中手动设置
61
+ *
62
+ * 此方法会在首次调用搜索功能时自动执行,手动调用可以提前检测配置问题。
63
+ */
64
+ initSearch(): void;
65
+ /**
66
+ * 搜索 POI(兴趣点)
67
+ * 根据关键词和可选参数返回匹配的 POI 列表。
68
+ *
69
+ * @param options 搜索参数,包含关键词、城市、类型等
70
+ * @returns 匹配的 POI 列表
71
+ */
72
+ searchPOI(options: POISearchOptions): Promise<SearchResult>;
73
+ /**
74
+ * 搜索周边 POI
75
+ * 根据位置和半径返回周边的 POI 列表。
76
+ *
77
+ * @param options 搜索参数,包含位置、半径、类型等
78
+ * @returns 周边的 POI 列表
79
+ */
80
+ searchNearby(options: NearbySearchOptions): Promise<SearchResult>;
81
+ /**
82
+ * 搜索沿途 POI
83
+ * 根据路线和半径返回沿途的 POI 列表。
84
+ *
85
+ * @param options 搜索参数,包含路线、半径、类型等
86
+ * @returns 沿途的 POI 列表
87
+ */
88
+ searchAlong(options: AlongSearchOptions): Promise<SearchResult>;
89
+ /**
90
+ * 搜索多边形内的 POI
91
+ * 根据多边形区域返回其内的 POI 列表。
92
+ *
93
+ * @param options 搜索参数,包含多边形区域、类型等
94
+ * @returns 多边形内的 POI 列表
95
+ */
96
+ searchPolygon(options: PolygonSearchOptions): Promise<SearchResult>;
97
+ /**
98
+ * 获取输入提示
99
+ * 根据用户输入返回可能的搜索建议。
100
+ *
101
+ * @param options 输入提示参数,包含关键词、城市等
102
+ * @returns 输入提示结果
103
+ */
104
+ getInputTips(options: InputTipsOptions): Promise<InputTipsResult>;
105
+ /**
106
+ * 逆地理编码
107
+ * 根据经纬度返回地址信息。
108
+ *
109
+ * @param options 逆地理编码参数,包含经纬度等
110
+ * @returns 逆地理编码结果
111
+ */
112
+ reGeocode(options: ReGeocodeOptions): Promise<ReGeocodeResult>;
113
+ /**
114
+ * 获取 POI 详情
115
+ * 根据 POI ID 返回详细信息。
116
+ *
117
+ * @param id POI 唯一标识符
118
+ * @returns POI 详情
119
+ */
120
+ getPoiDetail(id: string): Promise<POI>;
121
+ }
122
+
39
123
  /**
40
124
  * 高德地图搜索模块
41
125
  *
42
126
  * 提供 POI 搜索、周边搜索、沿途搜索、多边形搜索和输入提示功能
43
127
  */
44
- const ExpoGaodeMapSearchModule = requireNativeModule('ExpoGaodeMapSearch');
128
+ const ExpoGaodeMapSearchModule = requireNativeModule<ExpoGaodeMapSearchModuleType>('ExpoGaodeMapSearch');
45
129
 
46
- export default ExpoGaodeMapSearchModule;
130
+ export default ExpoGaodeMapSearchModule;
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import ExpoGaodeMapSearchModule from './ExpoGaodeMapSearchModule';
2
2
  import type {
3
- SearchType,
4
3
  Coordinates,
5
4
  POI,
6
5
  POISearchOptions,
@@ -11,6 +10,12 @@ import type {
11
10
  InputTip,
12
11
  SearchResult,
13
12
  InputTipsResult,
13
+ ReGeocodeOptions,
14
+ ReGeocodeResult,
15
+ AddressComponent,
16
+ Road,
17
+ RoadCross,
18
+ AOI,
14
19
  } from './ExpoGaodeMapSearch.types';
15
20
 
16
21
  /**
@@ -143,6 +148,41 @@ export async function getInputTips(options: InputTipsOptions): Promise<InputTips
143
148
  return await ExpoGaodeMapSearchModule.getInputTips(options);
144
149
  }
145
150
 
151
+ /**
152
+ * 逆地理编码(坐标转地址)
153
+ *
154
+ * @param options 逆地理编码选项
155
+ * @returns 逆地理编码结果
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * const result = await reGeocode({
160
+ * location: { latitude: 39.9, longitude: 116.4 },
161
+ * radius: 1000,
162
+ * });
163
+ * console.log(result.formattedAddress);
164
+ * ```
165
+ */
166
+ export async function reGeocode(options: ReGeocodeOptions): Promise<ReGeocodeResult> {
167
+ return await ExpoGaodeMapSearchModule.reGeocode(options);
168
+ }
169
+
170
+ /**
171
+ * POI 详情查询
172
+ *
173
+ * @param id POI ID
174
+ * @returns POI 详情
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * const poi = await getPoiDetail('B000A83M61');
179
+ * console.log(poi.name, poi.address);
180
+ * ```
181
+ */
182
+ export async function getPoiDetail(id: string): Promise<POI> {
183
+ return await ExpoGaodeMapSearchModule.getPoiDetail(id);
184
+ }
185
+
146
186
  // 导出类型和枚举
147
187
  export type {
148
188
  Coordinates,
@@ -155,6 +195,12 @@ export type {
155
195
  InputTip,
156
196
  SearchResult,
157
197
  InputTipsResult,
198
+ ReGeocodeOptions,
199
+ ReGeocodeResult,
200
+ AddressComponent,
201
+ Road,
202
+ RoadCross,
203
+ AOI,
158
204
  };
159
205
 
160
206
  export { SearchType } from './ExpoGaodeMapSearch.types';
@@ -167,4 +213,5 @@ export default {
167
213
  searchAlong,
168
214
  searchPolygon,
169
215
  getInputTips,
216
+ reGeocode,
170
217
  };