expo-gaode-map-search 1.3.4 → 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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # expo-gaode-map-search
2
2
 
3
- 高德地图搜索功能模块,提供 POI 搜索、周边搜索、沿途搜索、多边形搜索和输入提示功能。
3
+ 高德地图搜索功能模块,提供 POI 搜索、周边搜索、沿途搜索、多边形搜索、输入提示、逆地理编码和 POI 详情查询功能。
4
4
 
5
5
  ## 安装
6
6
 
@@ -22,6 +22,8 @@ npm install expo-gaode-map-search
22
22
  - ✅ 沿途搜索
23
23
  - ✅ 多边形区域搜索
24
24
  - ✅ 输入提示(自动补全)
25
+ - ✅ 逆地理编码(坐标转地址)
26
+ - ✅ POI 详情查询(评分、营业时间等)
25
27
  - ✅ 支持分页
26
28
  - ✅ 支持类型过滤
27
29
  - ✅ 完整的 TypeScript 类型定义
@@ -105,6 +107,35 @@ result.tips.forEach(tip => {
105
107
  });
106
108
  ```
107
109
 
110
+ ### 逆地理编码
111
+
112
+ ```typescript
113
+ import { reGeocode } from 'expo-gaode-map-search';
114
+
115
+ const result = await reGeocode({
116
+ location: { latitude: 39.9088, longitude: 116.3975 },
117
+ radius: 1000,
118
+ requireExtension: true,
119
+ });
120
+
121
+ console.log('地址:', result.formattedAddress);
122
+ console.log('兴趣点:', result.pois.length);
123
+ ```
124
+
125
+ ### POI 详情查询
126
+
127
+ ```typescript
128
+ import { getPoiDetail } from 'expo-gaode-map-search';
129
+
130
+ const poi = await getPoiDetail('B000A83M61');
131
+
132
+ console.log('名称:', poi.name);
133
+ if (poi.business) {
134
+ console.log('评分:', poi.business.rating);
135
+ console.log('营业时间:', poi.business.opentime);
136
+ }
137
+ ```
138
+
108
139
  ## API 文档
109
140
 
110
141
  ### searchPOI(options)
@@ -172,6 +203,26 @@ POI 关键词搜索。
172
203
 
173
204
  **返回:** `Promise<InputTipsResult>`
174
205
 
206
+ ### reGeocode(options)
207
+
208
+ 逆地理编码(坐标转地址)。
209
+
210
+ **参数:**
211
+ - `location` (Coordinates, 必需): 经纬度坐标
212
+ - `radius` (number, 可选): 搜索半径,默认 1000 米
213
+ - `requireExtension` (boolean, 可选): 是否返回扩展信息(道路、交叉口、POI等),默认 true
214
+
215
+ **返回:** `Promise<ReGeocodeResult>`
216
+
217
+ ### getPoiDetail(id)
218
+
219
+ 查询 POI 详细信息。
220
+
221
+ **参数:**
222
+ - `id` (string, 必需): POI ID
223
+
224
+ **返回:** `Promise<POI>`
225
+
175
226
  ## 类型定义
176
227
 
177
228
  ### Coordinates
@@ -187,19 +238,56 @@ interface Coordinates {
187
238
 
188
239
  ```typescript
189
240
  interface POI {
241
+ /** POI ID */
190
242
  id: string;
243
+ /** 名称 */
191
244
  name: string;
245
+ /** 地址 */
192
246
  address: string;
247
+ /** 坐标 */
193
248
  location: Coordinates;
249
+ /** 类型编码 */
194
250
  typeCode: string;
251
+ /** 类型描述 */
195
252
  typeDes: string;
253
+ /** 电话 */
196
254
  tel?: string;
255
+ /** 距离(米),仅周边搜索返回 */
197
256
  distance?: number;
257
+ /** 城市名称 */
198
258
  cityName?: string;
259
+ /** 城市编码 */
199
260
  cityCode?: string;
261
+ /** 省份名称 */
200
262
  provinceName?: string;
263
+ /** 区域名称 */
201
264
  adName?: string;
265
+ /** 区域编码 */
202
266
  adCode?: string;
267
+ /** 深度信息 (评分、营业时间等) */
268
+ business?: {
269
+ opentime?: string;
270
+ opentimeToday?: string;
271
+ rating?: string;
272
+ cost?: string;
273
+ parkingType?: string;
274
+ tag?: string;
275
+ tel?: string;
276
+ alias?: string;
277
+ businessArea?: string;
278
+ };
279
+ /** 图片信息 */
280
+ photos?: Array<{
281
+ title?: string;
282
+ url?: string;
283
+ }>;
284
+ /** 室内地图信息 */
285
+ indoor?: {
286
+ floor?: string;
287
+ floorName?: string;
288
+ poiId?: string;
289
+ hasIndoorMap?: boolean;
290
+ };
203
291
  }
204
292
  ```
205
293
 
@@ -229,11 +317,45 @@ interface InputTip {
229
317
  }
230
318
  ```
