expo-gaode-map-web-api 1.0.1-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.
- package/README.md +632 -0
- package/build/index.d.ts +91 -0
- package/build/index.js +186 -0
- package/build/services/GeocodeService.d.ts +97 -0
- package/build/services/GeocodeService.js +133 -0
- package/build/services/InputTipsService.d.ts +103 -0
- package/build/services/InputTipsService.js +127 -0
- package/build/services/POIService.d.ts +133 -0
- package/build/services/POIService.js +174 -0
- package/build/services/RouteService.d.ts +149 -0
- package/build/services/RouteService.js +203 -0
- package/build/types/geocode.types.d.ts +326 -0
- package/build/types/geocode.types.js +5 -0
- package/build/types/inputtips.types.d.ts +69 -0
- package/build/types/inputtips.types.js +6 -0
- package/build/types/poi.types.d.ts +319 -0
- package/build/types/poi.types.js +7 -0
- package/build/types/route.types.d.ts +636 -0
- package/build/types/route.types.js +71 -0
- package/build/utils/client.d.ts +78 -0
- package/build/utils/client.js +144 -0
- package/build/utils/errorCodes.d.ts +35 -0
- package/build/utils/errorCodes.js +396 -0
- package/package.json +39 -0
- package/package.json.backup +40 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 高德地图 Web API HTTP 客户端
|
|
3
|
+
*/
|
|
4
|
+
import { type ErrorInfo } from './errorCodes';
|
|
5
|
+
/**
|
|
6
|
+
* 高德地图 API 错误类
|
|
7
|
+
*/
|
|
8
|
+
export declare class GaodeAPIError extends Error {
|
|
9
|
+
/** 错误码 */
|
|
10
|
+
readonly code: string;
|
|
11
|
+
/** 官方错误信息 */
|
|
12
|
+
readonly info: string;
|
|
13
|
+
/** 友好的错误描述 */
|
|
14
|
+
readonly description: string;
|
|
15
|
+
/** 问题排查建议 */
|
|
16
|
+
readonly suggestion: string;
|
|
17
|
+
/** 错误类型 */
|
|
18
|
+
readonly type: ErrorInfo['type'];
|
|
19
|
+
/** API 响应状态 */
|
|
20
|
+
readonly status: string;
|
|
21
|
+
constructor(status: string, info: string, infocode: string);
|
|
22
|
+
/**
|
|
23
|
+
* 获取完整的错误信息(用于日志记录)
|
|
24
|
+
*/
|
|
25
|
+
toJSON(): {
|
|
26
|
+
name: string;
|
|
27
|
+
code: string;
|
|
28
|
+
info: string;
|
|
29
|
+
description: string;
|
|
30
|
+
suggestion: string;
|
|
31
|
+
type: "success" | "key_error" | "param_error" | "route_error" | "service_error" | "quota_error";
|
|
32
|
+
status: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 获取用户友好的错误提示
|
|
36
|
+
*/
|
|
37
|
+
getUserMessage(): string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated 使用 GaodeAPIError 代替
|
|
41
|
+
*/
|
|
42
|
+
export interface APIError {
|
|
43
|
+
status: string;
|
|
44
|
+
info: string;
|
|
45
|
+
infocode: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* HTTP 客户端配置
|
|
49
|
+
*/
|
|
50
|
+
export interface ClientConfig {
|
|
51
|
+
/** 高德地图 Web API Key ,默认可以通过 getWebKey 获取,所以不再是必传*/
|
|
52
|
+
key?: string;
|
|
53
|
+
/** 基础 URL,默认:https://restapi.amap.com */
|
|
54
|
+
baseURL?: string;
|
|
55
|
+
/** 请求超时时间(毫秒),默认:10000 */
|
|
56
|
+
timeout?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 高德地图 Web API HTTP 客户端
|
|
60
|
+
*/
|
|
61
|
+
export declare class GaodeWebAPIClient {
|
|
62
|
+
private key;
|
|
63
|
+
private baseURL;
|
|
64
|
+
private timeout;
|
|
65
|
+
constructor(config: ClientConfig);
|
|
66
|
+
/**
|
|
67
|
+
* 发起 HTTP 请求
|
|
68
|
+
*/
|
|
69
|
+
request<T>(path: string, params?: Record<string, any>): Promise<T>;
|
|
70
|
+
/**
|
|
71
|
+
* 更新 API Key
|
|
72
|
+
*/
|
|
73
|
+
setKey(key: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* 获取当前 API Key
|
|
76
|
+
*/
|
|
77
|
+
getKey(): string;
|
|
78
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 高德地图 Web API HTTP 客户端
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GaodeWebAPIClient = exports.GaodeAPIError = void 0;
|
|
7
|
+
const errorCodes_1 = require("./errorCodes");
|
|
8
|
+
function resolveWebKey() {
|
|
9
|
+
// 1) 尝试从核心地图包读取
|
|
10
|
+
try {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
12
|
+
const core = require('expo-gaode-map');
|
|
13
|
+
const fn = core?.getWebKey;
|
|
14
|
+
if (typeof fn === 'function') {
|
|
15
|
+
return fn();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// ignore
|
|
20
|
+
}
|
|
21
|
+
// 2) 若未安装核心包,则尝试从导航包读取(导航内置地图)
|
|
22
|
+
try {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
24
|
+
const nav = require('expo-gaode-map-navigation');
|
|
25
|
+
const fn2 = nav?.getWebKey;
|
|
26
|
+
if (typeof fn2 === 'function') {
|
|
27
|
+
return fn2();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// ignore
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 高德地图 API 错误类
|
|
37
|
+
*/
|
|
38
|
+
class GaodeAPIError extends Error {
|
|
39
|
+
constructor(status, info, infocode) {
|
|
40
|
+
const errorInfo = (0, errorCodes_1.getErrorInfo)(infocode);
|
|
41
|
+
// 使用友好的错误描述作为 message
|
|
42
|
+
super(`${errorInfo.description} (${infocode})`);
|
|
43
|
+
this.name = 'GaodeAPIError';
|
|
44
|
+
this.status = status;
|
|
45
|
+
this.code = infocode;
|
|
46
|
+
this.info = info;
|
|
47
|
+
this.description = errorInfo.description;
|
|
48
|
+
this.suggestion = errorInfo.suggestion;
|
|
49
|
+
this.type = errorInfo.type;
|
|
50
|
+
// 保持正确的 prototype 链
|
|
51
|
+
Object.setPrototypeOf(this, GaodeAPIError.prototype);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 获取完整的错误信息(用于日志记录)
|
|
55
|
+
*/
|
|
56
|
+
toJSON() {
|
|
57
|
+
return {
|
|
58
|
+
name: this.name,
|
|
59
|
+
code: this.code,
|
|
60
|
+
info: this.info,
|
|
61
|
+
description: this.description,
|
|
62
|
+
suggestion: this.suggestion,
|
|
63
|
+
type: this.type,
|
|
64
|
+
status: this.status,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 获取用户友好的错误提示
|
|
69
|
+
*/
|
|
70
|
+
getUserMessage() {
|
|
71
|
+
return `${this.description}\n\n💡 ${this.suggestion}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.GaodeAPIError = GaodeAPIError;
|
|
75
|
+
/**
|
|
76
|
+
* 高德地图 Web API HTTP 客户端
|
|
77
|
+
*/
|
|
78
|
+
class GaodeWebAPIClient {
|
|
79
|
+
constructor(config) {
|
|
80
|
+
this.key = config.key || resolveWebKey() || '';
|
|
81
|
+
this.baseURL = config.baseURL || 'https://restapi.amap.com';
|
|
82
|
+
this.timeout = config.timeout || 10000;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 发起 HTTP 请求
|
|
86
|
+
*/
|
|
87
|
+
async request(path, params = {}) {
|
|
88
|
+
// 构建 URL
|
|
89
|
+
const url = new URL(path, this.baseURL);
|
|
90
|
+
// 添加 key 参数
|
|
91
|
+
url.searchParams.append('key', this.key);
|
|
92
|
+
// 添加其他参数
|
|
93
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
94
|
+
if (value !== undefined && value !== null) {
|
|
95
|
+
url.searchParams.append(key, String(value));
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
// 创建 AbortController 用于超时控制
|
|
99
|
+
const controller = new AbortController();
|
|
100
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
101
|
+
try {
|
|
102
|
+
// 发起请求
|
|
103
|
+
const response = await fetch(url.toString(), {
|
|
104
|
+
method: 'GET',
|
|
105
|
+
signal: controller.signal,
|
|
106
|
+
});
|
|
107
|
+
clearTimeout(timeoutId);
|
|
108
|
+
// 检查 HTTP 状态
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
throw new Error(`HTTP Error: ${response.status} ${response.statusText}`);
|
|
111
|
+
}
|
|
112
|
+
// 解析 JSON
|
|
113
|
+
const data = await response.json();
|
|
114
|
+
// 检查 API 状态
|
|
115
|
+
if (data.status !== '1' && !(0, errorCodes_1.isSuccess)(data.infocode)) {
|
|
116
|
+
throw new GaodeAPIError(data.status, data.info || 'Unknown error', data.infocode || '0');
|
|
117
|
+
}
|
|
118
|
+
return data;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
clearTimeout(timeoutId);
|
|
122
|
+
if (error instanceof Error) {
|
|
123
|
+
if (error.name === 'AbortError') {
|
|
124
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
125
|
+
}
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
throw new Error('Unknown error occurred');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 更新 API Key
|
|
133
|
+
*/
|
|
134
|
+
setKey(key) {
|
|
135
|
+
this.key = key;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 获取当前 API Key
|
|
139
|
+
*/
|
|
140
|
+
getKey() {
|
|
141
|
+
return this.key;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.GaodeWebAPIClient = GaodeWebAPIClient;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 高德地图 Web API 错误码定义
|
|
3
|
+
* 文档: https://lbs.amap.com/api/webservice/guide/tools/info
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 错误码类型
|
|
7
|
+
*/
|
|
8
|
+
export type InfoCode = '10000' | '10001' | '10002' | '10003' | '10004' | '10005' | '10006' | '10007' | '10008' | '10009' | '10010' | '10011' | '10012' | '10013' | '10014' | '10015' | '10016' | '10017' | '10019' | '10020' | '10021' | '10026' | '10029' | '10041' | '10044' | '10045' | '20000' | '20001' | '20002' | '20003' | '20011' | '20012' | '20800' | '20801' | '20802' | '20803' | '30001' | '30002' | '30003' | '32000' | '32001' | '32002' | '32003' | '32200' | '32201' | '32202' | '32203' | '40000' | '40001' | '40002' | '40003';
|
|
9
|
+
/**
|
|
10
|
+
* 错误信息接口
|
|
11
|
+
*/
|
|
12
|
+
export interface ErrorInfo {
|
|
13
|
+
/** 错误码 */
|
|
14
|
+
code: InfoCode;
|
|
15
|
+
/** 官方错误信息 */
|
|
16
|
+
message: string;
|
|
17
|
+
/** 友好的中文描述 */
|
|
18
|
+
description: string;
|
|
19
|
+
/** 问题排查建议 */
|
|
20
|
+
suggestion: string;
|
|
21
|
+
/** 错误类型 */
|
|
22
|
+
type: 'success' | 'key_error' | 'param_error' | 'route_error' | 'service_error' | 'quota_error';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 高德地图 Web API 错误码映射表
|
|
26
|
+
*/
|
|
27
|
+
export declare const ERROR_CODE_MAP: Record<InfoCode, ErrorInfo>;
|
|
28
|
+
/**
|
|
29
|
+
* 根据错误码获取错误信息
|
|
30
|
+
*/
|
|
31
|
+
export declare function getErrorInfo(infocode: string): ErrorInfo;
|
|
32
|
+
/**
|
|
33
|
+
* 判断是否为成功状态
|
|
34
|
+
*/
|
|
35
|
+
export declare function isSuccess(infocode: string): boolean;
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 高德地图 Web API 错误码定义
|
|
4
|
+
* 文档: https://lbs.amap.com/api/webservice/guide/tools/info
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ERROR_CODE_MAP = void 0;
|
|
8
|
+
exports.getErrorInfo = getErrorInfo;
|
|
9
|
+
exports.isSuccess = isSuccess;
|
|
10
|
+
/**
|
|
11
|
+
* 高德地图 Web API 错误码映射表
|
|
12
|
+
*/
|
|
13
|
+
exports.ERROR_CODE_MAP = {
|
|
14
|
+
// 成功
|
|
15
|
+
'10000': {
|
|
16
|
+
code: '10000',
|
|
17
|
+
message: 'OK',
|
|
18
|
+
description: '请求正常',
|
|
19
|
+
suggestion: '请求成功',
|
|
20
|
+
type: 'success',
|
|
21
|
+
},
|
|
22
|
+
// Key相关错误
|
|
23
|
+
'10001': {
|
|
24
|
+
code: '10001',
|
|
25
|
+
message: 'INVALID_USER_KEY',
|
|
26
|
+
description: 'Key不正确或过期',
|
|
27
|
+
suggestion: '请检查您的 API Key 是否正确,或前往控制台查看 Key 是否已过期',
|
|
28
|
+
type: 'key_error',
|
|
29
|
+
},
|
|
30
|
+
'10002': {
|
|
31
|
+
code: '10002',
|
|
32
|
+
message: 'SERVICE_NOT_AVAILABLE',
|
|
33
|
+
description: '没有权限使用相应的服务或请求接口路径拼写错误',
|
|
34
|
+
suggestion: '1. 检查 Key 是否有权限使用该服务\n2. 检查请求接口路径是否正确',
|
|
35
|
+
type: 'key_error',
|
|
36
|
+
},
|
|
37
|
+
'10003': {
|
|
38
|
+
code: '10003',
|
|
39
|
+
message: 'DAILY_QUERY_OVER_LIMIT',
|
|
40
|
+
description: '访问已超出日访问量',
|
|
41
|
+
suggestion: '日访问量已超限,系统已自动封停,第二天 0:00 会自动解封',
|
|
42
|
+
type: 'key_error',
|
|
43
|
+
},
|
|
44
|
+
'10004': {
|
|
45
|
+
code: '10004',
|
|
46
|
+
message: 'ACCESS_TOO_FREQUENT',
|
|
47
|
+
description: '单位时间内访问过于频繁',
|
|
48
|
+
suggestion: '单位时间内(1分钟)访问量超限,请降低请求频率,下一分钟自动解封',
|
|
49
|
+
type: 'key_error',
|
|
50
|
+
},
|
|
51
|
+
'10005': {
|
|
52
|
+
code: '10005',
|
|
53
|
+
message: 'INVALID_USER_IP',
|
|
54
|
+
description: 'IP白名单出错,发送请求的服务器IP不在白名单内',
|
|
55
|
+
suggestion: '请在控制台检查并设置正确的 IP 白名单',
|
|
56
|
+
type: 'key_error',
|
|
57
|
+
},
|
|
58
|
+
'10006': {
|
|
59
|
+
code: '10006',
|
|
60
|
+
message: 'INVALID_USER_DOMAIN',
|
|
61
|
+
description: '绑定域名无效',
|
|
62
|
+
suggestion: '请在控制台重新设置绑定域名',
|
|
63
|
+
type: 'key_error',
|
|
64
|
+
},
|
|
65
|
+
'10007': {
|
|
66
|
+
code: '10007',
|
|
67
|
+
message: 'INVALID_USER_SIGNATURE',
|
|
68
|
+
description: '数字签名未通过验证',
|
|
69
|
+
suggestion: '请检查数字签名生成算法是否正确',
|
|
70
|
+
type: 'key_error',
|
|
71
|
+
},
|
|
72
|
+
'10008': {
|
|
73
|
+
code: '10008',
|
|
74
|
+
message: 'INVALID_USER_SCODE',
|
|
75
|
+
description: 'MD5安全码未通过验证',
|
|
76
|
+
suggestion: '请检查 Key 绑定的 SHA1 和 package 是否与 SDK 包一致',
|
|
77
|
+
type: 'key_error',
|
|
78
|
+
},
|
|
79
|
+
'10009': {
|
|
80
|
+
code: '10009',
|
|
81
|
+
message: 'USERKEY_PLAT_NOMATCH',
|
|
82
|
+
description: '请求Key与绑定平台不符',
|
|
83
|
+
suggestion: '请使用对应平台的 Key(如:Web 服务 Key、JS API Key 等)',
|
|
84
|
+
type: 'key_error',
|
|
85
|
+
},
|
|
86
|
+
'10010': {
|
|
87
|
+
code: '10010',
|
|
88
|
+
message: 'IP_QUERY_OVER_LIMIT',
|
|
89
|
+
description: 'IP访问超限',
|
|
90
|
+
suggestion: '单个 IP 访问次数超限已被封停,请提交工单联系客服',
|
|
91
|
+
type: 'key_error',
|
|
92
|
+
},
|
|
93
|
+
'10011': {
|
|
94
|
+
code: '10011',
|
|
95
|
+
message: 'NOT_SUPPORT_HTTPS',
|
|
96
|
+
description: '服务不支持HTTPS请求',
|
|
97
|
+
suggestion: '该服务暂不支持 HTTPS,请使用 HTTP 或提交工单申请支持',
|
|
98
|
+
type: 'key_error',
|
|
99
|
+
},
|
|
100
|
+
'10012': {
|
|
101
|
+
code: '10012',
|
|
102
|
+
message: 'INSUFFICIENT_PRIVILEGES',
|
|
103
|
+
description: '权限不足,服务请求被拒绝',
|
|
104
|
+
suggestion: '您的 Key 没有权限访问该服务,请在控制台开通相应服务',
|
|
105
|
+
type: 'key_error',
|
|
106
|
+
},
|
|
107
|
+
'10013': {
|
|
108
|
+
code: '10013',
|
|
109
|
+
message: 'USER_KEY_RECYCLED',
|
|
110
|
+
description: 'Key被删除',
|
|
111
|
+
suggestion: 'Key 已被删除无法使用,请使用有效的 Key',
|
|
112
|
+
type: 'key_error',
|
|
113
|
+
},
|
|
114
|
+
'10014': {
|
|
115
|
+
code: '10014',
|
|
116
|
+
message: 'QPS_HAS_EXCEEDED_THE_LIMIT',
|
|
117
|
+
description: '云图服务QPS超限',
|
|
118
|
+
suggestion: 'QPS 超出限制,请降低请求频率或在控制台提工单',
|
|
119
|
+
type: 'key_error',
|
|
120
|
+
},
|
|
121
|
+
'10015': {
|
|
122
|
+
code: '10015',
|
|
123
|
+
message: 'GATEWAY_TIMEOUT',
|
|
124
|
+
description: '受单机QPS限流限制',
|
|
125
|
+
suggestion: '建议降低请求的 QPS 或提工单联系客服',
|
|
126
|
+
type: 'key_error',
|
|
127
|
+
},
|
|
128
|
+
'10016': {
|
|
129
|
+
code: '10016',
|
|
130
|
+
message: 'SERVER_IS_BUSY',
|
|
131
|
+
description: '服务器负载过高',
|
|
132
|
+
suggestion: '服务器繁忙,请稍后重试',
|
|
133
|
+
type: 'key_error',
|
|
134
|
+
},
|
|
135
|
+
'10017': {
|
|
136
|
+
code: '10017',
|
|
137
|
+
message: 'RESOURCE_UNAVAILABLE',
|
|
138
|
+
description: '所请求的资源不可用',
|
|
139
|
+
suggestion: '请求的资源暂时不可用,请稍后重试',
|
|
140
|
+
type: 'key_error',
|
|
141
|
+
},
|
|
142
|
+
'10019': {
|
|
143
|
+
code: '10019',
|
|
144
|
+
message: 'CQPS_HAS_EXCEEDED_THE_LIMIT',
|
|
145
|
+
description: '使用的某个服务总QPS超限',
|
|
146
|
+
suggestion: 'QPS 超出限制,请降低请求频率',
|
|
147
|
+
type: 'key_error',
|
|
148
|
+
},
|
|
149
|
+
'10020': {
|
|
150
|
+
code: '10020',
|
|
151
|
+
message: 'CKQPS_HAS_EXCEEDED_THE_LIMIT',
|
|
152
|
+
description: '某个Key使用某个服务接口QPS超出限制',
|
|
153
|
+
suggestion: 'QPS 超出限制,请降低该 Key 的请求频率',
|
|
154
|
+
type: 'key_error',
|
|
155
|
+
},
|
|
156
|
+
'10021': {
|
|
157
|
+
code: '10021',
|
|
158
|
+
message: 'CUQPS_HAS_EXCEEDED_THE_LIMIT',
|
|
159
|
+
description: '账号使用某个服务接口QPS超出限制',
|
|
160
|
+
suggestion: 'QPS 超出限制,请降低账号的请求频率',
|
|
161
|
+
type: 'key_error',
|
|
162
|
+
},
|
|
163
|
+
'10026': {
|
|
164
|
+
code: '10026',
|
|
165
|
+
message: 'INVALID_REQUEST',
|
|
166
|
+
description: '账号处于被封禁状态',
|
|
167
|
+
suggestion: '账号因违规被封禁,如有异议请登录控制台提交申诉工单',
|
|
168
|
+
type: 'key_error',
|
|
169
|
+
},
|
|
170
|
+
'10029': {
|
|
171
|
+
code: '10029',
|
|
172
|
+
message: 'ABROAD_DAILY_QUERY_OVER_LIMIT',
|
|
173
|
+
description: '某个Key的海外服务日调用量超出限制',
|
|
174
|
+
suggestion: '海外服务日调用量已超限,请等待次日解封',
|
|
175
|
+
type: 'key_error',
|
|
176
|
+
},
|
|
177
|
+
'10041': {
|
|
178
|
+
code: '10041',
|
|
179
|
+
message: 'NO_EFFECTIVE_INTERFACE',
|
|
180
|
+
description: '请求的接口权限过期',
|
|
181
|
+
suggestion: '接口权限已过期,请提交工单联系客服',
|
|
182
|
+
type: 'key_error',
|
|
183
|
+
},
|
|
184
|
+
'10044': {
|
|
185
|
+
code: '10044',
|
|
186
|
+
message: 'USER_DAILY_QUERY_OVER_LIMIT',
|
|
187
|
+
description: '账号维度日调用量超出限制',
|
|
188
|
+
suggestion: '账号日调用量已超限,请等待次日解封',
|
|
189
|
+
type: 'key_error',
|
|
190
|
+
},
|
|
191
|
+
'10045': {
|
|
192
|
+
code: '10045',
|
|
193
|
+
message: 'USER_ABROAD_DAILY_QUERY_OVER_LIMIT',
|
|
194
|
+
description: '账号维度海外服务日调用量超出限制',
|
|
195
|
+
suggestion: '账号海外服务日调用量已超限,请等待次日解封',
|
|
196
|
+
type: 'key_error',
|
|
197
|
+
},
|
|
198
|
+
// 请求参数错误
|
|
199
|
+
'20000': {
|
|
200
|
+
code: '20000',
|
|
201
|
+
message: 'INVALID_PARAMS',
|
|
202
|
+
description: '请求参数非法',
|
|
203
|
+
suggestion: '请检查请求参数的值是否符合规范要求',
|
|
204
|
+
type: 'param_error',
|
|
205
|
+
},
|
|
206
|
+
'20001': {
|
|
207
|
+
code: '20001',
|
|
208
|
+
message: 'MISSING_REQUIRED_PARAMS',
|
|
209
|
+
description: '缺少必填参数',
|
|
210
|
+
suggestion: '请检查并补充接口要求的必填参数',
|
|
211
|
+
type: 'param_error',
|
|
212
|
+
},
|
|
213
|
+
'20002': {
|
|
214
|
+
code: '20002',
|
|
215
|
+
message: 'ILLEGAL_REQUEST',
|
|
216
|
+
description: '请求协议非法',
|
|
217
|
+
suggestion: '请检查请求方法是否正确(GET/POST)',
|
|
218
|
+
type: 'param_error',
|
|
219
|
+
},
|
|
220
|
+
'20003': {
|
|
221
|
+
code: '20003',
|
|
222
|
+
message: 'UNKNOWN_ERROR',
|
|
223
|
+
description: '其他未知错误',
|
|
224
|
+
suggestion: '发生未知错误,请提交工单联系客服',
|
|
225
|
+
type: 'param_error',
|
|
226
|
+
},
|
|
227
|
+
'20011': {
|
|
228
|
+
code: '20011',
|
|
229
|
+
message: 'INSUFFICIENT_ABROAD_PRIVILEGES',
|
|
230
|
+
description: '查询坐标在海外,但没有海外地图权限',
|
|
231
|
+
suggestion: '请在控制台开通海外地图服务权限',
|
|
232
|
+
type: 'param_error',
|
|
233
|
+
},
|
|
234
|
+
'20012': {
|
|
235
|
+
code: '20012',
|
|
236
|
+
message: 'ILLEGAL_CONTENT',
|
|
237
|
+
description: '查询信息存在非法内容',
|
|
238
|
+
suggestion: '请检查查询内容是否合法',
|
|
239
|
+
type: 'param_error',
|
|
240
|
+
},
|
|
241
|
+
// 路径规划错误
|
|
242
|
+
'20800': {
|
|
243
|
+
code: '20800',
|
|
244
|
+
message: 'OUT_OF_SERVICE',
|
|
245
|
+
description: '规划点不在中国陆地范围内',
|
|
246
|
+
suggestion: '起点、终点或途经点不在中国大陆范围内,请检查坐标',
|
|
247
|
+
type: 'route_error',
|
|
248
|
+
},
|
|
249
|
+
'20801': {
|
|
250
|
+
code: '20801',
|
|
251
|
+
message: 'NO_ROADS_NEARBY',
|
|
252
|
+
description: '规划点附近搜不到路',
|
|
253
|
+
suggestion: '起点、终点或途经点附近没有道路,请调整坐标位置',
|
|
254
|
+
type: 'route_error',
|
|
255
|
+
},
|
|
256
|
+
'20802': {
|
|
257
|
+
code: '20802',
|
|
258
|
+
message: 'ROUTE_FAIL',
|
|
259
|
+
description: '路线计算失败',
|
|
260
|
+
suggestion: '路线计算失败,通常是由于道路连通关系导致,请尝试调整起终点',
|
|
261
|
+
type: 'route_error',
|
|
262
|
+
},
|
|
263
|
+
'20803': {
|
|
264
|
+
code: '20803',
|
|
265
|
+
message: 'OVER_DIRECTION_RANGE',
|
|
266
|
+
description: '起点终点距离过长',
|
|
267
|
+
suggestion: '起点和终点距离过长,请缩短距离或添加途经点',
|
|
268
|
+
type: 'route_error',
|
|
269
|
+
},
|
|
270
|
+
// 服务响应错误
|
|
271
|
+
'30001': {
|
|
272
|
+
code: '30001',
|
|
273
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
274
|
+
description: '服务响应失败',
|
|
275
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
276
|
+
type: 'service_error',
|
|
277
|
+
},
|
|
278
|
+
'30002': {
|
|
279
|
+
code: '30002',
|
|
280
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
281
|
+
description: '服务响应失败',
|
|
282
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
283
|
+
type: 'service_error',
|
|
284
|
+
},
|
|
285
|
+
'30003': {
|
|
286
|
+
code: '30003',
|
|
287
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
288
|
+
description: '服务响应失败',
|
|
289
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
290
|
+
type: 'service_error',
|
|
291
|
+
},
|
|
292
|
+
'32000': {
|
|
293
|
+
code: '32000',
|
|
294
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
295
|
+
description: '服务响应失败',
|
|
296
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
297
|
+
type: 'service_error',
|
|
298
|
+
},
|
|
299
|
+
'32001': {
|
|
300
|
+
code: '32001',
|
|
301
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
302
|
+
description: '服务响应失败',
|
|
303
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
304
|
+
type: 'service_error',
|
|
305
|
+
},
|
|
306
|
+
'32002': {
|
|
307
|
+
code: '32002',
|
|
308
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
309
|
+
description: '服务响应失败',
|
|
310
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
311
|
+
type: 'service_error',
|
|
312
|
+
},
|
|
313
|
+
'32003': {
|
|
314
|
+
code: '32003',
|
|
315
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
316
|
+
description: '服务响应失败',
|
|
317
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
318
|
+
type: 'service_error',
|
|
319
|
+
},
|
|
320
|
+
'32200': {
|
|
321
|
+
code: '32200',
|
|
322
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
323
|
+
description: '服务响应失败',
|
|
324
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
325
|
+
type: 'service_error',
|
|
326
|
+
},
|
|
327
|
+
'32201': {
|
|
328
|
+
code: '32201',
|
|
329
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
330
|
+
description: '服务响应失败',
|
|
331
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
332
|
+
type: 'service_error',
|
|
333
|
+
},
|
|
334
|
+
'32202': {
|
|
335
|
+
code: '32202',
|
|
336
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
337
|
+
description: '服务响应失败',
|
|
338
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
339
|
+
type: 'service_error',
|
|
340
|
+
},
|
|
341
|
+
'32203': {
|
|
342
|
+
code: '32203',
|
|
343
|
+
message: 'ENGINE_RESPONSE_DATA_ERROR',
|
|
344
|
+
description: '服务响应失败',
|
|
345
|
+
suggestion: '请检查传入参数是否正确,如无法解决请提交工单',
|
|
346
|
+
type: 'service_error',
|
|
347
|
+
},
|
|
348
|
+
// 配额相关错误
|
|
349
|
+
'40000': {
|
|
350
|
+
code: '40000',
|
|
351
|
+
message: 'QUOTA_PLAN_RUN_OUT',
|
|
352
|
+
description: '余额耗尽',
|
|
353
|
+
suggestion: '服务余额已耗尽,请前往控制台充值',
|
|
354
|
+
type: 'quota_error',
|
|
355
|
+
},
|
|
356
|
+
'40001': {
|
|
357
|
+
code: '40001',
|
|
358
|
+
message: 'GEOFENCE_MAX_COUNT_REACHED',
|
|
359
|
+
description: '围栏个数达到上限',
|
|
360
|
+
suggestion: 'Key 可创建的地理围栏数量已达上限',
|
|
361
|
+
type: 'quota_error',
|
|
362
|
+
},
|
|
363
|
+
'40002': {
|
|
364
|
+
code: '40002',
|
|
365
|
+
message: 'SERVICE_EXPIRED',
|
|
366
|
+
description: '购买服务到期',
|
|
367
|
+
suggestion: '服务已到期,请前往控制台续费',
|
|
368
|
+
type: 'quota_error',
|
|
369
|
+
},
|
|
370
|
+
'40003': {
|
|
371
|
+
code: '40003',
|
|
372
|
+
message: 'ABROAD_QUOTA_PLAN_RUN_OUT',
|
|
373
|
+
description: '海外服务余额耗尽',
|
|
374
|
+
suggestion: '海外服务余额已耗尽,请前往控制台充值',
|
|
375
|
+
type: 'quota_error',
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
/**
|
|
379
|
+
* 根据错误码获取错误信息
|
|
380
|
+
*/
|
|
381
|
+
function getErrorInfo(infocode) {
|
|
382
|
+
const code = infocode;
|
|
383
|
+
return exports.ERROR_CODE_MAP[code] || {
|
|
384
|
+
code: code,
|
|
385
|
+
message: 'UNKNOWN_ERROR',
|
|
386
|
+
description: '未知错误',
|
|
387
|
+
suggestion: `未知错误码: ${infocode},请联系技术支持`,
|
|
388
|
+
type: 'service_error',
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* 判断是否为成功状态
|
|
393
|
+
*/
|
|
394
|
+
function isSuccess(infocode) {
|
|
395
|
+
return infocode === '10000';
|
|
396
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-gaode-map-web-api",
|
|
3
|
+
"version": "1.0.1-next.0",
|
|
4
|
+
"description": "高德地图 Web API 服务 - 搜索、路径规划、地理编码(纯 JavaScript 实现),配合 expo-gaode-map 使用",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"react-native",
|
|
9
|
+
"expo",
|
|
10
|
+
"amap",
|
|
11
|
+
"gaode",
|
|
12
|
+
"web-api",
|
|
13
|
+
"search",
|
|
14
|
+
"geocode",
|
|
15
|
+
"route",
|
|
16
|
+
"高德地图"
|
|
17
|
+
],
|
|
18
|
+
"repository": "https://github.com/TomWq/expo-gaode-map",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/TomWq/expo-gaode-map/issues"
|
|
21
|
+
},
|
|
22
|
+
"author": "尚博信_王强 <wangqiang03@sunboxsoft.com> (https://github.com/TomWq)",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"homepage": "https://github.com/TomWq/expo-gaode-map#readme",
|
|
25
|
+
"dependencies": {},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/react": "~19.1.0",
|
|
28
|
+
"typescript": "^5.9.3"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react-native": "*"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"dev": "tsc --watch",
|
|
36
|
+
"clean": "rm -rf build",
|
|
37
|
+
"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 中的任意一个。\\n请执行:pnpm add expo-gaode-map 或 pnpm add expo-gaode-map-navigation');process.exit(1)}}\""
|
|
38
|
+
}
|
|
39
|
+
}
|