capacitor-baidu-location 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/CapacitorBaiduLocation.podspec +23 -0
- package/Package.swift +44 -0
- package/README.md +376 -0
- package/android/build.gradle +71 -0
- package/android/src/main/AndroidManifest.xml +32 -0
- package/android/src/main/kotlin/com/hybrid/baidu/location/CPBaiduLocation.kt +246 -0
- package/android/src/main/kotlin/com/hybrid/baidu/location/CPBaiduLocationConfig.kt +22 -0
- package/android/src/main/kotlin/com/hybrid/baidu/location/CPBaiduLocationPlugin.kt +225 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +294 -0
- package/dist/esm/definitions.d.ts +163 -0
- package/dist/esm/definitions.js +24 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +69 -0
- package/dist/esm/web.js +133 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +170 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +173 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/CPBaiduLocationPlugin/CPBaiduLocation.swift +646 -0
- package/ios/Sources/CPBaiduLocationPlugin/CPBaiduLocationConfig.swift +38 -0
- package/ios/Sources/CPBaiduLocationPlugin/CPBaiduLocationPlugin.swift +167 -0
- package/package.json +82 -0
package/dist/docs.json
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "CPBaiduLocationPlugin",
|
|
4
|
+
"slug": "cpbaidulocationplugin",
|
|
5
|
+
"docs": "百度地图定位插件接口",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "getCurrentPosition",
|
|
10
|
+
"signature": "(options?: PositionOptions | undefined) => Promise<PositionResult>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "PositionOptions | undefined"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<PositionResult>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "获取当前位置信息",
|
|
21
|
+
"complexTypes": [
|
|
22
|
+
"PositionResult",
|
|
23
|
+
"PositionOptions"
|
|
24
|
+
],
|
|
25
|
+
"slug": "getcurrentposition"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "checkPermission",
|
|
29
|
+
"signature": "() => Promise<{ granted: boolean; }>",
|
|
30
|
+
"parameters": [],
|
|
31
|
+
"returns": "Promise<{ granted: boolean; }>",
|
|
32
|
+
"tags": [],
|
|
33
|
+
"docs": "检查定位权限",
|
|
34
|
+
"complexTypes": [],
|
|
35
|
+
"slug": "checkpermission"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "requestPermission",
|
|
39
|
+
"signature": "() => Promise<{ granted: boolean; }>",
|
|
40
|
+
"parameters": [],
|
|
41
|
+
"returns": "Promise<{ granted: boolean; }>",
|
|
42
|
+
"tags": [],
|
|
43
|
+
"docs": "请求定位权限",
|
|
44
|
+
"complexTypes": [],
|
|
45
|
+
"slug": "requestpermission"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "setAK",
|
|
49
|
+
"signature": "(options?: { ak: string; } | undefined) => Promise<{ success: boolean; errorMessage?: string; }>",
|
|
50
|
+
"parameters": [
|
|
51
|
+
{
|
|
52
|
+
"name": "options",
|
|
53
|
+
"docs": "",
|
|
54
|
+
"type": "{ ak: string; } | undefined"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"returns": "Promise<{ success: boolean; errorMessage?: string | undefined; }>",
|
|
58
|
+
"tags": [],
|
|
59
|
+
"docs": "设置百度地图AK",
|
|
60
|
+
"complexTypes": [],
|
|
61
|
+
"slug": "setak"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "checkAKValidation",
|
|
65
|
+
"signature": "() => Promise<{ valid: boolean; errorMessage?: string; }>",
|
|
66
|
+
"parameters": [],
|
|
67
|
+
"returns": "Promise<{ valid: boolean; errorMessage?: string | undefined; }>",
|
|
68
|
+
"tags": [],
|
|
69
|
+
"docs": "检查AK验证状态",
|
|
70
|
+
"complexTypes": [],
|
|
71
|
+
"slug": "checkakvalidation"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "setCoordinateType",
|
|
75
|
+
"signature": "(options: { type: CoordinateType; }) => Promise<{ success: boolean; }>",
|
|
76
|
+
"parameters": [
|
|
77
|
+
{
|
|
78
|
+
"name": "options",
|
|
79
|
+
"docs": "",
|
|
80
|
+
"type": "{ type: CoordinateType; }"
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"returns": "Promise<{ success: boolean; }>",
|
|
84
|
+
"tags": [],
|
|
85
|
+
"docs": "设置坐标类型",
|
|
86
|
+
"complexTypes": [
|
|
87
|
+
"CoordinateType"
|
|
88
|
+
],
|
|
89
|
+
"slug": "setcoordinatetype"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "getCoordinateType",
|
|
93
|
+
"signature": "() => Promise<{ type: CoordinateType; }>",
|
|
94
|
+
"parameters": [],
|
|
95
|
+
"returns": "Promise<{ type: CoordinateType; }>",
|
|
96
|
+
"tags": [],
|
|
97
|
+
"docs": "获取当前坐标类型",
|
|
98
|
+
"complexTypes": [
|
|
99
|
+
"CoordinateType"
|
|
100
|
+
],
|
|
101
|
+
"slug": "getcoordinatetype"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"properties": []
|
|
105
|
+
},
|
|
106
|
+
"interfaces": [
|
|
107
|
+
{
|
|
108
|
+
"name": "PositionResult",
|
|
109
|
+
"slug": "positionresult",
|
|
110
|
+
"docs": "定位结果",
|
|
111
|
+
"tags": [],
|
|
112
|
+
"methods": [],
|
|
113
|
+
"properties": [
|
|
114
|
+
{
|
|
115
|
+
"name": "latitude",
|
|
116
|
+
"tags": [],
|
|
117
|
+
"docs": "纬度",
|
|
118
|
+
"complexTypes": [],
|
|
119
|
+
"type": "number"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "longitude",
|
|
123
|
+
"tags": [],
|
|
124
|
+
"docs": "经度",
|
|
125
|
+
"complexTypes": [],
|
|
126
|
+
"type": "number"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "accuracy",
|
|
130
|
+
"tags": [],
|
|
131
|
+
"docs": "定位精度(米)",
|
|
132
|
+
"complexTypes": [],
|
|
133
|
+
"type": "number | undefined"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "address",
|
|
137
|
+
"tags": [],
|
|
138
|
+
"docs": "完整地址",
|
|
139
|
+
"complexTypes": [],
|
|
140
|
+
"type": "string | undefined"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "country",
|
|
144
|
+
"tags": [],
|
|
145
|
+
"docs": "国家",
|
|
146
|
+
"complexTypes": [],
|
|
147
|
+
"type": "string | undefined"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "province",
|
|
151
|
+
"tags": [],
|
|
152
|
+
"docs": "省份",
|
|
153
|
+
"complexTypes": [],
|
|
154
|
+
"type": "string | undefined"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "city",
|
|
158
|
+
"tags": [],
|
|
159
|
+
"docs": "城市",
|
|
160
|
+
"complexTypes": [],
|
|
161
|
+
"type": "string | undefined"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "district",
|
|
165
|
+
"tags": [],
|
|
166
|
+
"docs": "区县",
|
|
167
|
+
"complexTypes": [],
|
|
168
|
+
"type": "string | undefined"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "street",
|
|
172
|
+
"tags": [],
|
|
173
|
+
"docs": "街道",
|
|
174
|
+
"complexTypes": [],
|
|
175
|
+
"type": "string | undefined"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "adcode",
|
|
179
|
+
"tags": [],
|
|
180
|
+
"docs": "行政区划代码",
|
|
181
|
+
"complexTypes": [],
|
|
182
|
+
"type": "string | undefined"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "town",
|
|
186
|
+
"tags": [],
|
|
187
|
+
"docs": "乡镇",
|
|
188
|
+
"complexTypes": [],
|
|
189
|
+
"type": "string | undefined"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "locationDescribe",
|
|
193
|
+
"tags": [],
|
|
194
|
+
"docs": "位置描述",
|
|
195
|
+
"complexTypes": [],
|
|
196
|
+
"type": "string | undefined"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "errorCode",
|
|
200
|
+
"tags": [],
|
|
201
|
+
"docs": "错误码",
|
|
202
|
+
"complexTypes": [],
|
|
203
|
+
"type": "number | undefined"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"name": "errorMessage",
|
|
207
|
+
"tags": [],
|
|
208
|
+
"docs": "错误信息",
|
|
209
|
+
"complexTypes": [],
|
|
210
|
+
"type": "string | undefined"
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"name": "PositionOptions",
|
|
216
|
+
"slug": "positionoptions",
|
|
217
|
+
"docs": "定位参数选项",
|
|
218
|
+
"tags": [],
|
|
219
|
+
"methods": [],
|
|
220
|
+
"properties": [
|
|
221
|
+
{
|
|
222
|
+
"name": "needAddress",
|
|
223
|
+
"tags": [],
|
|
224
|
+
"docs": "是否需要地址信息",
|
|
225
|
+
"complexTypes": [],
|
|
226
|
+
"type": "boolean | undefined"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"name": "needLocationDescribe",
|
|
230
|
+
"tags": [],
|
|
231
|
+
"docs": "是否需要位置描述",
|
|
232
|
+
"complexTypes": [],
|
|
233
|
+
"type": "boolean | undefined"
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
"enums": [
|
|
239
|
+
{
|
|
240
|
+
"name": "CoordinateType",
|
|
241
|
+
"slug": "coordinatetype",
|
|
242
|
+
"members": [
|
|
243
|
+
{
|
|
244
|
+
"name": "BD09LL",
|
|
245
|
+
"value": "'BD09LL'",
|
|
246
|
+
"tags": [],
|
|
247
|
+
"docs": "百度经纬度坐标"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"name": "BD09MC",
|
|
251
|
+
"value": "'BD09MC'",
|
|
252
|
+
"tags": [],
|
|
253
|
+
"docs": "百度墨卡托米制坐标"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"name": "GCJ02",
|
|
257
|
+
"value": "'GCJ02'",
|
|
258
|
+
"tags": [],
|
|
259
|
+
"docs": "国测局坐标"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"name": "WGS84",
|
|
263
|
+
"value": "'WGS84'",
|
|
264
|
+
"tags": [],
|
|
265
|
+
"docs": "WGS84坐标"
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
"typeAliases": [],
|
|
271
|
+
"pluginConfigs": [
|
|
272
|
+
{
|
|
273
|
+
"name": "CPBaiduLocation",
|
|
274
|
+
"slug": "cpbaidulocation",
|
|
275
|
+
"properties": [
|
|
276
|
+
{
|
|
277
|
+
"name": "androidAK",
|
|
278
|
+
"tags": [],
|
|
279
|
+
"docs": "Android平台百度地图API Key",
|
|
280
|
+
"complexTypes": [],
|
|
281
|
+
"type": "string | undefined"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"name": "iOSAK",
|
|
285
|
+
"tags": [],
|
|
286
|
+
"docs": "iOS平台百度地图API Key",
|
|
287
|
+
"complexTypes": [],
|
|
288
|
+
"type": "string | undefined"
|
|
289
|
+
}
|
|
290
|
+
],
|
|
291
|
+
"docs": "百度地图定位插件配置"
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
declare module '@capacitor/cli' {
|
|
2
|
+
interface PluginsConfig {
|
|
3
|
+
/**
|
|
4
|
+
* 百度地图定位插件配置
|
|
5
|
+
*/
|
|
6
|
+
CPBaiduLocation?: {
|
|
7
|
+
/**
|
|
8
|
+
* Android平台百度地图API Key
|
|
9
|
+
*/
|
|
10
|
+
androidAK?: string;
|
|
11
|
+
/**
|
|
12
|
+
* iOS平台百度地图API Key
|
|
13
|
+
*/
|
|
14
|
+
iOSAK?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 定位参数选项
|
|
20
|
+
*/
|
|
21
|
+
export interface PositionOptions {
|
|
22
|
+
/**
|
|
23
|
+
* 是否需要地址信息
|
|
24
|
+
*/
|
|
25
|
+
needAddress?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 是否需要位置描述
|
|
28
|
+
*/
|
|
29
|
+
needLocationDescribe?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 定位结果
|
|
33
|
+
*/
|
|
34
|
+
export interface PositionResult {
|
|
35
|
+
/**
|
|
36
|
+
* 纬度
|
|
37
|
+
*/
|
|
38
|
+
latitude: number;
|
|
39
|
+
/**
|
|
40
|
+
* 经度
|
|
41
|
+
*/
|
|
42
|
+
longitude: number;
|
|
43
|
+
/**
|
|
44
|
+
* 定位精度(米)
|
|
45
|
+
*/
|
|
46
|
+
accuracy?: number;
|
|
47
|
+
/**
|
|
48
|
+
* 完整地址
|
|
49
|
+
*/
|
|
50
|
+
address?: string;
|
|
51
|
+
/**
|
|
52
|
+
* 国家
|
|
53
|
+
*/
|
|
54
|
+
country?: string;
|
|
55
|
+
/**
|
|
56
|
+
* 省份
|
|
57
|
+
*/
|
|
58
|
+
province?: string;
|
|
59
|
+
/**
|
|
60
|
+
* 城市
|
|
61
|
+
*/
|
|
62
|
+
city?: string;
|
|
63
|
+
/**
|
|
64
|
+
* 区县
|
|
65
|
+
*/
|
|
66
|
+
district?: string;
|
|
67
|
+
/**
|
|
68
|
+
* 街道
|
|
69
|
+
*/
|
|
70
|
+
street?: string;
|
|
71
|
+
/**
|
|
72
|
+
* 行政区划代码
|
|
73
|
+
*/
|
|
74
|
+
adcode?: string;
|
|
75
|
+
/**
|
|
76
|
+
* 乡镇
|
|
77
|
+
*/
|
|
78
|
+
town?: string;
|
|
79
|
+
/**
|
|
80
|
+
* 位置描述
|
|
81
|
+
*/
|
|
82
|
+
locationDescribe?: string;
|
|
83
|
+
/**
|
|
84
|
+
* 错误码
|
|
85
|
+
*/
|
|
86
|
+
errorCode?: number;
|
|
87
|
+
/**
|
|
88
|
+
* 错误信息
|
|
89
|
+
*/
|
|
90
|
+
errorMessage?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 坐标类型枚举
|
|
94
|
+
*/
|
|
95
|
+
export declare enum CoordinateType {
|
|
96
|
+
/**
|
|
97
|
+
* 百度经纬度坐标
|
|
98
|
+
*/
|
|
99
|
+
BD09LL = "BD09LL",
|
|
100
|
+
/**
|
|
101
|
+
* 百度墨卡托米制坐标
|
|
102
|
+
*/
|
|
103
|
+
BD09MC = "BD09MC",
|
|
104
|
+
/**
|
|
105
|
+
* 国测局坐标
|
|
106
|
+
*/
|
|
107
|
+
GCJ02 = "GCJ02",
|
|
108
|
+
/**
|
|
109
|
+
* WGS84坐标
|
|
110
|
+
*/
|
|
111
|
+
WGS84 = "WGS84"
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 百度地图定位插件接口
|
|
115
|
+
*/
|
|
116
|
+
export interface CPBaiduLocationPlugin {
|
|
117
|
+
/**
|
|
118
|
+
* 获取当前位置信息
|
|
119
|
+
*/
|
|
120
|
+
getCurrentPosition(options?: PositionOptions): Promise<PositionResult>;
|
|
121
|
+
/**
|
|
122
|
+
* 检查定位权限
|
|
123
|
+
*/
|
|
124
|
+
checkPermission(): Promise<{
|
|
125
|
+
granted: boolean;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* 请求定位权限
|
|
129
|
+
*/
|
|
130
|
+
requestPermission(): Promise<{
|
|
131
|
+
granted: boolean;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* 设置百度地图AK
|
|
135
|
+
*/
|
|
136
|
+
setAK(options?: {
|
|
137
|
+
ak: string;
|
|
138
|
+
}): Promise<{
|
|
139
|
+
success: boolean;
|
|
140
|
+
errorMessage?: string;
|
|
141
|
+
}>;
|
|
142
|
+
/**
|
|
143
|
+
* 检查AK验证状态
|
|
144
|
+
*/
|
|
145
|
+
checkAKValidation(): Promise<{
|
|
146
|
+
valid: boolean;
|
|
147
|
+
errorMessage?: string;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* 设置坐标类型
|
|
151
|
+
*/
|
|
152
|
+
setCoordinateType(options: {
|
|
153
|
+
type: CoordinateType;
|
|
154
|
+
}): Promise<{
|
|
155
|
+
success: boolean;
|
|
156
|
+
}>;
|
|
157
|
+
/**
|
|
158
|
+
* 获取当前坐标类型
|
|
159
|
+
*/
|
|
160
|
+
getCoordinateType(): Promise<{
|
|
161
|
+
type: CoordinateType;
|
|
162
|
+
}>;
|
|
163
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="@capacitor/cli" />
|
|
2
|
+
/**
|
|
3
|
+
* 坐标类型枚举
|
|
4
|
+
*/
|
|
5
|
+
export var CoordinateType;
|
|
6
|
+
(function (CoordinateType) {
|
|
7
|
+
/**
|
|
8
|
+
* 百度经纬度坐标
|
|
9
|
+
*/
|
|
10
|
+
CoordinateType["BD09LL"] = "BD09LL";
|
|
11
|
+
/**
|
|
12
|
+
* 百度墨卡托米制坐标
|
|
13
|
+
*/
|
|
14
|
+
CoordinateType["BD09MC"] = "BD09MC";
|
|
15
|
+
/**
|
|
16
|
+
* 国测局坐标
|
|
17
|
+
*/
|
|
18
|
+
CoordinateType["GCJ02"] = "GCJ02";
|
|
19
|
+
/**
|
|
20
|
+
* WGS84坐标
|
|
21
|
+
*/
|
|
22
|
+
CoordinateType["WGS84"] = "WGS84";
|
|
23
|
+
})(CoordinateType || (CoordinateType = {}));
|
|
24
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAgGxC;;GAEG;AACH,MAAM,CAAN,IAAY,cAiBX;AAjBD,WAAY,cAAc;IACtB;;OAEG;IACH,mCAAiB,CAAA;IACjB;;OAEG;IACH,mCAAiB,CAAA;IACjB;;OAEG;IACH,iCAAe,CAAA;IACf;;OAEG;IACH,iCAAe,CAAA;AACnB,CAAC,EAjBW,cAAc,KAAd,cAAc,QAiBzB","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\ndeclare module '@capacitor/cli' {\n interface PluginsConfig {\n /**\n * 百度地图定位插件配置\n */\n CPBaiduLocation?: {\n /**\n * Android平台百度地图API Key\n */\n androidAK?: string;\n /**\n * iOS平台百度地图API Key\n */\n iOSAK?: string;\n };\n }\n}\n\n/**\n * 定位参数选项\n */\nexport interface PositionOptions {\n /**\n * 是否需要地址信息\n */\n needAddress?: boolean;\n /**\n * 是否需要位置描述\n */\n needLocationDescribe?: boolean;\n}\n\n/**\n * 定位结果\n */\nexport interface PositionResult {\n /**\n * 纬度\n */\n latitude: number;\n /**\n * 经度\n */\n longitude: number;\n /**\n * 定位精度(米)\n */\n accuracy?: number;\n /**\n * 完整地址\n */\n address?: string;\n /**\n * 国家\n */\n country?: string;\n /**\n * 省份\n */\n province?: string;\n /**\n * 城市\n */\n city?: string;\n /**\n * 区县\n */\n district?: string;\n /**\n * 街道\n */\n street?: string;\n /**\n * 行政区划代码\n */\n adcode?: string;\n /**\n * 乡镇\n */\n town?: string;\n /**\n * 位置描述\n */\n locationDescribe?: string;\n /**\n * 错误码\n */\n errorCode?: number;\n /**\n * 错误信息\n */\n errorMessage?: string;\n}\n\n/**\n * 坐标类型枚举\n */\nexport enum CoordinateType {\n /**\n * 百度经纬度坐标\n */\n BD09LL = 'BD09LL',\n /**\n * 百度墨卡托米制坐标\n */\n BD09MC = 'BD09MC',\n /**\n * 国测局坐标\n */\n GCJ02 = 'GCJ02',\n /**\n * WGS84坐标\n */\n WGS84 = 'WGS84',\n}\n\n/**\n * 百度地图定位插件接口\n */\nexport interface CPBaiduLocationPlugin {\n\n /**\n * 获取当前位置信息\n */\n getCurrentPosition(options?: PositionOptions): Promise<PositionResult>;\n\n /**\n * 检查定位权限\n */\n checkPermission(): Promise<{ granted: boolean }>;\n\n /**\n * 请求定位权限\n */\n requestPermission(): Promise<{ granted: boolean }>;\n\n /**\n * 设置百度地图AK\n */\n setAK(options?: { ak: string }): Promise<{ success: boolean; errorMessage?: string }>;\n /**\n * 检查AK验证状态\n */\n checkAKValidation(): Promise<{ valid: boolean; errorMessage?: string }>;\n\n /**\n * 设置坐标类型\n */\n setCoordinateType(options: { type: CoordinateType }): Promise<{ success: boolean }>;\n\n /**\n * 获取当前坐标类型\n */\n getCoordinateType(): Promise<{ type: CoordinateType }>;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerPlugin } from '@capacitor/core';
|
|
2
|
+
const CPBaiduLocation = registerPlugin('CPBaiduLocation', {
|
|
3
|
+
web: () => import('./web').then((m) => new m.CPBaiduLocationWeb()),
|
|
4
|
+
});
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
export { CPBaiduLocation };
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,eAAe,GAAG,cAAc,CAAwB,iBAAiB,EAAE;IAC7E,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;CACrE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CPBaiduLocationPlugin } from './definitions';\n\nconst CPBaiduLocation = registerPlugin<CPBaiduLocationPlugin>('CPBaiduLocation', {\n web: () => import('./web').then((m) => new m.CPBaiduLocationWeb()),\n});\n\nexport * from './definitions';\nexport { CPBaiduLocation };\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 百度地图定位插件Web端实现
|
|
3
|
+
*/
|
|
4
|
+
import { WebPlugin } from '@capacitor/core';
|
|
5
|
+
import { CoordinateType } from './definitions';
|
|
6
|
+
import type { CPBaiduLocationPlugin, PositionOptions, PositionResult } from './definitions';
|
|
7
|
+
/**
|
|
8
|
+
* 百度地图定位插件Web端实现类
|
|
9
|
+
*/
|
|
10
|
+
export declare class CPBaiduLocationWeb extends WebPlugin implements CPBaiduLocationPlugin {
|
|
11
|
+
/**
|
|
12
|
+
* 获取当前位置信息
|
|
13
|
+
* @param _options 定位参数选项,包含needAddress和needLocationDescribe字段
|
|
14
|
+
* - needAddress: 是否需要地址信息(Web端暂不支持)
|
|
15
|
+
* - needLocationDescribe: 是否需要位置描述(Web端暂不支持)
|
|
16
|
+
* @returns 定位结果,包含经纬度、精度等信息
|
|
17
|
+
*/
|
|
18
|
+
getCurrentPosition(_options?: PositionOptions): Promise<PositionResult>;
|
|
19
|
+
/**
|
|
20
|
+
* 检查定位权限
|
|
21
|
+
* @returns 权限状态
|
|
22
|
+
*/
|
|
23
|
+
checkPermission(): Promise<{
|
|
24
|
+
granted: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* 请求定位权限
|
|
28
|
+
* @returns 权限请求结果
|
|
29
|
+
*/
|
|
30
|
+
requestPermission(): Promise<{
|
|
31
|
+
granted: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* 设置百度地图AK
|
|
35
|
+
* @param options 包含ak属性的对象,可选
|
|
36
|
+
* @returns 设置结果
|
|
37
|
+
*/
|
|
38
|
+
setAK(options?: {
|
|
39
|
+
ak: string;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
success: boolean;
|
|
42
|
+
errorMessage?: string;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* 检查AK验证状态
|
|
46
|
+
* @returns AK验证状态
|
|
47
|
+
*/
|
|
48
|
+
checkAKValidation(): Promise<{
|
|
49
|
+
valid: boolean;
|
|
50
|
+
errorMessage?: string;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* 设置坐标类型
|
|
54
|
+
* @param options 包含type属性的对象
|
|
55
|
+
* @returns 设置结果
|
|
56
|
+
*/
|
|
57
|
+
setCoordinateType(options: {
|
|
58
|
+
type: CoordinateType;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
success: boolean;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* 获取当前坐标类型
|
|
64
|
+
* @returns 当前坐标类型
|
|
65
|
+
*/
|
|
66
|
+
getCoordinateType(): Promise<{
|
|
67
|
+
type: CoordinateType;
|
|
68
|
+
}>;
|
|
69
|
+
}
|