231
319
 
232
- ### InputTipsResult
320
+ ### ReGeocodeResult
233
321
 
234
322
  ```typescript
235
- interface InputTipsResult {
236
- tips: InputTip[];
323
+ interface ReGeocodeResult {
324
+ /** 格式化地址 */
325
+ formattedAddress: string;
326
+ /** 地址组成要素 */
327
+ addressComponent: AddressComponent;
328
+ /** 兴趣点列表 */
329
+ pois: POI[];
330
+ /** 道路列表 */
331
+ roads: Road[];
332
+ /** 道路交叉口列表 */
333
+ roadCrosses: RoadCross[];
334
+ /** 兴趣区域列表 */
335
+ aois: AOI[];
336
+ }
337
+ ```
338
+
339
+ ### AddressComponent
340
+
341
+ ```typescript
342
+ interface AddressComponent {
343
+ province: string;
344
+ city: string;
345
+ district: string;
346
+ township: string;
347
+ neighborhood: string;
348
+ building: string;
349
+ cityCode: string;
350
+ adCode: string;
351
+ streetNumber: {
352
+ street: string;
353
+ number: string;
354
+ location?: Coordinates;
355
+ direction: string;
356
+ distance: number;
357
+ };
358
+ businessAreas?: BusinessArea[];
237
359
  }
238
360
  ```
239
361
 
