expo-gaode-map-web-api 1.1.3 → 1.1.4-next.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.
|
@@ -113,7 +113,7 @@ export declare class POIService {
|
|
|
113
113
|
* const result = await poi.getDetail('B000A8VE1H|B0FFKEPXS2', 'business,photos');
|
|
114
114
|
* ```
|
|
115
115
|
*/
|
|
116
|
-
getDetail(id: string, show_fields?: string): Promise<POISearchResponse>;
|
|
116
|
+
getDetail(id: string, show_fields?: string, version?: 'v3' | 'v5'): Promise<POISearchResponse>;
|
|
117
117
|
/**
|
|
118
118
|
* 批量查询POI详情
|
|
119
119
|
*
|
|
@@ -129,5 +129,5 @@ export declare class POIService {
|
|
|
129
129
|
* ], 'business,photos');
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
132
|
-
batchGetDetail(ids: string[], show_fields?: string): Promise<POISearchResponse>;
|
|
132
|
+
batchGetDetail(ids: string[], show_fields?: string, version?: 'v3' | 'v5'): Promise<POISearchResponse>;
|
|
133
133
|
}
|
|
@@ -41,11 +41,13 @@ class POIService {
|
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
43
|
async search(keywords, options) {
|
|
44
|
+
const { version = 'v5', ...rest } = options || {};
|
|
44
45
|
const params = {
|
|
45
46
|
keywords,
|
|
46
|
-
...
|
|
47
|
+
...rest,
|
|
47
48
|
};
|
|
48
|
-
|
|
49
|
+
const path = `/${version}/place/text`;
|
|
50
|
+
return this.client.request(path, params);
|
|
49
51
|
}
|
|
50
52
|
/**
|
|
51
53
|
* 周边搜索
|
|
@@ -88,11 +90,13 @@ class POIService {
|
|
|
88
90
|
else {
|
|
89
91
|
locationStr = `${location.longitude},${location.latitude}`;
|
|
90
92
|
}
|
|
93
|
+
const { version = 'v5', ...rest } = options || {};
|
|
91
94
|
const params = {
|
|
92
95
|
location: locationStr,
|
|
93
|
-
...
|
|
96
|
+
...rest,
|
|
94
97
|
};
|
|
95
|
-
|
|
98
|
+
const path = `/${version}/place/around`;
|
|
99
|
+
return this.client.request(path, params);
|
|
96
100
|
}
|
|
97
101
|
/**
|
|
98
102
|
* 多边形搜索
|
|
@@ -114,11 +118,13 @@ class POIService {
|
|
|
114
118
|
* ```
|
|
115
119
|
*/
|
|
116
120
|
async searchPolygon(polygon, options) {
|
|
121
|
+
const { version = 'v5', ...rest } = options || {};
|
|
117
122
|
const params = {
|
|
118
123
|
polygon,
|
|
119
|
-
...
|
|
124
|
+
...rest,
|
|
120
125
|
};
|
|
121
|
-
|
|
126
|
+
const path = `/${version}/place/polygon`;
|
|
127
|
+
return this.client.request(path, params);
|
|
122
128
|
}
|
|
123
129
|
/**
|
|
124
130
|
* POI详情查询
|
|
@@ -138,12 +144,13 @@ class POIService {
|
|
|
138
144
|
* const result = await poi.getDetail('B000A8VE1H|B0FFKEPXS2', 'business,photos');
|
|
139
145
|
* ```
|
|
140
146
|
*/
|
|
141
|
-
async getDetail(id, show_fields) {
|
|
147
|
+
async getDetail(id, show_fields, version = 'v5') {
|
|
142
148
|
const params = {
|
|
143
149
|
id,
|
|
144
150
|
show_fields,
|
|
145
151
|
};
|
|
146
|
-
|
|
152
|
+
const path = `/${version}/place/detail`;
|
|
153
|
+
return this.client.request(path, params);
|
|
147
154
|
}
|
|
148
155
|
/**
|
|
149
156
|
* 批量查询POI详情
|
|
@@ -160,7 +167,7 @@ class POIService {
|
|
|
160
167
|
* ], 'business,photos');
|
|
161
168
|
* ```
|
|
162
169
|
*/
|
|
163
|
-
async batchGetDetail(ids, show_fields) {
|
|
170
|
+
async batchGetDetail(ids, show_fields, version = 'v5') {
|
|
164
171
|
if (ids.length > 10) {
|
|
165
172
|
throw new Error('批量查询最多支持10个POI ID');
|
|
166
173
|
}
|
|
@@ -168,7 +175,8 @@ class POIService {
|
|
|
168
175
|
id: ids.join('|'),
|
|
169
176
|
show_fields,
|
|
170
177
|
};
|
|
171
|
-
|
|
178
|
+
const path = `/${version}/place/detail`;
|
|
179
|
+
return this.client.request(path, params);
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
182
|
exports.POIService = POIService;
|
|
@@ -48,21 +48,23 @@ class RouteService {
|
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
50
|
async driving(origin, destination, options) {
|
|
51
|
+
const { version = 'v5', ...rest } = options || {};
|
|
51
52
|
const params = {
|
|
52
53
|
origin: this.formatCoordinate(origin),
|
|
53
54
|
destination: this.formatCoordinate(destination),
|
|
54
|
-
...
|
|
55
|
+
...rest,
|
|
55
56
|
};
|
|
56
57
|
// 处理途经点
|
|
57
|
-
if (
|
|
58
|
-
if (Array.isArray(
|
|
59
|
-
params.waypoints =
|
|
58
|
+
if (rest?.waypoints) {
|
|
59
|
+
if (Array.isArray(rest.waypoints)) {
|
|
60
|
+
params.waypoints = rest.waypoints.map(wp => this.formatCoordinate(wp)).join(';');
|
|
60
61
|
}
|
|
61
62
|
else {
|
|
62
|
-
params.waypoints = this.formatCoordinate(
|
|
63
|
+
params.waypoints = this.formatCoordinate(rest.waypoints);
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
const path = `/${version}/direction/driving`;
|
|
67
|
+
return this.client.request(path, params);
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* 步行路径规划
|
|
@@ -83,12 +85,14 @@ class RouteService {
|
|
|
83
85
|
* ```
|
|
84
86
|
*/
|
|
85
87
|
async walking(origin, destination, options) {
|
|
88
|
+
const { version = 'v5', ...rest } = options || {};
|
|
86
89
|
const params = {
|
|
87
90
|
origin: this.formatCoordinate(origin),
|
|
88
91
|
destination: this.formatCoordinate(destination),
|
|
89
|
-
...
|
|
92
|
+
...rest,
|
|
90
93
|
};
|
|
91
|
-
|
|
94
|
+
const path = `/${version}/direction/walking`;
|
|
95
|
+
return this.client.request(path, params);
|
|
92
96
|
}
|
|
93
97
|
/**
|
|
94
98
|
* 骑行路径规划
|
|
@@ -110,12 +114,14 @@ class RouteService {
|
|
|
110
114
|
* ```
|
|
111
115
|
*/
|
|
112
116
|
async bicycling(origin, destination, options) {
|
|
117
|
+
const { version = 'v5', ...rest } = options || {};
|
|
113
118
|
const params = {
|
|
114
119
|
origin: this.formatCoordinate(origin),
|
|
115
120
|
destination: this.formatCoordinate(destination),
|
|
116
|
-
...
|
|
121
|
+
...rest,
|
|
117
122
|
};
|
|
118
|
-
|
|
123
|
+
const path = `/${version}/direction/bicycling`;
|
|
124
|
+
return this.client.request(path, params);
|
|
119
125
|
}
|
|
120
126
|
/**
|
|
121
127
|
* 电动车路径规划
|
|
@@ -133,12 +139,14 @@ class RouteService {
|
|
|
133
139
|
* ```
|
|
134
140
|
*/
|
|
135
141
|
async electricBike(origin, destination, options) {
|
|
142
|
+
const { version = 'v5', ...rest } = options || {};
|
|
136
143
|
const params = {
|
|
137
144
|
origin: this.formatCoordinate(origin),
|
|
138
145
|
destination: this.formatCoordinate(destination),
|
|
139
|
-
...
|
|
146
|
+
...rest,
|
|
140
147
|
};
|
|
141
|
-
|
|
148
|
+
const path = `/${version}/direction/electrobike`;
|
|
149
|
+
return this.client.request(path, params);
|
|
142
150
|
}
|
|
143
151
|
/**
|
|
144
152
|
* 公交路径规划(新版 V5 API)
|
|
@@ -190,14 +198,16 @@ class RouteService {
|
|
|
190
198
|
* ```
|
|
191
199
|
*/
|
|
192
200
|
async transit(origin, destination, city1, city2, options) {
|
|
201
|
+
const { version = 'v5', ...rest } = options || {};
|
|
193
202
|
const params = {
|
|
194
203
|
origin: this.formatCoordinate(origin),
|
|
195
204
|
destination: this.formatCoordinate(destination),
|
|
196
205
|
city1,
|
|
197
206
|
city2,
|
|
198
|
-
...
|
|
207
|
+
...rest,
|
|
199
208
|
};
|
|
200
|
-
|
|
209
|
+
const path = `/${version}/direction/transit/integrated`;
|
|
210
|
+
return this.client.request(path, params);
|
|
201
211
|
}
|
|
202
212
|
}
|
|
203
213
|
exports.RouteService = RouteService;
|
|
@@ -46,6 +46,11 @@ export interface POISearchParams {
|
|
|
46
46
|
* 请求第几分页
|
|
47
47
|
*/
|
|
48
48
|
page_num?: number;
|
|
49
|
+
/**
|
|
50
|
+
* API 版本
|
|
51
|
+
* @default 'v5'
|
|
52
|
+
*/
|
|
53
|
+
version?: 'v3' | 'v5';
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
56
|
* 周边搜索参数
|
|
@@ -111,6 +116,11 @@ export interface POIAroundParams {
|
|
|
111
116
|
* @default 1
|
|
112
117
|
*/
|
|
113
118
|
page_num?: number;
|
|
119
|
+
/**
|
|
120
|
+
* API 版本
|
|
121
|
+
* @default 'v5'
|
|
122
|
+
*/
|
|
123
|
+
version?: 'v3' | 'v5';
|
|
114
124
|
}
|
|
115
125
|
/**
|
|
116
126
|
* 多边形搜索参数
|
|
@@ -153,6 +163,11 @@ export interface POIPolygonParams {
|
|
|
153
163
|
* @default 1
|
|
154
164
|
*/
|
|
155
165
|
page_num?: number;
|
|
166
|
+
/**
|
|
167
|
+
* API 版本
|
|
168
|
+
* @default 'v5'
|
|
169
|
+
*/
|
|
170
|
+
version?: 'v3' | 'v5';
|
|
156
171
|
}
|
|
157
172
|
/**
|
|
158
173
|
* POI 详情
|
|
@@ -316,4 +331,9 @@ export interface POIDetailParams {
|
|
|
316
331
|
* 可选值:children, business, indoor, navi, photos
|
|
317
332
|
*/
|
|
318
333
|
show_fields?: string;
|
|
334
|
+
/**
|
|
335
|
+
* API 版本
|
|
336
|
+
* @default 'v5'
|
|
337
|
+
*/
|
|
338
|
+
version?: 'v3' | 'v5';
|
|
319
339
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-gaode-map-web-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4-next.0",
|
|
4
4
|
"description": "高德地图 Web API 服务 - 搜索、路径规划、地理编码(纯 JavaScript 实现),配合 expo-gaode-map 使用",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"build": "tsc",
|
|
13
13
|
"dev": "tsc --watch",
|
|
14
14
|
"clean": "rm -rf build",
|
|
15
|
+
"lint": "node -e \"const { spawnSync } = require('child_process'); const r = spawnSync('tsc', ['--noEmit', '--pretty', 'false'], { stdio: 'inherit' }); process.exit(r.status ?? 1);\" --",
|
|
15
16
|
"test": "bun test",
|
|
16
17
|
"prepare": "npm run build",
|
|
17
18
|
"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-web-api] 需要安装基础地图组件:expo-gaode-map 或 expo-gaode-map-navigation 中的任意一个。\\bun add expo-gaode-map 或 bun add expo-gaode-map-navigation');process.exit(1)}}\""
|