expo-gaode-map-navigation 1.1.4 → 1.1.5-next.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.
@@ -28,9 +28,8 @@ const ExpoGaodeMapModuleWithHelpers = {
28
28
  * 初始化 SDK,并缓存配置(包含 webKey)
29
29
  */
30
30
  initSDK(config) {
31
- var _a;
32
- _sdkConfig = config !== null && config !== void 0 ? config : null;
33
- (_a = nativeModule === null || nativeModule === void 0 ? void 0 : nativeModule.initSDK) === null || _a === void 0 ? void 0 : _a.call(nativeModule, config);
31
+ _sdkConfig = config ?? null;
32
+ nativeModule?.initSDK?.(config);
34
33
  },
35
34
  /**
36
35
  * 添加定位监听器(便捷方法)
@@ -40,9 +39,8 @@ const ExpoGaodeMapModuleWithHelpers = {
40
39
  * @throws 如果底层模块不可用,返回一个空操作的订阅对象
41
40
  */
42
41
  addLocationListener(listener) {
43
- var _a;
44
42
  // 使用可选链和空值合并,确保即使模块不可用也不会崩溃
45
- return ((_a = nativeModule === null || nativeModule === void 0 ? void 0 : nativeModule.addListener) === null || _a === void 0 ? void 0 : _a.call(nativeModule, 'onLocationUpdate', listener)) || {
43
+ return nativeModule?.addListener?.('onLocationUpdate', listener) || {
46
44
  remove: () => { },
47
45
  };
48
46
  },
@@ -57,6 +55,6 @@ function getSDKConfig() {
57
55
  * 获取用于 Web API 的 webKey(若未初始化或未提供则返回 undefined)
58
56
  */
59
57
  function getWebKey() {
60
- return _sdkConfig === null || _sdkConfig === void 0 ? void 0 : _sdkConfig.webKey;
58
+ return _sdkConfig?.webKey;
61
59
  }
62
60
  exports.default = ExpoGaodeMapModuleWithHelpers;
@@ -1,9 +1,7 @@
1
1
  export * from './ExpoGaodeMap.types';
2
- export * from './types';
3
2
  export { default as ExpoGaodeMapModule, getWebKey, getSDKConfig } from './ExpoGaodeMapModule';
4
3
  export type { SDKConfig, PermissionStatus } from './ExpoGaodeMapModule';
5
4
  export { default as MapView } from './ExpoGaodeMapView';
6
- export type { MapViewRef } from './ExpoGaodeMapView';
7
5
  export { Marker, Polyline, Polygon, Circle, HeatMap, MultiPoint, Cluster, } from './components/overlays';
8
6
  export { requireModule, OptionalModules, getInstalledModules, printModuleInfo, createLazyLoader, } from './utils/ModuleLoader';
9
7
  export { default } from './ExpoGaodeMapModule';
@@ -20,7 +20,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.default = exports.createLazyLoader = exports.printModuleInfo = exports.getInstalledModules = exports.OptionalModules = exports.requireModule = exports.Cluster = exports.MultiPoint = exports.HeatMap = exports.Circle = exports.Polygon = exports.Polyline = exports.Marker = exports.MapView = exports.getSDKConfig = exports.getWebKey = exports.ExpoGaodeMapModule = void 0;
21
21
  // 导出类型定义
22
22
  __exportStar(require("./ExpoGaodeMap.types"), exports);
23
- __exportStar(require("./types"), exports);
24
23
  // 导出原生模块 - 直接使用,无需封装
25
24
  var ExpoGaodeMapModule_1 = require("./ExpoGaodeMapModule");
26
25
  Object.defineProperty(exports, "ExpoGaodeMapModule", { enumerable: true, get: function () { return __importDefault(ExpoGaodeMapModule_1).default; } });
@@ -336,5 +336,5 @@ export interface ClusterProps {
336
336
  /**
337
337
  * 聚合点点击事件
338
338
  */
339
- onPress?: (event: NativeSyntheticEvent<ClusterParams>) => void;
339
+ onClusterPress?: (event: NativeSyntheticEvent<ClusterParams>) => void;
340
340
  }
@@ -17,7 +17,7 @@ class EventManager {
17
17
  }
18
18
  trigger(id, eventType, data) {
19
19
  const callbacks = this.callbacks.get(id);
20
- const callback = callbacks === null || callbacks === void 0 ? void 0 : callbacks[eventType];
20
+ const callback = callbacks?.[eventType];
21
21
  if (typeof callback === 'function') {
22
22
  callback(data);
23
23
  }
@@ -106,13 +106,6 @@ export interface NaviViewProps extends ViewProps {
106
106
  * @since 6.2.0
107
107
  */
108
108
  carOverlayVisible?: boolean;
109
- /**
110
- * 是否显示交通信号灯
111
- * @platform android
112
- * @default true
113
- * @since 7.4.0
114
- */
115
- trafficLightsVisible?: boolean;
116
109
  /**
117
110
  * 路线标记点可见性配置
118
111
  * @platform android
@@ -152,26 +145,25 @@ export interface NaviViewProps extends ViewProps {
152
145
  */
153
146
  showTrafficLightView?: boolean;
154
147
  /**
155
- * 是否显示路线
156
- * @platform ios
157
- * @default true
148
+ * 导航界面顶部与状态栏的间距(单位:dp)
149
+ * @platform android
150
+ * @default 状态栏高度(单位:dp)
158
151
  */
159
- showRoute?: boolean;
152
+ androidStatusBarPaddingTop?: number;
160
153
  /**
161
- * 是否显示转向箭头
154
+ * 是否显示路线
162
155
  * @platform ios
163
156
  * @default true
164
157
  */
165
- showTurnArrow?: boolean;
158
+ showRoute?: boolean;
166
159
  /**
167
160
  * 是否显示路况光柱
168
- * @platform ios
169
161
  * @default true
170
162
  */
171
163
  showTrafficBar?: boolean;
172
164
  /**
173
165
  * 是否显示全览按钮
174
- * @platform ios
166
+ *
175
167
  * @default true
176
168
  */
177
169
  showBrowseRouteButton?: boolean;
@@ -183,31 +175,41 @@ export interface NaviViewProps extends ViewProps {
183
175
  showMoreButton?: boolean;
184
176
  /**
185
177
  * 是否显示实时交通按钮
186
- * @platform ios
178
+ *
187
179
  * @default true
188
180
  */
189
181
  showTrafficButton?: boolean;
190
182
  /**
191
183
  * 是否显示界面元素(设为false可完全自定义界面)
192
- * @platform ios
184
+ * 提示:ios 暂时无效,android 有效
193
185
  * @default true
194
186
  */
195
187
  showUIElements?: boolean;
196
188
  /**
197
189
  * 走过的路线是否置灰
198
- * @platform ios
190
+ *
199
191
  * @default false
200
192
  */
201
193
  showGreyAfterPass?: boolean;
202
194
  /**
203
195
  * 是否显示牵引线(起点到终点的飞线)
204
- * @platform ios
196
+ *
205
197
  * @default true
206
198
  */
207
199
  showVectorline?: boolean;
200
+ /**
201
+ * 设置是否为骑步行视图
202
+ * @platform android
203
+ * @default false
204
+ */
205
+ isNaviTravelView?: boolean;
206
+ /**
207
+ * 是否显示指南针
208
+ * @default true
209
+ */
210
+ showCompassEnabled?: boolean;
208
211
  /**
209
212
  * 是否显示红绿灯图标
210
- * @platform ios
211
213
  * @default true
212
214
  */
213
215
  showTrafficLights?: boolean;
@@ -5,6 +5,7 @@
5
5
  //
6
6
  //
7
7
 
8
+ import Foundation
8
9
  import ExpoModulesCore
9
10
  import AMapNaviKit
10
11
 
@@ -84,6 +85,11 @@ public class ExpoGaodeMapNaviView: ExpoView {
84
85
 
85
86
  // MARK: - Properties
86
87
  private var driveView: AMapNaviDriveView?
88
+ private var driveViewLoaded: Bool = false
89
+ private var pendingShowUIElements: Bool?
90
+ private var pendingShowUIElementsWorkItem: DispatchWorkItem?
91
+ private var hasStartedNavi: Bool = false
92
+ private var hasReceivedFirstNaviData: Bool = false
87
93
  private var driveManager: AMapNaviDriveManager?
88
94
 
89
95
  // Props - 通用属性
@@ -136,7 +142,7 @@ public class ExpoGaodeMapNaviView: ExpoView {
136
142
  didSet { driveView?.showTrafficButton = showTrafficButton }
137
143
  }
138
144
  var showUIElements: Bool = true {
139
- didSet { driveView?.showUIElements = showUIElements }
145
+ didSet { applyShowUIElementsToDriveViewIfReady() }
140
146
  }
141
147
  var showGreyAfterPass: Bool = false {
142
148
  didSet { driveView?.showGreyAfterPass = showGreyAfterPass }
@@ -153,6 +159,10 @@ public class ExpoGaodeMapNaviView: ExpoView {
153
159
  var lineWidth: CGFloat = 0 {
154
160
  didSet { driveView?.lineWidth = lineWidth }
155
161
  }
162
+
163
+ func applyShowUIElements(_ visible: Bool) {
164
+ showUIElements = visible
165
+ }
156
166
 
157
167
  // 坐标
158
168
  private var startCoordinate: AMapNaviPoint?
@@ -222,15 +232,68 @@ public class ExpoGaodeMapNaviView: ExpoView {
222
232
  driveView?.showBrowseRouteButton = showBrowseRouteButton
223
233
  driveView?.showMoreButton = showMoreButton
224
234
  driveView?.showTrafficButton = showTrafficButton
225
- driveView?.showUIElements = showUIElements
226
235
  driveView?.showGreyAfterPass = showGreyAfterPass
227
236
  driveView?.showVectorline = showVectorline
228
237
  driveView?.showTrafficLights = showTrafficLights
229
238
  if lineWidth > 0 {
230
239
  driveView?.lineWidth = lineWidth
231
240
  }
241
+
242
+ applyShowUIElementsToDriveViewIfReady()
232
243
  }
233
-
244
+
245
+ private func applyShowUIElementsToDriveViewIfReady() {
246
+ guard driveView != nil else {
247
+ pendingShowUIElements = showUIElements
248
+ return
249
+ }
250
+
251
+ guard driveViewLoaded else {
252
+ pendingShowUIElements = showUIElements
253
+ return
254
+ }
255
+
256
+ let value = pendingShowUIElements ?? showUIElements
257
+ pendingShowUIElements = nil
258
+
259
+ if value == false && (!hasStartedNavi || !hasReceivedFirstNaviData) {
260
+ pendingShowUIElements = false
261
+ pendingShowUIElementsWorkItem?.cancel()
262
+ let workItem = DispatchWorkItem { [weak self] in
263
+ guard let self else { return }
264
+ self.applyDriveViewShowUIElements(true, remainingAttempts: 20)
265
+ }
266
+ pendingShowUIElementsWorkItem = workItem
267
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.08, execute: workItem)
268
+ return
269
+ }
270
+
271
+ pendingShowUIElementsWorkItem?.cancel()
272
+ let workItem = DispatchWorkItem { [weak self] in
273
+ guard let self else { return }
274
+ self.applyDriveViewShowUIElements(value, remainingAttempts: 20)
275
+ }
276
+ pendingShowUIElementsWorkItem = workItem
277
+
278
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.08, execute: workItem)
279
+ }
280
+
281
+ private func applyDriveViewShowUIElements(_ value: Bool, remainingAttempts: Int) {
282
+ guard let driveView else { return }
283
+
284
+ if driveView.bounds.isEmpty {
285
+ if remainingAttempts <= 0 {
286
+ return
287
+ }
288
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [weak self] in
289
+ self?.applyDriveViewShowUIElements(value, remainingAttempts: remainingAttempts - 1)
290
+ }
291
+ return
292
+ }
293
+
294
+ driveView.showUIElements = value
295
+ }
296
+
234
297
  // MARK: - Prop Setters
235
298
  private func applyShowCamera(_ show: Bool) {
236
299
  driveView?.showCamera = show
@@ -366,6 +429,7 @@ public class ExpoGaodeMapNaviView: ExpoView {
366
429
  extension ExpoGaodeMapNaviView: AMapNaviDriveManagerDelegate {
367
430
 
368
431
  public func driveManager(onCalculateRouteSuccess driveManager: AMapNaviDriveManager) {
432
+ hasStartedNavi = true
369
433
  onRouteCalculated([
370
434
  "success": true,
371
435
  "naviType": naviType
@@ -377,6 +441,8 @@ extension ExpoGaodeMapNaviView: AMapNaviDriveManagerDelegate {
377
441
  } else {
378
442
  driveManager.startGPSNavi()
379
443
  }
444
+
445
+ applyShowUIElementsToDriveViewIfReady()
380
446
  }
381
447
 
382
448
  public func driveManager(_ driveManager: AMapNaviDriveManager, onCalculateRouteFailure error: Error) {
@@ -387,10 +453,13 @@ extension ExpoGaodeMapNaviView: AMapNaviDriveManagerDelegate {
387
453
  }
388
454
 
389
455
  public func driveManager(_ driveManager: AMapNaviDriveManager, didStartNavi naviMode: AMapNaviMode) {
456
+ hasStartedNavi = true
390
457
  onNavigationStarted([
391
458
  "type": naviMode == .emulator ? 1 : 0,
392
459
  "isEmulator": naviMode == .emulator
393
460
  ])
461
+
462
+ applyShowUIElementsToDriveViewIfReady()
394
463
  }
395
464
 
396
465
  public func driveManagerNavi(_ driveManager: AMapNaviDriveManager, didArrive wayPoint: AMapNaviPoint) {
@@ -404,6 +473,10 @@ extension ExpoGaodeMapNaviView: AMapNaviDriveManagerDelegate {
404
473
  }
405
474
 
406
475
  public func driveManager(_ driveManager: AMapNaviDriveManager, didUpdate naviLocation: AMapNaviLocation) {
476
+ if !hasReceivedFirstNaviData {
477
+ hasReceivedFirstNaviData = true
478
+ applyShowUIElementsToDriveViewIfReady()
479
+ }
407
480
  onLocationUpdate([
408
481
  "latitude": naviLocation.coordinate.latitude,
409
482
  "longitude": naviLocation.coordinate.longitude,
@@ -413,6 +486,10 @@ extension ExpoGaodeMapNaviView: AMapNaviDriveManagerDelegate {
413
486
  }
414
487
 
415
488
  public func driveManager(_ driveManager: AMapNaviDriveManager, didUpdate naviInfo: AMapNaviInfo) {
489
+ if !hasReceivedFirstNaviData {
490
+ hasReceivedFirstNaviData = true
491
+ applyShowUIElementsToDriveViewIfReady()
492
+ }
416
493
  onNavigationInfoUpdate([
417
494
  "currentRoadName": naviInfo.currentRoadName ?? "",
418
495
  "nextRoadName": naviInfo.nextRoadName ?? "",
@@ -458,6 +535,13 @@ extension ExpoGaodeMapNaviView: AMapNaviDriveManagerDelegate {
458
535
  extension ExpoGaodeMapNaviView: AMapNaviDriveViewDelegate {
459
536
 
460
537
  public func driveViewDidLoad(_ driveView: AMapNaviDriveView) {
538
+ driveViewLoaded = true
539
+ applyViewOptions()
540
+ applyShowUIElementsToDriveViewIfReady()
461
541
  onNavigationReady([:])
462
542
  }
543
+
544
+ public func driveViewEdgePadding(_ driveView: AMapNaviDriveView) -> UIEdgeInsets {
545
+ return .zero
546
+ }
463
547
  }
@@ -76,7 +76,7 @@ public class ExpoGaodeMapNaviViewModule: Module {
76
76
  view.showRoute = value
77
77
  }
78
78
 
79
- Prop("showTurnArrow") { (view: ExpoGaodeMapNaviView, value: Bool) in
79
+ Prop("naviArrowVisible") { (view: ExpoGaodeMapNaviView, value: Bool) in
80
80
  view.showTurnArrow = value
81
81
  }
82
82
 
@@ -97,7 +97,7 @@ public class ExpoGaodeMapNaviViewModule: Module {
97
97
  }
98
98
 
99
99
  Prop("showUIElements") { (view: ExpoGaodeMapNaviView, value: Bool) in
100
- view.showUIElements = value
100
+ view.applyShowUIElements(value)
101
101
  }
102
102
 
103
103
  Prop("showGreyAfterPass") { (view: ExpoGaodeMapNaviView, value: Bool) in
@@ -1,6 +1,7 @@
1
1
  import Foundation
2
2
  import AMapLocationKit
3
3
  import CoreLocation
4
+ import ExpoModulesCore
4
5
 
5
6
  /**
6
7
  * 定位管理器
@@ -123,6 +124,13 @@ class LocationManager: NSObject, AMapLocationManagerDelegate {
123
124
  * @param allows 是否允许后台定位
124
125
  */
125
126
  func setAllowsBackgroundLocationUpdates(_ allows: Bool) {
127
+ if allows {
128
+ let backgroundModes = Bundle.main.object(forInfoDictionaryKey: "UIBackgroundModes") as? [String]
129
+ if backgroundModes?.contains("location") != true {
130
+ log.warn("⚠️ [ExpoGaodeMap] iOS 后台定位未正确配置,setAllowsBackgroundLocationUpdates(true) 可能不会生效,请检查 Info.plist 是否包含 UIBackgroundModes: location,或者在 app.json 中配置 enableBackgroundLocation: true,然后重新执行 npx expo prebuild")
131
+ return
132
+ }
133
+ }
126
134
  locationManager?.allowsBackgroundLocationUpdates = allows
127
135
  }
128
136
 
@@ -262,4 +270,4 @@ class LocationManager: NSObject, AMapLocationManagerDelegate {
262
270
  func amapLocationManager(_ manager: AMapLocationManager!, didFailWithError error: Error!) {
263
271
  // 定位失败 - 静默处理
264
272
  }
265
- }
273
+ }
package/package.json CHANGED
@@ -1,17 +1,11 @@
1
1
  {
2
2
  "name": "expo-gaode-map-navigation",
3
- "version": "1.1.4",
3
+ "version": "1.1.5-next.1",
4
4
  "description": "高德地图导航功能模块 - 路径规划、导航引导,独立版本包含完整地图功能",
5
+ "author": "<TomWq> (https://github.com/TomWq)",
6
+ "repository": "https://github.com/TomWq/expo-gaode-map",
5
7
  "main": "build/index.js",
6
8
  "types": "build/index.d.ts",
7
- "files": [
8
- "build",
9
- "android",
10
- "ios",
11
- "app.plugin.js",
12
- "expo-module.config.json",
13
- "plugin/build"
14
- ],
15
9
  "scripts": {
16
10
  "build": "expo-module build && bun run build:plugin",
17
11
  "build:plugin": "tsc --project plugin/tsconfig.json",
@@ -19,9 +13,34 @@
19
13
  "lint": "expo-module lint",
20
14
  "test": "expo-module test",
21
15
  "prepare": "expo-module prepare && bun run build:plugin",
22
- "prepublishOnly": "expo-module prepublishOnly",
16
+ "prepublishOnly": "echo 'Skipping proofread check' && exit 0",
23
17
  "expo-module": "expo-module"
24
18
  },
19
+ "devDependencies": {
20
+ "@expo/config-plugins": "~54.0.4",
21
+ "@types/react": "~19.1.0",
22
+ "expo": "^54.0.31",
23
+ "expo-module-scripts": "^5.0.8",
24
+ "react-native": "0.81.5",
25
+ "typescript": "^5.9.3"
26
+ },
27
+ "peerDependencies": {
28
+ "expo": "*",
29
+ "react": "*",
30
+ "react-native": "*"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/TomWq/expo-gaode-map/issues"
34
+ },
35
+ "files": [
36
+ "build",
37
+ "android",
38
+ "ios",
39
+ "app.plugin.js",
40
+ "expo-module.config.json",
41
+ "plugin/build"
42
+ ],
43
+ "homepage": "https://github.com/TomWq/expo-gaode-map#readme",
25
44
  "keywords": [
26
45
  "react-native",
27
46
  "expo",
@@ -32,27 +51,5 @@
32
51
  "高德地图",
33
52
  "导航"
34
53
  ],
35
- "repository": "https://github.com/TomWq/expo-gaode-map",
36
- "bugs": {
37
- "url": "https://github.com/TomWq/expo-gaode-map/issues"
38
- },
39
- "author": "<TomWq> (https://github.com/TomWq)",
40
- "license": "MIT",
41
- "homepage": "https://github.com/TomWq/expo-gaode-map#readme",
42
- "dependencies": {
43
- "supercluster": "^8.0.1"
44
- },
45
- "devDependencies": {
46
- "@expo/config-plugins": "^9.1.7",
47
- "@types/react": "~19.1.0",
48
- "expo": "^54.0.18",
49
- "expo-module-scripts": "^5.0.7",
50
- "react-native": "0.81.5",
51
- "typescript": "^5.9.3"
52
- },
53
- "peerDependencies": {
54
- "expo": "*",
55
- "react": "*",
56
- "react-native": "*"
57
- }
54
+ "license": "MIT"
58
55
  }