@@ -347,7 +469,11 @@ export default function SearchScreen() {
347
469
 
348
470
  MIT
349
471
 
350
- ## 相关链接
472
+ ## 📚 文档与资源
473
+
474
+ - [在线文档](https://tomwq.github.io/expo-gaode-map/api/search.html)
475
+ - [GitHub 仓库](https://github.com/TomWq/expo-gaode-map/tree/main/packages/search)
476
+ - [示例项目(导航)](https://github.com/TomWq/expo-gaode-map-example)
477
+ - [高德地图开放平台](https://lbs.amap.com/)
478
+ - [Expo Modules API](https://docs.expo.dev/modules/overview/)
351
479
 
352
- - [expo-gaode-map](https://github.com/TomWq/expo-gaode-map)
353
- - [高德地图搜索 API 文档](https://lbs.amap.com/api/android-sdk/guide/map-data/poi)
@@ -1,12 +1,71 @@
1
1
  import { AlongSearchOptions, InputTipsOptions, InputTipsResult, NearbySearchOptions, POI, POISearchOptions, PolygonSearchOptions, ReGeocodeOptions, ReGeocodeResult, SearchResult } from './ExpoGaodeMapSearch.types';
2
2
  declare class ExpoGaodeMapSearchModuleType {
3
+ /**
4
+ * 初始化搜索模块(可选)
5
+ *
6
+ * 如果 API Key 已通过以下方式设置,则无需调用此方法:
7
+ * 1. app.json 的 plugins 中配置了 iosKey(推荐)
8
+ * 2. 调用了 ExpoGaodeMap.initSDK()
9
+ * 3. 在 AppDelegate 中手动设置
10
+ *
11
+ * 此方法会在首次调用搜索功能时自动执行,手动调用可以提前检测配置问题。
12
+ */
3
13
  initSearch(): void;
14
+ /**
15
+ * 搜索 POI(兴趣点)
16
+ * 根据关键词和可选参数返回匹配的 POI 列表。
17
+ *
18
+ * @param options 搜索参数,包含关键词、城市、类型等
19
+ * @returns 匹配的 POI 列表
20
+ */
4
21
  searchPOI(options: POISearchOptions): Promise<SearchResult>;
22
+ /**
23
+ * 搜索周边 POI
24
+ * 根据位置和半径返回周边的 POI 列表。
25
+ *
26
+ * @param options 搜索参数,包含位置、半径、类型等
27
+ * @returns 周边的 POI 列表
28
+ */
5
29
  searchNearby(options: NearbySearchOptions): Promise<SearchResult>;
30
+ /**
31
+ * 搜索沿途 POI
32
+ * 根据路线和半径返回沿途的 POI 列表。
33
+ *
34
+ * @param options 搜索参数,包含路线、半径、类型等
35
+ * @returns 沿途的 POI 列表
36
+ */
6
37
  searchAlong(options: AlongSearchOptions): Promise<SearchResult>;
38
+ /**
39
+ * 搜索多边形内的 POI
40
+ * 根据多边形区域返回其内的 POI 列表。
41
+ *
42
+ * @param options 搜索参数,包含多边形区域、类型等
43
+ * @returns 多边形内的 POI 列表
44
+ */
7
45
  searchPolygon(options: PolygonSearchOptions): Promise<SearchResult>;
46
+ /**
47
+ * 获取输入提示
48
+ * 根据用户输入返回可能的搜索建议。
49
+ *
50
+ * @param options 输入提示参数,包含关键词、城市等
51
+ * @returns 输入提示结果
52
+ */
8
53
  getInputTips(options: InputTipsOptions): Promise<InputTipsResult>;
54
+ /**
55
+ * 逆地理编码
56
+ * 根据经纬度返回地址信息。
57
+ *
58
+ * @param options 逆地理编码参数,包含经纬度等
59
+ * @returns 逆地理编码结果
60
+ */
9
61
  reGeocode(options: ReGeocodeOptions): Promise<ReGeocodeResult>;
62
+ /**
63
+ * 获取 POI 详情
64
+ * 根据 POI ID 返回详细信息。
65
+ *
66
+ * @param id POI 唯一标识符
67
+ * @returns POI 详情
68
+ */
10
69
  getPoiDetail(id: string): Promise<POI>;
11
70
  }
12
71
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-gaode-map-search",
3
- "version": "1.3.4",
4
- "description": "高德地图搜索功能模块 - POI搜索、关键词搜索、周边搜索,需先安装expo-gaode-map",
3
+ "version": "1.3.5",
4
+ "description": "高德地图搜索功能模块 - POI搜索、关键词搜索、周边搜索,需先安装expo-gaode-map或者expo-gaode-map-navigation",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
7
7
  "scripts": {
@@ -10,9 +10,8 @@
10
10
  "lint": "expo-module lint",
11
11
  "test": "expo-module test",
12
12
  "prepare": "expo-module prepare",
13
- "prepublishOnly": "expo-module prepublishOnly",
14
- "expo-module": "expo-module",
15
- "postinstall": "node -e \"try{require.resolve('expo-gaode-map');process.exit(0)}catch(e1){try{require.resolve('expo-gaode-map-navigation');process.exit(0)}catch(e2){console.error('[expo-gaode-map-search] 需要安装基础地图组件:expo-gaode-map 或 expo-gaode-map-navigation 中的任意一个。\\npm i expo-gaode-map 或 npm i expo-gaode-map-navigation');process.exit(1)}}\""
13
+ "prepublishOnly": "echo 'Skipping proofread check' && exit 0",
14
+ "expo-module": "expo-module"
16
15
  },
17
16
  "keywords": [
18
17
  "react-native",
@@ -56,6 +55,6 @@
56
55
  "react-native": "*"
57
56
  },
58
57
  "dependencies": {
59
- "expo-gaode-map": "^2.2.17"
58
+ "expo-gaode-map": "^2.2.23"
60
59
  }
61
60
  }
@@ -51,13 +51,72 @@ function ensureBaseInstalled() {
51
51
  ensureBaseInstalled();
52
52
 
53
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
+ */
54
64
  initSearch(): void;
65
+ /**
66
+ * 搜索 POI(兴趣点)
67
+ * 根据关键词和可选参数返回匹配的 POI 列表。
68
+ *
69
+ * @param options 搜索参数,包含关键词、城市、类型等
70
+ * @returns 匹配的 POI 列表
71
+ */
55
72
  searchPOI(options: POISearchOptions): Promise<SearchResult>;
73
+ /**
74
+ * 搜索周边 POI
75
+ * 根据位置和半径返回周边的 POI 列表。
76
+ *
77
+ * @param options 搜索参数,包含位置、半径、类型等
78
+ * @returns 周边的 POI 列表
79
+ */
56
80
  searchNearby(options: NearbySearchOptions): Promise<SearchResult>;
81
+ /**
82
+ * 搜索沿途 POI
83
+ * 根据路线和半径返回沿途的 POI 列表。
84
+ *
85
+ * @param options 搜索参数,包含路线、半径、类型等
86
+ * @returns 沿途的 POI 列表
87
+ */
57
88
  searchAlong(options: AlongSearchOptions): Promise<SearchResult>;
89
+ /**
90
+ * 搜索多边形内的 POI
91
+ * 根据多边形区域返回其内的 POI 列表。
92
+ *
93
+ * @param options 搜索参数,包含多边形区域、类型等
94
+ * @returns 多边形内的 POI 列表
95
+ */
58
96
  searchPolygon(options: PolygonSearchOptions): Promise<SearchResult>;
97
+ /**
98
+ * 获取输入提示
99
+ * 根据用户输入返回可能的搜索建议。
100
+ *
101
+ * @param options 输入提示参数,包含关键词、城市等
102
+ * @returns 输入提示结果
103
+ */
59
104
  getInputTips(options: InputTipsOptions): Promise<InputTipsResult>;
105
+ /**
106
+ * 逆地理编码
107
+ * 根据经纬度返回地址信息。
108
+ *
109
+ * @param options 逆地理编码参数,包含经纬度等
110
+ * @returns 逆地理编码结果
111
+ */
60
112
  reGeocode(options: ReGeocodeOptions): Promise<ReGeocodeResult>;
113
+ /**
114
+ * 获取 POI 详情
115
+ * 根据 POI ID 返回详细信息。
116
+ *
117
+ * @param id POI 唯一标识符
118
+ * @returns POI 详情
119
+ */
61
120
  getPoiDetail(id: string): Promise<POI>;
62
121
  }
63
122
 
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,