expo-gaode-map 2.2.8-next.0 → 2.2.9-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.
@@ -18,11 +18,11 @@ function Marker(props) {
18
18
  // 根据是否有 children 来决定使用哪个尺寸属性
19
19
  const hasChildren = !!children;
20
20
  const finalIconWidth = hasChildren
21
- ? (customViewWidth && customViewWidth > 0 ? customViewWidth : 0)
22
- : (iconWidth && iconWidth > 0 ? iconWidth : 0);
21
+ ? (customViewWidth && customViewWidth > 0 ? customViewWidth : 200)
22
+ : (iconWidth && iconWidth > 0 ? iconWidth : 40);
23
23
  const finalIconHeight = hasChildren
24
- ? (customViewHeight && customViewHeight > 0 ? customViewHeight : 0)
25
- : (iconHeight && iconHeight > 0 ? iconHeight : 0);
24
+ ? (customViewHeight && customViewHeight > 0 ? customViewHeight : 40)
25
+ : (iconHeight && iconHeight > 0 ? iconHeight : 40);
26
26
  return (<NativeMarkerView latitude={position.latitude} longitude={position.longitude} iconWidth={finalIconWidth} iconHeight={finalIconHeight} customViewWidth={finalIconWidth} customViewHeight={finalIconHeight} {...restProps}>
27
27
  {children}
28
28
  </NativeMarkerView>);
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.js","sourceRoot":"","sources":["../../../src/components/overlays/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,MAAM,gBAAgB,GAAG,wBAAwB,CAAC,YAAY,CAAC,CAAC;AAEhE;;;;;;;;;GASG;AACH,SAAS,MAAM,CAAC,KAAkB;IAChC,mCAAmC;IACnC,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAE7G,qBAAqB;IACrB,6BAA6B;IAC7B,MAAM,WAA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,IAAI,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6BAA6B;IAC7B,IAAI,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,eAAe;IACf,OAAO,IAAI,CAAC;AACd,CAAC;AAED,WAAW;AACX,eAAe,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { requireNativeViewManager } from 'expo-modules-core';\nimport type { MarkerProps } from '../../types';\n\nconst NativeMarkerView = requireNativeViewManager('MarkerView');\n\n/**\n * Marker 组件 - 完全声明式 API\n *\n * 支持:\n * - 自定义图标(icon)\n * - 自定义内容(children)\n * - 大头针样式(pinColor)\n * - 拖拽功能\n * - 所有事件回调\n */\nfunction Marker(props: MarkerProps) {\n // 从 props 中排除 position 属性,避免传递到原生层\n const { position, customViewWidth, customViewHeight, iconWidth, iconHeight, children, ...restProps } = props;\n \n // 🔑 性能优化:使用常量避免重复计算\n // 根据是否有 children 来决定使用哪个尺寸属性\n const hasChildren = !!children;\n const finalIconWidth = hasChildren\n ? (customViewWidth && customViewWidth > 0 ? customViewWidth : 0)\n : (iconWidth && iconWidth > 0 ? iconWidth : 0);\n const finalIconHeight = hasChildren\n ? (customViewHeight && customViewHeight > 0 ? customViewHeight : 0)\n : (iconHeight && iconHeight > 0 ? iconHeight : 0);\n \n return (\n <NativeMarkerView\n latitude={position.latitude}\n longitude={position.longitude}\n iconWidth={finalIconWidth}\n iconHeight={finalIconHeight}\n customViewWidth={finalIconWidth}\n customViewHeight={finalIconHeight}\n {...restProps}\n >\n {children}\n </NativeMarkerView>\n );\n}\n\n/**\n * 🔑 性能优化:极简比较函数\n * 只检查最常变化的关键属性,减少 JS 线程开销\n */\nfunction arePropsEqual(prevProps: MarkerProps, nextProps: MarkerProps): boolean {\n // 快速路径:比较 position (最常变化)\n if (\n prevProps.position.latitude !== nextProps.position.latitude ||\n prevProps.position.longitude !== nextProps.position.longitude\n ) {\n return false;\n }\n \n // 比较 cacheKey (如果提供了 cacheKey,其他属性理论上不会变)\n if (prevProps.cacheKey !== nextProps.cacheKey) {\n return false;\n }\n \n // 比较 children (如果有 children)\n if (prevProps.children !== nextProps.children) {\n return false;\n }\n \n // 其他属性相同,不重新渲染\n return true;\n}\n\n// 导出优化后的组件\nexport default React.memo(Marker, arePropsEqual);"]}
1
+ {"version":3,"file":"Marker.js","sourceRoot":"","sources":["../../../src/components/overlays/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,MAAM,gBAAgB,GAAG,wBAAwB,CAAC,YAAY,CAAC,CAAC;AAEhE;;;;;;;;;GASG;AACH,SAAS,MAAM,CAAC,KAAkB;IAChC,mCAAmC;IACnC,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAE7G,qBAAqB;IACrB,6BAA6B;IAC7B,MAAM,WAAW,GAAG,CAAC,CAAC,QAAQ,CAAC;IAC/B,MAAM,cAAc,GAAG,WAAW;QAChC,CAAC,CAAC,CAAC,eAAe,IAAI,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC;QAClE,CAAC,CAAC,CAAC,SAAS,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAClD,MAAM,eAAe,GAAG,WAAW;QACjC,CAAC,CAAC,CAAC,gBAAgB,IAAI,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,CAAC,CAAC,CAAC,UAAU,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAErD,OAAO,CACL,CAAC,gBAAgB,CACf,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAC5B,SAAS,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAC9B,SAAS,CAAC,CAAC,cAAc,CAAC,CAC1B,UAAU,CAAC,CAAC,eAAe,CAAC,CAC5B,eAAe,CAAC,CAAC,cAAc,CAAC,CAChC,gBAAgB,CAAC,CAAC,eAAe,CAAC,CAClC,IAAI,SAAS,CAAC,CAEd;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,gBAAgB,CAAC,CACpB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,SAAsB,EAAE,SAAsB;IACnE,0BAA0B;IAC1B,IACE,SAAS,CAAC,QAAQ,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,CAAC,QAAQ;QAC3D,SAAS,CAAC,QAAQ,CAAC,SAAS,KAAK,SAAS,CAAC,QAAQ,CAAC,SAAS,EAC7D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,0CAA0C;IAC1C,IAAI,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6BAA6B;IAC7B,IAAI,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,eAAe;IACf,OAAO,IAAI,CAAC;AACd,CAAC;AAED,WAAW;AACX,eAAe,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { requireNativeViewManager } from 'expo-modules-core';\nimport type { MarkerProps } from '../../types';\n\nconst NativeMarkerView = requireNativeViewManager('MarkerView');\n\n/**\n * Marker 组件 - 完全声明式 API\n *\n * 支持:\n * - 自定义图标(icon)\n * - 自定义内容(children)\n * - 大头针样式(pinColor)\n * - 拖拽功能\n * - 所有事件回调\n */\nfunction Marker(props: MarkerProps) {\n // 从 props 中排除 position 属性,避免传递到原生层\n const { position, customViewWidth, customViewHeight, iconWidth, iconHeight, children, ...restProps } = props;\n \n // 🔑 性能优化:使用常量避免重复计算\n // 根据是否有 children 来决定使用哪个尺寸属性\n const hasChildren = !!children;\n const finalIconWidth = hasChildren\n ? (customViewWidth && customViewWidth > 0 ? customViewWidth : 200)\n : (iconWidth && iconWidth > 0 ? iconWidth : 40);\n const finalIconHeight = hasChildren\n ? (customViewHeight && customViewHeight > 0 ? customViewHeight : 40)\n : (iconHeight && iconHeight > 0 ? iconHeight : 40);\n \n return (\n <NativeMarkerView\n latitude={position.latitude}\n longitude={position.longitude}\n iconWidth={finalIconWidth}\n iconHeight={finalIconHeight}\n customViewWidth={finalIconWidth}\n customViewHeight={finalIconHeight}\n {...restProps}\n >\n {children}\n </NativeMarkerView>\n );\n}\n\n/**\n * 🔑 性能优化:极简比较函数\n * 只检查最常变化的关键属性,减少 JS 线程开销\n */\nfunction arePropsEqual(prevProps: MarkerProps, nextProps: MarkerProps): boolean {\n // 快速路径:比较 position (最常变化)\n if (\n prevProps.position.latitude !== nextProps.position.latitude ||\n prevProps.position.longitude !== nextProps.position.longitude\n ) {\n return false;\n }\n \n // 比较 cacheKey (如果提供了 cacheKey,其他属性理论上不会变)\n if (prevProps.cacheKey !== nextProps.cacheKey) {\n return false;\n }\n \n // 比较 children (如果有 children)\n if (prevProps.children !== nextProps.children) {\n return false;\n }\n \n // 其他属性相同,不重新渲染\n return true;\n}\n\n// 导出优化后的组件\nexport default React.memo(Marker, arePropsEqual);"]}
@@ -21,6 +21,48 @@ public class ExpoGaodeMapModule: Module {
21
21
  /// 隐私同意持久化 Key
22
22
  private static let privacyDefaultsKey = "expo_gaode_map_privacy_agreed"
23
23
 
24
+ // MARK: - 私有辅助方法
25
+
26
+ /**
27
+ * 尝试从 Info.plist 读取并设置 API Key
28
+ * @return 是否成功设置 API Key
29
+ */
30
+ private func trySetupApiKeyFromPlist() -> Bool {
31
+ if AMapServices.shared().apiKey == nil || AMapServices.shared().apiKey?.isEmpty == true {
32
+ if let plistKey = Bundle.main.infoDictionary?["AMapApiKey"] as? String, !plistKey.isEmpty {
33
+ AMapServices.shared().apiKey = plistKey
34
+ AMapServices.shared().enableHTTPS = true
35
+ print("✅ ExpoGaodeMap: 从 Info.plist 读取并设置 AMapApiKey 成功")
36
+ return true
37
+ } else {
38
+ print("⚠️ ExpoGaodeMap: Info.plist 未找到 AMapApiKey")
39
+ return false
40
+ }
41
+ }
42
+ return true // 已经设置过了
43
+ }
44
+
45
+ /**
46
+ * 尝试启动预加载(检查 API Key 后)
47
+ * @param delay 延迟时间(秒)
48
+ * @param poolSize 预加载池大小
49
+ */
50
+ private func tryStartPreload(delay: Double = 1.0, poolSize: Int = 1) {
51
+ if let apiKey = AMapServices.shared().apiKey, !apiKey.isEmpty {
52
+ DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
53
+ let status = MapPreloadManager.shared.getStatus()
54
+ let isPreloading = (status["isPreloading"] as? Bool) ?? false
55
+
56
+ if !MapPreloadManager.shared.hasPreloadedMapView() && !isPreloading {
57
+ print("🚀 ExpoGaodeMap: 自动启动地图预加载")
58
+ MapPreloadManager.shared.startPreload(poolSize: poolSize)
59
+ }
60
+ }
61
+ } else {
62
+ print("⚠️ ExpoGaodeMap: API Key 未设置,跳过自动预加载")
63
+ }
64
+ }
65
+
24
66
  public func definition() -> ModuleDefinition {
25
67
  Name("ExpoGaodeMap")
26
68
 
@@ -37,27 +79,9 @@ public class ExpoGaodeMapModule: Module {
37
79
  MAMapView.updatePrivacyAgree(AMapPrivacyAgreeStatus.didAgree)
38
80
  print("🔁 ExpoGaodeMap: 已从缓存恢复隐私同意状态: true")
39
81
 
40
- // 尝试从 Info.plist 读取并设置 API Key
41
- if AMapServices.shared().apiKey == nil || AMapServices.shared().apiKey?.isEmpty == true {
42
- if let plistKey = Bundle.main.infoDictionary?["AMapApiKey"] as? String, !plistKey.isEmpty {
43
- AMapServices.shared().apiKey = plistKey
44
- AMapServices.shared().enableHTTPS = true
45
- print("✅ ExpoGaodeMap: OnCreate 从 Info.plist 读取并设置 AMapApiKey 成功")
46
- } else {
47
- print("⚠️ ExpoGaodeMap: Info.plist 未找到 AMapApiKey,跳过自动预加载")
48
- }
49
- }
50
-
51
- // 🚀 自动启动预加载(延迟2秒,避免影响启动速度)
52
- // 只有在 API Key 已设置的情况下才启动预加载
53
- if let apiKey = AMapServices.shared().apiKey, !apiKey.isEmpty {
54
- DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
55
- print("🚀 ExpoGaodeMap: 自动启动地图预加载")
56
- MapPreloadManager.shared.startPreload(poolSize: 1)
57
- }
58
- } else {
59
- print("⚠️ ExpoGaodeMap: API Key 未设置,跳过自动预加载")
60
- }
82
+ // 尝试设置 API Key 并启动预加载(延迟2秒)
83
+ self.trySetupApiKeyFromPlist()
84
+ self.tryStartPreload(delay: 2.0, poolSize: 1)
61
85
  } else {
62
86
  print("ℹ️ ExpoGaodeMap: 未发现已同意记录,等待用户同意后再使用 SDK")
63
87
  }
@@ -80,33 +104,14 @@ public class ExpoGaodeMapModule: Module {
80
104
  MAMapView.updatePrivacyAgree(AMapPrivacyAgreeStatus.didAgree)
81
105
  print("✅ ExpoGaodeMap: 用户已同意隐私协议,可以使用 SDK(状态已持久化)")
82
106
 
83
- // 在用户同意后,如果尚未设置 API Key,则尝试从 Info.plist 读取并设置
84
- if AMapServices.shared().apiKey == nil || AMapServices.shared().apiKey?.isEmpty == true {
85
- if let plistKey = Bundle.main.infoDictionary?["AMapApiKey"] as? String, !plistKey.isEmpty {
86
- AMapServices.shared().apiKey = plistKey
87
- AMapServices.shared().enableHTTPS = true
88
- print("✅ ExpoGaodeMap: 从 Info.plist 读取并设置 AMapApiKey 成功")
89
- } else {
90
- print("⚠️ ExpoGaodeMap: Info.plist 未找到 AMapApiKey,后续需通过 initSDK 提供 iosKey")
91
- }
92
- }
93
-
94
- // 🚀 用户首次同意后,立即启动预加载
95
- DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
96
- let status = MapPreloadManager.shared.getStatus()
97
- let isPreloading = (status["isPreloading"] as? Bool) ?? false
98
-
99
- if !MapPreloadManager.shared.hasPreloadedMapView() && !isPreloading {
100
- print("🚀 ExpoGaodeMap: 用户同意隐私协议,自动启动预加载")
101
- MapPreloadManager.shared.startPreload(poolSize: 1)
102
- }
103
- }
107
+ // 尝试设置 API Key 并启动预加载(延迟1秒)
108
+ self.trySetupApiKeyFromPlist()
109
+ self.tryStartPreload(delay: 1.0, poolSize: 1)
104
110
  } else {
105
111
  MAMapView.updatePrivacyAgree(AMapPrivacyAgreeStatus.notAgree)
106
112
  print("⚠️ ExpoGaodeMap: 用户未同意隐私协议,SDK 功能将受限(状态已持久化)")
107
113
  }
108
114
  }
109
-
110
115
  // ==================== SDK 初始化 ====================
111
116
 
112
117
  /**
@@ -462,7 +467,7 @@ public class ExpoGaodeMapModule: Module {
462
467
  }
463
468
  }
464
469
 
465
- // MARK: - 私有方法
470
+ // MARK: - 定位管理器
466
471
 
467
472
  /**
468
473
  * 获取或创建定位管理器实例
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-gaode-map",
3
- "version": "2.2.8-next.0",
3
+ "version": "2.2.9-next.0",
4
4
  "description": "一个功能完整的高德地图 React Native 组件库,基于 Expo Modules 开发,提供地图显示、定位、覆盖物等功能。",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",