expo-gaode-map-navigation 2.0.12 → 2.0.13
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 +7 -2
- package/android/build.gradle +8 -4
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapOfflineModule.kt +83 -15
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +13 -3
- package/android/src/main/java/expo/modules/gaodemap/map/managers/UIManager.kt +36 -39
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterView.kt +5 -2
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapView.kt +122 -10
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapViewModule.kt +2 -2
- package/android/src/main/java/expo/modules/gaodemap/map/search/ExpoGaodeMapSearchModule.kt +751 -0
- package/build/map/ExpoGaodeMapOfflineModule.d.ts +5 -0
- package/build/map/ExpoGaodeMapOfflineModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.js.map +1 -1
- package/build/map/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/map/components/overlays/HeatMap.js +21 -2
- package/build/map/components/overlays/HeatMap.js.map +1 -1
- package/build/map/index.d.ts +3 -0
- package/build/map/index.d.ts.map +1 -1
- package/build/map/index.js +3 -0
- package/build/map/index.js.map +1 -1
- package/build/map/search/ExpoGaodeMapSearch.types.d.ts +340 -0
- package/build/map/search/ExpoGaodeMapSearch.types.d.ts.map +1 -0
- package/build/map/search/ExpoGaodeMapSearch.types.js +19 -0
- package/build/map/search/ExpoGaodeMapSearch.types.js.map +1 -0
- package/build/map/search/ExpoGaodeMapSearchModule.d.ts +74 -0
- package/build/map/search/ExpoGaodeMapSearchModule.d.ts.map +1 -0
- package/build/map/search/ExpoGaodeMapSearchModule.js +47 -0
- package/build/map/search/ExpoGaodeMapSearchModule.js.map +1 -0
- package/build/map/search/index.d.ts +156 -0
- package/build/map/search/index.d.ts.map +1 -0
- package/build/map/search/index.js +171 -0
- package/build/map/search/index.js.map +1 -0
- package/build/map/types/map-view.types.d.ts +4 -2
- package/build/map/types/map-view.types.d.ts.map +1 -1
- package/build/map/types/map-view.types.js.map +1 -1
- package/build/map/utils/ErrorHandler.js +11 -11
- package/build/map/utils/ErrorHandler.js.map +1 -1
- package/build/map/utils/OfflineMapManager.d.ts +4 -0
- package/build/map/utils/OfflineMapManager.d.ts.map +1 -1
- package/build/map/utils/OfflineMapManager.js +6 -0
- package/build/map/utils/OfflineMapManager.js.map +1 -1
- package/expo-module.config.json +4 -2
- package/ios/ExpoGaodeMapNaviView.swift +16 -17
- package/ios/ExpoGaodeMapNavigation.podspec +2 -1
- package/ios/map/ExpoGaodeMapOfflineModule.swift +61 -0
- package/ios/map/ExpoGaodeMapSearchModule.swift +773 -0
- package/ios/map/modules/LocationManager.swift +9 -3
- package/ios/map/overlays/PolylineView.swift +6 -12
- package/package.json +1 -1
- package/plugin/build/withGaodeMap.js +12 -0
- package/android/src/main/java/expo/modules/gaodemap/navigation/managers/RouteCalculator.kt +0 -173
|
@@ -102,11 +102,17 @@ class LocationManager: NSObject, AMapLocationManagerDelegate {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
private func setReGeocodeLanguage(_ rawValue: AMapRegionLanguageType.RawValue) {
|
|
106
|
+
if let language = AMapRegionLanguageType(rawValue: rawValue) {
|
|
107
|
+
ensureLocationManager()?.reGeocodeLanguage = language
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
105
111
|
func setGeoLanguage(_ language: Int) {
|
|
106
112
|
switch language {
|
|
107
|
-
case 0:
|
|
108
|
-
case 1:
|
|
109
|
-
case 2:
|
|
113
|
+
case 0: setReGeocodeLanguage(0)
|
|
114
|
+
case 1: setReGeocodeLanguage(0)
|
|
115
|
+
case 2: setReGeocodeLanguage(2)
|
|
110
116
|
default: break
|
|
111
117
|
}
|
|
112
118
|
}
|
|
@@ -71,6 +71,9 @@ class PolylineView: ExpoView {
|
|
|
71
71
|
func setMap(_ map: MAMapView) {
|
|
72
72
|
// 🔑 关键优化:如果是同一个地图引用,跳过重复设置
|
|
73
73
|
if lastSetMapView === map {
|
|
74
|
+
if polyline == nil {
|
|
75
|
+
updatePolyline()
|
|
76
|
+
}
|
|
74
77
|
return
|
|
75
78
|
}
|
|
76
79
|
|
|
@@ -105,10 +108,9 @@ class PolylineView: ExpoView {
|
|
|
105
108
|
// 🔑 至少需要2个点才能绘制折线
|
|
106
109
|
guard coords.count >= 2 else { return }
|
|
107
110
|
|
|
111
|
+
renderer = nil
|
|
108
112
|
polyline = MAPolyline(coordinates: &coords, count: UInt(coords.count))
|
|
109
113
|
mapView.add(polyline!)
|
|
110
|
-
|
|
111
|
-
renderer = nil
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
/**
|
|
@@ -221,18 +223,10 @@ class PolylineView: ExpoView {
|
|
|
221
223
|
|
|
222
224
|
/**
|
|
223
225
|
* 强制重新渲染折线
|
|
224
|
-
*
|
|
226
|
+
* 通过重建 overlay 来触发地图重新请求 renderer
|
|
225
227
|
*/
|
|
226
228
|
private func forceRerender() {
|
|
227
|
-
|
|
228
|
-
return
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// 移除旧的 overlay
|
|
232
|
-
mapView.remove(polyline)
|
|
233
|
-
|
|
234
|
-
// 重新添加(地图会调用 rendererFor overlay)
|
|
235
|
-
mapView.add(polyline)
|
|
229
|
+
updatePolyline()
|
|
236
230
|
}
|
|
237
231
|
|
|
238
232
|
func setDotted(_ dotted: Bool) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-gaode-map-navigation",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"description": "React Native AMap (Gaode Map) navigation module for Expo: route planning and turn-by-turn navigation, includes full map features.",
|
|
5
5
|
"author": "TomWq <582752848@qq.com> (https://github.com/TomWq)",
|
|
6
6
|
"repository": {
|
|
@@ -236,6 +236,18 @@ configurations.all {
|
|
|
236
236
|
*/
|
|
237
237
|
const withGaodeMapAndroidSdk = (config, props) => {
|
|
238
238
|
return (0, config_plugins_1.withGradleProperties)(config, (config) => {
|
|
239
|
+
const jetifierKey = 'android.enableJetifier';
|
|
240
|
+
const jetifier = config.modResults.find((item) => item.type === 'property' && item.key === jetifierKey);
|
|
241
|
+
if (jetifier && jetifier.type === 'property') {
|
|
242
|
+
jetifier.value = 'true';
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
config.modResults.push({
|
|
246
|
+
type: 'property',
|
|
247
|
+
key: jetifierKey,
|
|
248
|
+
value: 'true',
|
|
249
|
+
});
|
|
250
|
+
}
|
|
239
251
|
if (props.customMapSdkPath) {
|
|
240
252
|
const key = 'EXPO_GAODE_MAP_CUSTOM_SDK_PATH';
|
|
241
253
|
const existing = config.modResults.find((item) => item.type === 'property' && item.key === key);
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
package expo.modules.gaodemap.navigation.managers
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import com.amap.api.navi.AMapNavi
|
|
5
|
-
import com.amap.api.navi.model.AMapCarInfo
|
|
6
|
-
|
|
7
|
-
import expo.modules.kotlin.Promise
|
|
8
|
-
import expo.modules.gaodemap.navigation.ExpoGaodeMapNavigationModule
|
|
9
|
-
import expo.modules.gaodemap.navigation.utils.Converters
|
|
10
|
-
import expo.modules.gaodemap.navigation.listeners.RouteCalculateListener
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 路径规划管理器
|
|
14
|
-
*
|
|
15
|
-
* 负责处理各种类型的路径规划:驾车、步行、骑行、公交、货车
|
|
16
|
-
*/
|
|
17
|
-
class RouteCalculator(
|
|
18
|
-
private val context: Context,
|
|
19
|
-
private val module: ExpoGaodeMapNavigationModule
|
|
20
|
-
) {
|
|
21
|
-
|
|
22
|
-
private var aMapNavi: AMapNavi? = null
|
|
23
|
-
private var routeListener: RouteCalculateListener? = null
|
|
24
|
-
|
|
25
|
-
init {
|
|
26
|
-
initNavi()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private fun initNavi() {
|
|
30
|
-
if (aMapNavi == null) {
|
|
31
|
-
aMapNavi = AMapNavi.getInstance(context)
|
|
32
|
-
routeListener = RouteCalculateListener(module)
|
|
33
|
-
aMapNavi?.addAMapNaviListener(routeListener)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 驾车路径规划
|
|
39
|
-
*/
|
|
40
|
-
fun calculateDriveRoute(options: Map<String, Any?>, promise: Promise) {
|
|
41
|
-
@Suppress("UNCHECKED_CAST")
|
|
42
|
-
val from = options["from"] as? Map<String, Any?>
|
|
43
|
-
@Suppress("UNCHECKED_CAST")
|
|
44
|
-
val to = options["to"] as? Map<String, Any?>
|
|
45
|
-
?: throw Exception("to is required")
|
|
46
|
-
|
|
47
|
-
val fromPoi = from?.let { Converters.parseNaviPoi(it) }
|
|
48
|
-
val toPoi = Converters.parseNaviPoi(to)
|
|
49
|
-
@Suppress("UNCHECKED_CAST")
|
|
50
|
-
val waypoints = Converters.parseWaypoints(options["waypoints"] as? List<Map<String, Any?>>)
|
|
51
|
-
|
|
52
|
-
// 支持两种策略传参:
|
|
53
|
-
// 1) 直接传 PathPlanningStrategy 的整型值:strategy
|
|
54
|
-
// 2) 传策略开关(建议):avoidCongestion/avoidHighway/avoidCost/prioritiseHighway
|
|
55
|
-
val strategy: Int = if (options.containsKey("strategy")) {
|
|
56
|
-
(options["strategy"] as? Number)?.toInt() ?: 0
|
|
57
|
-
} else {
|
|
58
|
-
val avoidCongestion = options["avoidCongestion"] as? Boolean ?: false
|
|
59
|
-
val avoidHighway = options["avoidHighway"] as? Boolean ?: false
|
|
60
|
-
val avoidCost = options["avoidCost"] as? Boolean ?: false
|
|
61
|
-
val prioritiseHighway = options["prioritiseHighway"] as? Boolean ?: false
|
|
62
|
-
try {
|
|
63
|
-
// 6.3+ multipleRoute 参数已无效,但保留 true 以获取多路线策略
|
|
64
|
-
aMapNavi?.strategyConvert(avoidCongestion, avoidHighway, avoidCost, prioritiseHighway, true) ?: 0
|
|
65
|
-
} catch (e: Exception) {
|
|
66
|
-
0
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 若提供了车牌/限行信息,则在算路前设置车辆信息(小客车)
|
|
71
|
-
val carNumber = options["carNumber"] as? String
|
|
72
|
-
val restriction = options["restriction"] as? Boolean
|
|
73
|
-
if (carNumber != null || restriction != null) {
|
|
74
|
-
try {
|
|
75
|
-
val carInfo = AMapCarInfo().apply {
|
|
76
|
-
if (carNumber != null) setCarNumber(carNumber)
|
|
77
|
-
// 0=小客车;如为货车请使用 calculateTruckRoute 并设置 carType=1
|
|
78
|
-
setCarType("0")
|
|
79
|
-
if (restriction != null) setRestriction(restriction)
|
|
80
|
-
}
|
|
81
|
-
aMapNavi?.setCarInfo(carInfo)
|
|
82
|
-
} catch (_: Exception) {
|
|
83
|
-
// 忽略设置失败,不影响算路
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
routeListener?.currentPromise = promise
|
|
88
|
-
// 官方 API:POI 算路
|
|
89
|
-
aMapNavi?.calculateDriveRoute(fromPoi, toPoi, waypoints, strategy)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* 步行路径规划(使用 NaviLatLng)
|
|
94
|
-
*/
|
|
95
|
-
fun calculateWalkRoute(options: Map<String, Any?>, promise: Promise) {
|
|
96
|
-
@Suppress("UNCHECKED_CAST")
|
|
97
|
-
val from = options["from"] as? Map<String, Any?>
|
|
98
|
-
?: throw Exception("from is required")
|
|
99
|
-
@Suppress("UNCHECKED_CAST")
|
|
100
|
-
val to = options["to"] as? Map<String, Any?>
|
|
101
|
-
?: throw Exception("to is required")
|
|
102
|
-
|
|
103
|
-
val fromLatLng = Converters.parseNaviLatLng(from)
|
|
104
|
-
val toLatLng = Converters.parseNaviLatLng(to)
|
|
105
|
-
|
|
106
|
-
routeListener?.currentPromise = promise
|
|
107
|
-
aMapNavi?.calculateWalkRoute(fromLatLng, toLatLng)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* 骑行路径规划(使用 NaviLatLng)
|
|
112
|
-
*/
|
|
113
|
-
fun calculateRideRoute(options: Map<String, Any?>, promise: Promise) {
|
|
114
|
-
@Suppress("UNCHECKED_CAST")
|
|
115
|
-
val from = options["from"] as? Map<String, Any?>
|
|
116
|
-
?: throw Exception("from is required")
|
|
117
|
-
@Suppress("UNCHECKED_CAST")
|
|
118
|
-
val to = options["to"] as? Map<String, Any?>
|
|
119
|
-
?: throw Exception("to is required")
|
|
120
|
-
|
|
121
|
-
val fromLatLng = Converters.parseNaviLatLng(from)
|
|
122
|
-
val toLatLng = Converters.parseNaviLatLng(to)
|
|
123
|
-
|
|
124
|
-
routeListener?.currentPromise = promise
|
|
125
|
-
aMapNavi?.calculateRideRoute(fromLatLng, toLatLng)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* 公交路径规划
|
|
130
|
-
* 注意:公交路径规划需要使用搜索服务,这里返回未实现错误
|
|
131
|
-
*/
|
|
132
|
-
fun calculateBusRoute(options: Map<String, Any?>, promise: Promise) {
|
|
133
|
-
promise.reject("NOT_IMPLEMENTED", "Bus route calculation requires search service", null)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* 货车路径规划
|
|
138
|
-
*/
|
|
139
|
-
fun calculateTruckRoute(options: Map<String, Any?>, promise: Promise) {
|
|
140
|
-
// 货车路径规划:在算路前设置货车信息
|
|
141
|
-
try {
|
|
142
|
-
val carNumber = options["carNumber"] as? String
|
|
143
|
-
val restriction = options["restriction"] as? Boolean
|
|
144
|
-
val carInfo = AMapCarInfo().apply {
|
|
145
|
-
if (carNumber != null) setCarNumber(carNumber)
|
|
146
|
-
// 1=货车(CarType 为 1/3/5 均视为货车),这里取 1 作为通用值
|
|
147
|
-
setCarType("1")
|
|
148
|
-
if (restriction != null) setRestriction(restriction)
|
|
149
|
-
// 如需更精细的车型参数(轴数/长宽高/载重等),可在此扩展:
|
|
150
|
-
// setVehicleAxis("6"); setVehicleHeight("3.5"); setVehicleLength("7.3"); setVehicleWidth("2.5");
|
|
151
|
-
// setVehicleSize("4"); setVehicleLoad("25.99"); setVehicleWeight("20"); setVehicleLoadSwitch(true);
|
|
152
|
-
}
|
|
153
|
-
aMapNavi?.setCarInfo(carInfo)
|
|
154
|
-
} catch (_: Exception) {
|
|
155
|
-
// 忽略设置失败,不影响后续算路
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// 复用驾车算路逻辑(含 strategyConvert)
|
|
159
|
-
calculateDriveRoute(options, promise)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
fun destroy() {
|
|
163
|
-
aMapNavi?.removeAMapNaviListener(routeListener)
|
|
164
|
-
try {
|
|
165
|
-
// 官方建议:销毁单例释放资源
|
|
166
|
-
AMapNavi.destroy()
|
|
167
|
-
} catch (_: Exception) {
|
|
168
|
-
} finally {
|
|
169
|
-
aMapNavi = null
|
|
170
|
-
routeListener = null
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|