expo-gaode-map-navigation 1.1.1 → 1.1.3
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
|
@@ -21,14 +21,12 @@
|
|
|
21
21
|
仅安装本模块(不要安装 `expo-gaode-map`):
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
#
|
|
25
|
-
|
|
24
|
+
# bun
|
|
25
|
+
bun add expo-gaode-map-navigation
|
|
26
26
|
|
|
27
27
|
# or yarn
|
|
28
28
|
yarn add expo-gaode-map-navigation
|
|
29
29
|
|
|
30
|
-
# or pnpm
|
|
31
|
-
pnpm add expo-gaode-map-navigation
|
|
32
30
|
```
|
|
33
31
|
|
|
34
32
|
如果项目中已安装过核心地图包,请先移除避免冲突:
|
|
@@ -36,7 +34,7 @@ pnpm add expo-gaode-map-navigation
|
|
|
36
34
|
```bash
|
|
37
35
|
npm uninstall expo-gaode-map
|
|
38
36
|
# or: yarn remove expo-gaode-map
|
|
39
|
-
# or:
|
|
37
|
+
# or: bun remove expo-gaode-map
|
|
40
38
|
```
|
|
41
39
|
|
|
42
40
|
## 初始化
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// ExpoGaodeMapNaviView.swift
|
|
3
3
|
// expo-gaode-map-navigation
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
//
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import ExpoModulesCore
|
|
@@ -24,7 +24,6 @@ public class ExpoGaodeMapNaviView: ExpoView {
|
|
|
24
24
|
// 从 Info.plist 读取到了 Key,设置到 SDK
|
|
25
25
|
AMapServices.shared().apiKey = infoPlistKey
|
|
26
26
|
apiKey = infoPlistKey
|
|
27
|
-
print("✅ [ExpoGaodeMapNaviView] 已从 Info.plist 读取并设置高德地图 API Key")
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
|
|
@@ -176,7 +175,6 @@ public class ExpoGaodeMapNaviView: ExpoView {
|
|
|
176
175
|
try checkAMapInitialization()
|
|
177
176
|
} catch {
|
|
178
177
|
let errorMessage = formatError(error)
|
|
179
|
-
print("⚠️ [ExpoGaodeMapNaviView] 初始化失败: \(errorMessage)")
|
|
180
178
|
// 触发初始化失败事件
|
|
181
179
|
DispatchQueue.main.async {
|
|
182
180
|
self.onNavigationFailed([
|
|
@@ -37,7 +37,6 @@ public class ExpoGaodeMapNavigationModule: Module {
|
|
|
37
37
|
// 从 Info.plist 读取到了 Key,设置到 SDK
|
|
38
38
|
AMapServices.shared().apiKey = infoPlistKey
|
|
39
39
|
apiKey = infoPlistKey
|
|
40
|
-
print("✅ [ExpoGaodeMapNavigation] 已从 Info.plist 读取并设置高德地图 API Key")
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
|
|
@@ -96,7 +95,6 @@ public class ExpoGaodeMapNavigationModule: Module {
|
|
|
96
95
|
return true
|
|
97
96
|
} catch {
|
|
98
97
|
let errorMessage = self.formatError(error)
|
|
99
|
-
print("⚠️ [ExpoGaodeMapNavigation] 初始化失败: \(errorMessage)")
|
|
100
98
|
throw error
|
|
101
99
|
}
|
|
102
100
|
}
|
|
@@ -109,7 +107,6 @@ public class ExpoGaodeMapNavigationModule: Module {
|
|
|
109
107
|
self.walkRideCalculator = nil
|
|
110
108
|
self.independentRouteService = nil
|
|
111
109
|
self.independentRouteManager.clearAll()
|
|
112
|
-
print("✅ [ExpoGaodeMapNavigation] 已清理所有路径计算器实例")
|
|
113
110
|
}
|
|
114
111
|
|
|
115
112
|
// ---------------- 1. 驾车/货车 路线规划 ----------------
|
|
@@ -35,9 +35,7 @@ public class NaviMapModule: Module {
|
|
|
35
35
|
if saved {
|
|
36
36
|
// 同步到 SDK
|
|
37
37
|
MAMapView.updatePrivacyAgree(AMapPrivacyAgreeStatus.didAgree)
|
|
38
|
-
print("🔁 ExpoGaodeMap: 已从缓存恢复隐私同意状态: true")
|
|
39
38
|
} else {
|
|
40
|
-
print("ℹ️ ExpoGaodeMap: 未发现已同意记录,等待用户同意后再使用 SDK")
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
|
|
@@ -56,21 +54,17 @@ public class NaviMapModule: Module {
|
|
|
56
54
|
if hasAgreed {
|
|
57
55
|
// 同步到 SDK
|
|
58
56
|
MAMapView.updatePrivacyAgree(AMapPrivacyAgreeStatus.didAgree)
|
|
59
|
-
print("✅ ExpoGaodeMap: 用户已同意隐私协议,可以使用 SDK(状态已持久化)")
|
|
60
57
|
|
|
61
58
|
// 在用户同意后,如果尚未设置 API Key,则尝试从 Info.plist 读取并设置
|
|
62
59
|
if AMapServices.shared().apiKey == nil || AMapServices.shared().apiKey?.isEmpty == true {
|
|
63
60
|
if let plistKey = Bundle.main.infoDictionary?["AMapApiKey"] as? String, !plistKey.isEmpty {
|
|
64
61
|
AMapServices.shared().apiKey = plistKey
|
|
65
62
|
AMapServices.shared().enableHTTPS = true
|
|
66
|
-
print("✅ ExpoGaodeMap: 从 Info.plist 读取并设置 AMapApiKey 成功")
|
|
67
63
|
} else {
|
|
68
|
-
print("⚠️ ExpoGaodeMap: Info.plist 未找到 AMapApiKey,后续需通过 initSDK 提供 iosKey")
|
|
69
64
|
}
|
|
70
65
|
}
|
|
71
66
|
} else {
|
|
72
67
|
MAMapView.updatePrivacyAgree(AMapPrivacyAgreeStatus.notAgree)
|
|
73
|
-
print("⚠️ ExpoGaodeMap: 用户未同意隐私协议,SDK 功能将受限(状态已持久化)")
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
70
|
|
|
@@ -83,7 +77,6 @@ public class NaviMapModule: Module {
|
|
|
83
77
|
Function("initSDK") { (config: [String: String]) in
|
|
84
78
|
// 检查是否已同意隐私协议
|
|
85
79
|
if !NaviMapModule.privacyAgreed {
|
|
86
|
-
print("⚠️ ExpoGaodeMap: 用户未同意隐私协议,无法初始化 SDK")
|
|
87
80
|
return
|
|
88
81
|
}
|
|
89
82
|
|
|
@@ -93,12 +86,10 @@ public class NaviMapModule: Module {
|
|
|
93
86
|
if finalKey == nil {
|
|
94
87
|
if let plistKey = Bundle.main.infoDictionary?["AMapApiKey"] as? String, !plistKey.isEmpty {
|
|
95
88
|
finalKey = plistKey
|
|
96
|
-
print("ℹ️ ExpoGaodeMap: initSDK 未提供 iosKey,已从 Info.plist 使用 AMapApiKey")
|
|
97
89
|
}
|
|
98
90
|
}
|
|
99
91
|
|
|
100
92
|
guard let keyToUse = finalKey, !keyToUse.isEmpty else {
|
|
101
|
-
print("⚠️ ExpoGaodeMap: 未提供 iosKey 且 Info.plist 中也无 AMapApiKey,无法初始化 SDK")
|
|
102
93
|
return
|
|
103
94
|
}
|
|
104
95
|
|
|
@@ -111,7 +102,6 @@ public class NaviMapModule: Module {
|
|
|
111
102
|
// 初始化定位管理器(触发原生侧懒加载)
|
|
112
103
|
self.getLocationManager()
|
|
113
104
|
|
|
114
|
-
print("✅ ExpoGaodeMap: 已设置 API Key 并完成初始化(来源:\(providedKey != nil ? "入参 iosKey" : "Info.plist"))")
|
|
115
105
|
}
|
|
116
106
|
|
|
117
107
|
/**
|
|
@@ -129,13 +119,11 @@ public class NaviMapModule: Module {
|
|
|
129
119
|
Function("start") {
|
|
130
120
|
// 检查隐私协议状态
|
|
131
121
|
if !NaviMapModule.privacyAgreed {
|
|
132
|
-
print("⚠️ ExpoGaodeMap: 用户未同意隐私协议,无法开始定位")
|
|
133
122
|
return
|
|
134
123
|
}
|
|
135
124
|
|
|
136
125
|
// 检查是否已设置 API Key
|
|
137
126
|
if AMapServices.shared().apiKey == nil || AMapServices.shared().apiKey?.isEmpty == true {
|
|
138
|
-
print("⚠️ ExpoGaodeMap: 未设置 API Key,无法开始定位")
|
|
139
127
|
return
|
|
140
128
|
}
|
|
141
129
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-gaode-map-navigation",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "高德地图导航功能模块 - 路径规划、导航引导,独立版本包含完整地图功能",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -12,6 +12,16 @@
|
|
|
12
12
|
"expo-module.config.json",
|
|
13
13
|
"plugin/build"
|
|
14
14
|
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "expo-module build && bun run build:plugin",
|
|
17
|
+
"build:plugin": "tsc --project plugin/tsconfig.json",
|
|
18
|
+
"clean": "expo-module clean",
|
|
19
|
+
"lint": "expo-module lint",
|
|
20
|
+
"test": "expo-module test",
|
|
21
|
+
"prepare": "expo-module prepare && bun run build:plugin",
|
|
22
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
23
|
+
"expo-module": "expo-module"
|
|
24
|
+
},
|
|
15
25
|
"keywords": [
|
|
16
26
|
"react-native",
|
|
17
27
|
"expo",
|
|
@@ -26,7 +36,7 @@
|
|
|
26
36
|
"bugs": {
|
|
27
37
|
"url": "https://github.com/TomWq/expo-gaode-map/issues"
|
|
28
38
|
},
|
|
29
|
-
"author": "
|
|
39
|
+
"author": "<TomWq> (https://github.com/TomWq)",
|
|
30
40
|
"license": "MIT",
|
|
31
41
|
"homepage": "https://github.com/TomWq/expo-gaode-map#readme",
|
|
32
42
|
"dependencies": {
|
|
@@ -44,13 +54,5 @@
|
|
|
44
54
|
"expo": "*",
|
|
45
55
|
"react": "*",
|
|
46
56
|
"react-native": "*"
|
|
47
|
-
},
|
|
48
|
-
"scripts": {
|
|
49
|
-
"build": "expo-module build && pnpm run build:plugin",
|
|
50
|
-
"build:plugin": "tsc --project plugin/tsconfig.json",
|
|
51
|
-
"clean": "expo-module clean",
|
|
52
|
-
"lint": "expo-module lint",
|
|
53
|
-
"test": "expo-module test",
|
|
54
|
-
"expo-module": "expo-module"
|
|
55
57
|
}
|
|
56
|
-
}
|
|
58
|
+
}
|