expo-gaode-map-navigation 2.0.12-next.0 → 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 +296 -7
- package/android/build.gradle +12 -4
- package/android/src/main/AndroidManifest.xml +10 -1
- package/android/src/main/cpp/cluster_jni.cpp +56 -0
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +49 -8
- 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/modules/SDKInitializer.kt +23 -17
- 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/overlays/MarkerView.kt +37 -25
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerViewModule.kt +6 -6
- package/android/src/main/java/expo/modules/gaodemap/map/search/ExpoGaodeMapSearchModule.kt +751 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/GeometryUtils.kt +103 -0
- package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNaviView.kt +1408 -394
- package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNaviViewModule.kt +121 -1
- package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNavigationModule.kt +14 -28
- package/android/src/main/java/expo/modules/gaodemap/navigation/listeners/IndependentRouteListener.kt +28 -3
- package/android/src/main/java/expo/modules/gaodemap/navigation/listeners/RouteCalculateListener.kt +2 -2
- package/android/src/main/java/expo/modules/gaodemap/navigation/managers/IndependentRouteManager.kt +114 -15
- package/android/src/main/java/expo/modules/gaodemap/navigation/routes/drive/DriveTruckRouteCalculator.kt +24 -35
- package/android/src/main/java/expo/modules/gaodemap/navigation/services/IndependentRouteService.kt +50 -36
- package/android/src/main/java/expo/modules/gaodemap/navigation/services/NavigationForegroundService.kt +661 -0
- package/android/src/main/java/expo/modules/gaodemap/navigation/utils/Converters.kt +21 -12
- package/android/src/main/res/drawable/ic_nav_notification_small.xml +10 -0
- package/android/src/main/res/drawable/landback_0.png +0 -0
- package/android/src/main/res/drawable/landback_1.png +0 -0
- package/android/src/main/res/drawable/landback_2.png +0 -0
- package/android/src/main/res/drawable/landback_3.png +0 -0
- package/android/src/main/res/drawable/landback_4.png +0 -0
- package/android/src/main/res/drawable/landback_5.png +0 -0
- package/android/src/main/res/drawable/landback_6.png +0 -0
- package/android/src/main/res/drawable/landback_7.png +0 -0
- package/android/src/main/res/drawable/landback_8.png +0 -0
- package/android/src/main/res/drawable/landback_9.png +0 -0
- package/android/src/main/res/drawable/landback_a.png +0 -0
- package/android/src/main/res/drawable/landback_b.png +0 -0
- package/android/src/main/res/drawable/landback_c.png +0 -0
- package/android/src/main/res/drawable/landback_d.png +0 -0
- package/android/src/main/res/drawable/landback_e.png +0 -0
- package/android/src/main/res/drawable/landback_f.png +0 -0
- package/android/src/main/res/drawable/landback_g.png +0 -0
- package/android/src/main/res/drawable/landback_h.png +0 -0
- package/android/src/main/res/drawable/landback_i.png +0 -0
- package/android/src/main/res/drawable/landback_j.png +0 -0
- package/android/src/main/res/drawable/landback_k.png +0 -0
- package/android/src/main/res/drawable/landback_l.png +0 -0
- package/android/src/main/res/drawable/landfront_0.png +0 -0
- package/android/src/main/res/drawable/landfront_00.png +0 -0
- package/android/src/main/res/drawable/landfront_1.png +0 -0
- package/android/src/main/res/drawable/landfront_11.png +0 -0
- package/android/src/main/res/drawable/landfront_20.png +0 -0
- package/android/src/main/res/drawable/landfront_21.png +0 -0
- package/android/src/main/res/drawable/landfront_22.png +0 -0
- package/android/src/main/res/drawable/landfront_3.png +0 -0
- package/android/src/main/res/drawable/landfront_33.png +0 -0
- package/android/src/main/res/drawable/landfront_40.png +0 -0
- package/android/src/main/res/drawable/landfront_43.png +0 -0
- package/android/src/main/res/drawable/landfront_44.png +0 -0
- package/android/src/main/res/drawable/landfront_5.png +0 -0
- package/android/src/main/res/drawable/landfront_55.png +0 -0
- package/android/src/main/res/drawable/landfront_61.png +0 -0
- package/android/src/main/res/drawable/landfront_63.png +0 -0
- package/android/src/main/res/drawable/landfront_66.png +0 -0
- package/android/src/main/res/drawable/landfront_70.png +0 -0
- package/android/src/main/res/drawable/landfront_71.png +0 -0
- package/android/src/main/res/drawable/landfront_73.png +0 -0
- package/android/src/main/res/drawable/landfront_77.png +0 -0
- package/android/src/main/res/drawable/landfront_8.png +0 -0
- package/android/src/main/res/drawable/landfront_88.png +0 -0
- package/android/src/main/res/drawable/landfront_90.png +0 -0
- package/android/src/main/res/drawable/landfront_95.png +0 -0
- package/android/src/main/res/drawable/landfront_99.png +0 -0
- package/android/src/main/res/drawable/landfront_a0.png +0 -0
- package/android/src/main/res/drawable/landfront_a8.png +0 -0
- package/android/src/main/res/drawable/landfront_aa.png +0 -0
- package/android/src/main/res/drawable/landfront_b1.png +0 -0
- package/android/src/main/res/drawable/landfront_b5.png +0 -0
- package/android/src/main/res/drawable/landfront_bb.png +0 -0
- package/android/src/main/res/drawable/landfront_c3.png +0 -0
- package/android/src/main/res/drawable/landfront_c8.png +0 -0
- package/android/src/main/res/drawable/landfront_cc.png +0 -0
- package/android/src/main/res/drawable/landfront_d.png +0 -0
- package/android/src/main/res/drawable/landfront_dd.png +0 -0
- package/android/src/main/res/drawable/landfront_e1.png +0 -0
- package/android/src/main/res/drawable/landfront_e5.png +0 -0
- package/android/src/main/res/drawable/landfront_ee.png +0 -0
- package/android/src/main/res/drawable/landfront_f0.png +0 -0
- package/android/src/main/res/drawable/landfront_f1.png +0 -0
- package/android/src/main/res/drawable/landfront_f5.png +0 -0
- package/android/src/main/res/drawable/landfront_ff.png +0 -0
- package/android/src/main/res/drawable/landfront_g3.png +0 -0
- package/android/src/main/res/drawable/landfront_g5.png +0 -0
- package/android/src/main/res/drawable/landfront_gg.png +0 -0
- package/android/src/main/res/drawable/landfront_h1.png +0 -0
- package/android/src/main/res/drawable/landfront_h3.png +0 -0
- package/android/src/main/res/drawable/landfront_h5.png +0 -0
- package/android/src/main/res/drawable/landfront_hh.png +0 -0
- package/android/src/main/res/drawable/landfront_i0.png +0 -0
- package/android/src/main/res/drawable/landfront_i3.png +0 -0
- package/android/src/main/res/drawable/landfront_i5.png +0 -0
- package/android/src/main/res/drawable/landfront_ii.png +0 -0
- package/android/src/main/res/drawable/landfront_j1.png +0 -0
- package/android/src/main/res/drawable/landfront_j8.png +0 -0
- package/android/src/main/res/drawable/landfront_jj.png +0 -0
- package/android/src/main/res/drawable/landfront_kk.png +0 -0
- package/android/src/main/res/drawable/landfront_ll.png +0 -0
- package/android/src/main/res/drawable/nav_notification_brand_icon.xml +16 -0
- package/android/src/main/res/drawable/navi_arrow_leftline.png +0 -0
- package/android/src/main/res/drawable/navi_lane_shape_bg_center.xml +5 -0
- package/android/src/main/res/drawable/navi_lane_shape_bg_left.xml +8 -0
- package/android/src/main/res/drawable/navi_lane_shape_bg_over.xml +6 -0
- package/android/src/main/res/drawable/navi_lane_shape_bg_right.xml +8 -0
- package/android/src/main/res/drawable-nodpi/nav_tracker_car.png +0 -0
- package/build/ExpoGaodeMapNaviView.d.ts +16 -0
- package/build/ExpoGaodeMapNaviView.d.ts.map +1 -1
- package/build/ExpoGaodeMapNaviView.js +74 -1
- package/build/ExpoGaodeMapNaviView.js.map +1 -1
- package/build/index.d.ts +56 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +452 -10
- package/build/index.js.map +1 -1
- package/build/map/ExpoGaodeMapModule.d.ts +15 -13
- package/build/map/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapModule.js +31 -39
- package/build/map/ExpoGaodeMapModule.js.map +1 -1
- 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/ExpoGaodeMapView.d.ts +3 -4
- package/build/map/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapView.js +28 -25
- package/build/map/ExpoGaodeMapView.js.map +1 -1
- package/build/map/components/overlays/Circle.d.ts.map +1 -1
- package/build/map/components/overlays/Circle.js +1 -30
- package/build/map/components/overlays/Circle.js.map +1 -1
- package/build/map/components/overlays/Cluster.d.ts.map +1 -1
- package/build/map/components/overlays/Cluster.js +1 -42
- package/build/map/components/overlays/Cluster.js.map +1 -1
- package/build/map/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/map/components/overlays/HeatMap.js +21 -21
- package/build/map/components/overlays/HeatMap.js.map +1 -1
- package/build/map/components/overlays/Marker.d.ts.map +1 -1
- package/build/map/components/overlays/Marker.js +76 -80
- package/build/map/components/overlays/Marker.js.map +1 -1
- package/build/map/components/overlays/Polygon.d.ts.map +1 -1
- package/build/map/components/overlays/Polygon.js +1 -25
- package/build/map/components/overlays/Polygon.js.map +1 -1
- package/build/map/components/overlays/Polyline.d.ts.map +1 -1
- package/build/map/components/overlays/Polyline.js +1 -31
- package/build/map/components/overlays/Polyline.js.map +1 -1
- package/build/map/index.d.ts +9 -2
- package/build/map/index.d.ts.map +1 -1
- package/build/map/index.js +9 -2
- 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/index.d.ts +2 -2
- package/build/map/types/index.d.ts.map +1 -1
- package/build/map/types/index.js.map +1 -1
- 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/types/native-module.types.d.ts +11 -12
- package/build/map/types/native-module.types.d.ts.map +1 -1
- package/build/map/types/native-module.types.js.map +1 -1
- package/build/map/types/overlays.types.d.ts +9 -14
- package/build/map/types/overlays.types.d.ts.map +1 -1
- package/build/map/types/overlays.types.js.map +1 -1
- package/build/map/types/route-playback.types.d.ts +16 -0
- package/build/map/types/route-playback.types.d.ts.map +1 -1
- package/build/map/types/route-playback.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/build/types/coordinates.types.d.ts +3 -0
- package/build/types/coordinates.types.d.ts.map +1 -1
- package/build/types/coordinates.types.js.map +1 -1
- package/build/types/independent.types.d.ts +111 -12
- package/build/types/independent.types.d.ts.map +1 -1
- package/build/types/independent.types.js.map +1 -1
- package/build/types/native-module.types.d.ts +1 -1
- package/build/types/native-module.types.js.map +1 -1
- package/build/types/naviview.types.d.ts +304 -14
- package/build/types/naviview.types.d.ts.map +1 -1
- package/build/types/naviview.types.js.map +1 -1
- package/build/types/route.types.d.ts +12 -2
- package/build/types/route.types.d.ts.map +1 -1
- package/build/types/route.types.js.map +1 -1
- package/expo-module.config.json +4 -2
- package/ios/ExpoGaodeMapNaviView.swift +2331 -201
- package/ios/ExpoGaodeMapNaviViewModule.swift +109 -1
- package/ios/ExpoGaodeMapNavigation.podspec +2 -1
- package/ios/ExpoGaodeMapNavigationModule.swift +7 -5
- package/ios/managers/IndependentRouteManager.swift +90 -26
- package/ios/map/ExpoGaodeMapModule.swift +72 -21
- package/ios/map/ExpoGaodeMapOfflineModule.swift +61 -0
- package/ios/map/ExpoGaodeMapSearchModule.swift +773 -0
- package/ios/map/ExpoGaodeMapView.swift +23 -5
- package/ios/map/GaodeMapPrivacyManager.swift +26 -18
- package/ios/map/cpp/GeometryEngine.cpp +112 -0
- package/ios/map/cpp/GeometryEngine.hpp +21 -0
- package/ios/map/modules/LocationManager.swift +37 -5
- package/ios/map/overlays/MarkerView.swift +11 -11
- package/ios/map/overlays/MarkerViewModule.swift +4 -4
- package/ios/map/overlays/PolylineView.swift +6 -12
- package/ios/map/utils/ClusterNative.h +8 -0
- package/ios/map/utils/ClusterNative.mm +27 -0
- package/ios/map/utils/PermissionManager.swift +115 -6
- package/ios/routes/drive/DriveTruckRouteCalculator.swift +165 -77
- package/ios/routes/walkride/WalkRideRouteCalculator.swift +127 -1
- package/ios/services/IndependentRouteService.swift +198 -39
- package/ios/services/NavigationLiveActivityAttributes.swift +48 -0
- package/ios/services/NavigationLiveActivityManager.swift +359 -0
- package/package.json +22 -7
- package/plugin/build/withGaodeMap.d.ts +8 -0
- package/plugin/build/withGaodeMap.js +60 -4
- package/scripts/check-expo-modules.js +68 -0
- package/shared/cpp/GeometryEngine.cpp +112 -0
- package/shared/cpp/GeometryEngine.hpp +21 -0
- package/widget-template/README.md +46 -0
- package/widget-template/ios/NavigationLiveActivityWidget.swift +367 -0
- package/android/src/main/java/expo/modules/gaodemap/navigation/managers/RouteCalculator.kt +0 -173
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapOfflineModule.js","sourceRoot":"","sources":["../../src/map/ExpoGaodeMapOfflineModule.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapOfflineModule.js","sourceRoot":"","sources":["../../src/map/ExpoGaodeMapOfflineModule.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAsLzD,IAAI,iBAAiB,GAAgC,IAAI,CAAC;AAE1D,SAAS,eAAe;IACtB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,mBAAmB,CAAuB,qBAAqB,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,mBAAmB,CAC1B,MAA4B,EAC5B,IAAiB;IAEjB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAgB,EAAE,IAAI,EAAE,MAAgB,CAAC,CAAC;IACpE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE,CAC3B,KAA2C,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,eAAe,IAAI,KAAK,CAAC,EAA0B,EAAE;IACnD,GAAG,CAAC,OAAO,EAAE,IAAI;QACf,OAAO,mBAAmB,CAAC,eAAe,EAAE,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CACF,CAAC,CAAC","sourcesContent":["/**\n * 高德地图离线地图原生模块\n */\n\nimport { NativeModule, requireNativeModule } from 'expo';\nimport type {\n OfflineMapInfo,\n OfflineMapDownloadConfig,\n OfflineMapStorageInfo,\n OfflineMapEvents,\n} from './types/offline.types';\n\n/**\n * 离线地图原生模块接口\n */\ndeclare class NaviMapOfflineModule extends NativeModule<OfflineMapEvents> {\n // ==================== 地图列表管理 ====================\n\n /**\n * 打开高德 3D 地图 SDK 官方离线地图 UI 组件(Android)。\n * 官方组件内置城市下载、暂停、更新、删除和城市搜索。\n */\n openOfflineMapUI(): Promise<void>;\n \n /**\n * 获取所有可下载的城市列表\n * @returns Promise<OfflineMapInfo[]> 城市列表\n */\n getAvailableCities(): Promise<OfflineMapInfo[]>;\n \n /**\n * 获取所有省份列表\n * @returns Promise<OfflineMapInfo[]> 省份列表\n */\n getAvailableProvinces(): Promise<OfflineMapInfo[]>;\n \n /**\n * 根据省份代码获取城市列表\n * @param provinceCode 省份代码\n * @returns Promise<OfflineMapInfo[]> 该省份下的城市列表\n */\n getCitiesByProvince(provinceCode: string): Promise<OfflineMapInfo[]>;\n \n /**\n * 获取已下载的地图列表\n * @returns Promise<OfflineMapInfo[]> 已下载的地图列表\n */\n getDownloadedMaps(): Promise<OfflineMapInfo[]>;\n \n // ==================== 下载管理 ====================\n \n /**\n * 开始下载离线地图\n * @param config 下载配置\n */\n startDownload(config: OfflineMapDownloadConfig): Promise<void>;\n \n /**\n * 暂停下载\n * @param cityCode 城市代码\n */\n pauseDownload(cityCode: string): Promise<void>;\n \n /**\n * 恢复下载\n * @param cityCode 城市代码\n */\n resumeDownload(cityCode: string): Promise<void>;\n \n /**\n * 取消下载\n * @param cityCode 城市代码\n */\n cancelDownload(cityCode: string): Promise<void>;\n \n /**\n * 删除离线地图\n * @param cityCode 城市代码\n */\n deleteMap(cityCode: string): Promise<void>;\n \n /**\n * 更新离线地图\n * @param cityCode 城市代码\n */\n updateMap(cityCode: string): Promise<void>;\n \n /**\n * 检查是否有可用更新\n * @param cityCode 城市代码\n * @returns Promise<boolean> 是否有更新\n */\n checkUpdate(cityCode: string): Promise<boolean>;\n \n // ==================== 状态查询 ====================\n \n /**\n * 检查地图是否已下载\n * @param cityCode 城市代码\n * @returns Promise<boolean> 是否已下载\n */\n isMapDownloaded(cityCode: string): Promise<boolean>;\n \n /**\n * 获取地图下载状态\n * @param cityCode 城市代码\n * @returns Promise<OfflineMapInfo> 地图信息\n */\n getMapStatus(cityCode: string): Promise<OfflineMapInfo>;\n \n /**\n * 获取所有下载任务的总进度\n * @returns Promise<number> 总进度 (0-100)\n */\n getTotalProgress(): Promise<number>;\n \n /**\n * 获取当前正在下载的城市列表\n * @returns Promise<string[]> 城市代码列表\n */\n getDownloadingCities(): Promise<string[]>;\n \n // ==================== 存储管理 ====================\n \n /**\n * 获取离线地图占用的存储空间(字节)\n * @returns Promise<number> 存储空间大小\n */\n getStorageSize(): Promise<number>;\n \n /**\n * 获取详细的存储信息\n * @returns Promise<OfflineMapStorageInfo> 存储信息\n */\n getStorageInfo(): Promise<OfflineMapStorageInfo>;\n \n /**\n * 清理所有离线地图\n */\n clearAllMaps(): Promise<void>;\n \n /**\n * 设置离线地图存储路径\n * @param path 存储路径\n */\n setStoragePath(path: string): void;\n \n /**\n * 获取离线地图存储路径\n * @returns Promise<string> 存储路径\n */\n getStoragePath(): Promise<string>;\n \n // ==================== 批量操作 ====================\n \n /**\n * 批量下载地图\n * @param cityCodes 城市代码列表\n * @param allowCellular 是否允许移动网络\n */\n batchDownload(cityCodes: string[], allowCellular?: boolean): Promise<void>;\n \n /**\n * 批量删除地图\n * @param cityCodes 城市代码列表\n */\n batchDelete(cityCodes: string[]): Promise<void>;\n \n /**\n * 批量更新地图\n * @param cityCodes 城市代码列表\n */\n batchUpdate(cityCodes: string[]): Promise<void>;\n \n /**\n * 暂停所有下载任务\n */\n pauseAllDownloads(): Promise<void>;\n \n /**\n * 恢复所有下载任务\n */\n resumeAllDownloads(): Promise<void>;\n\n}\n\nlet nativeModuleCache: NaviMapOfflineModule | null = null;\n\nfunction getNativeModule(): NaviMapOfflineModule {\n if (!nativeModuleCache) {\n nativeModuleCache = requireNativeModule<NaviMapOfflineModule>('ExpoGaodeMapOffline');\n }\n return nativeModuleCache;\n}\n\nfunction getBoundNativeValue(\n module: NaviMapOfflineModule,\n prop: PropertyKey\n): unknown {\n const value = Reflect.get(module as object, prop, module as object);\n if (typeof value === 'function') {\n return (...args: unknown[]) =>\n (value as (...fnArgs: unknown[]) => unknown).apply(module, args);\n }\n return value;\n}\n\nexport default new Proxy({} as NaviMapOfflineModule, {\n get(_target, prop) {\n return getBoundNativeValue(getNativeModule(), prop);\n },\n});\n"]}
|
|
@@ -9,13 +9,12 @@ export type { MapViewRef } from './types';
|
|
|
9
9
|
* @returns 返回包含地图视图和上下文提供者的React组件
|
|
10
10
|
*
|
|
11
11
|
* @remarks
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* - internalRef: 内部使用的API引用,通过MapContext共享
|
|
12
|
+
* 该组件内部维护 nativeRef,用于将 JS ref API 转发到原生地图视图。
|
|
13
|
+
* MapContext 会向子组件共享同一组地图 API 方法。
|
|
15
14
|
*
|
|
16
15
|
* 提供的主要API功能包括:
|
|
17
16
|
* - 相机控制(移动、缩放、获取当前位置)
|
|
18
|
-
* -
|
|
17
|
+
* - 屏幕坐标转换、截图、根据坐标集合拟合相机
|
|
19
18
|
*
|
|
20
19
|
* 所有API方法都会检查地图是否已初始化,未初始化时抛出错误
|
|
21
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapView.d.ts","sourceRoot":"","sources":["../../src/map/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAMX,MAAM,SAAS,CAAC;AAUjB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapView.d.ts","sourceRoot":"","sources":["../../src/map/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAMX,MAAM,SAAS,CAAC;AAUjB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA8B1C;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,gBAAgB,iFA6KpB,CAAC;AAIH,eAAe,gBAAgB,CAAC"}
|
|
@@ -14,6 +14,20 @@ function estimateZoom(latitudeDelta, longitudeDelta, options) {
|
|
|
14
14
|
const rawZoom = Math.log2(360 / span);
|
|
15
15
|
return Math.max(options?.minZoom ?? MIN_ZOOM, Math.min(options?.maxZoom ?? MAX_ZOOM, Number(rawZoom.toFixed(2))));
|
|
16
16
|
}
|
|
17
|
+
function splitMapChildren(children) {
|
|
18
|
+
const overlays = [];
|
|
19
|
+
const uiControls = [];
|
|
20
|
+
React.Children.forEach(children, (child) => {
|
|
21
|
+
if (React.isValidElement(child) &&
|
|
22
|
+
(child.type === MapUI || child.type?.isMapUI)) {
|
|
23
|
+
uiControls.push(child);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
overlays.push(child);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return { overlays, uiControls };
|
|
30
|
+
}
|
|
17
31
|
/**
|
|
18
32
|
* 高德地图视图组件,提供地图操作API和覆盖物管理功能
|
|
19
33
|
*
|
|
@@ -22,13 +36,12 @@ function estimateZoom(latitudeDelta, longitudeDelta, options) {
|
|
|
22
36
|
* @returns 返回包含地图视图和上下文提供者的React组件
|
|
23
37
|
*
|
|
24
38
|
* @remarks
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* - internalRef: 内部使用的API引用,通过MapContext共享
|
|
39
|
+
* 该组件内部维护 nativeRef,用于将 JS ref API 转发到原生地图视图。
|
|
40
|
+
* MapContext 会向子组件共享同一组地图 API 方法。
|
|
28
41
|
*
|
|
29
42
|
* 提供的主要API功能包括:
|
|
30
43
|
* - 相机控制(移动、缩放、获取当前位置)
|
|
31
|
-
* -
|
|
44
|
+
* - 屏幕坐标转换、截图、根据坐标集合拟合相机
|
|
32
45
|
*
|
|
33
46
|
* 所有API方法都会检查地图是否已初始化,未初始化时抛出错误
|
|
34
47
|
*/
|
|
@@ -38,7 +51,6 @@ const ExpoGaodeMapView = React.forwardRef((props, ref) => {
|
|
|
38
51
|
throw ErrorHandler.privacyNotAgreed('map');
|
|
39
52
|
}
|
|
40
53
|
const nativeRef = React.useRef(null);
|
|
41
|
-
const internalRef = React.useRef(null);
|
|
42
54
|
const NativeView = React.useMemo(() => getNativeView(), []);
|
|
43
55
|
const callNativeMethod = React.useCallback((methodName, ...args) => {
|
|
44
56
|
if (!nativeRef.current) {
|
|
@@ -51,8 +63,7 @@ const ExpoGaodeMapView = React.forwardRef((props, ref) => {
|
|
|
51
63
|
return nativeMethod.apply(nativeRef.current, args);
|
|
52
64
|
}, []);
|
|
53
65
|
/**
|
|
54
|
-
*
|
|
55
|
-
* 统一处理初始化检查和错误处理,减少重复代码
|
|
66
|
+
* 通用 API 方法包装器,统一处理初始化检查和错误包装。
|
|
56
67
|
*/
|
|
57
68
|
const createApiMethod = React.useCallback((methodName) => {
|
|
58
69
|
return ((...args) => {
|
|
@@ -138,13 +149,6 @@ const ExpoGaodeMapView = React.forwardRef((props, ref) => {
|
|
|
138
149
|
}
|
|
139
150
|
},
|
|
140
151
|
}), [callNativeMethod, createApiMethod]);
|
|
141
|
-
/**
|
|
142
|
-
* 将传入的apiRef赋值给internalRef.current
|
|
143
|
-
* 用于在组件内部保存对地图API实例的引用
|
|
144
|
-
*/
|
|
145
|
-
React.useEffect(() => {
|
|
146
|
-
internalRef.current = apiRef;
|
|
147
|
-
}, [apiRef]);
|
|
148
152
|
/**
|
|
149
153
|
* 获取当前地图实例的API引用
|
|
150
154
|
* @returns 返回地图API的引用对象,可用于调用地图相关方法
|
|
@@ -152,18 +156,10 @@ const ExpoGaodeMapView = React.forwardRef((props, ref) => {
|
|
|
152
156
|
React.useImperativeHandle(ref, () => apiRef, [apiRef]);
|
|
153
157
|
// 分离 children:区分原生覆盖物和普通 UI 组件
|
|
154
158
|
const { children, style, ...otherProps } = props;
|
|
155
|
-
const overlays = [];
|
|
156
|
-
const
|
|
157
|
-
React.Children.forEach(children, (child) => {
|
|
158
|
-
if (React.isValidElement(child) && (child.type === MapUI || child.type?.isMapUI)) {
|
|
159
|
-
uiControls.push(child);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
overlays.push(child);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
159
|
+
const { overlays, uiControls } = React.useMemo(() => splitMapChildren(children), [children]);
|
|
160
|
+
const containerStyle = React.useMemo(() => [styles.container, style], [style]);
|
|
165
161
|
return (<MapContext.Provider value={apiRef}>
|
|
166
|
-
<View style={
|
|
162
|
+
<View style={containerStyle}>
|
|
167
163
|
<NativeView ref={nativeRef} style={StyleSheet.absoluteFill} {...otherProps}>
|
|
168
164
|
{overlays}
|
|
169
165
|
</NativeView>
|
|
@@ -173,4 +169,11 @@ const ExpoGaodeMapView = React.forwardRef((props, ref) => {
|
|
|
173
169
|
});
|
|
174
170
|
ExpoGaodeMapView.displayName = 'ExpoGaodeMapView';
|
|
175
171
|
export default ExpoGaodeMapView;
|
|
172
|
+
const styles = StyleSheet.create({
|
|
173
|
+
container: {
|
|
174
|
+
flex: 1,
|
|
175
|
+
position: 'relative',
|
|
176
|
+
overflow: 'hidden',
|
|
177
|
+
},
|
|
178
|
+
});
|
|
176
179
|
//# sourceMappingURL=ExpoGaodeMapView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../../src/map/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B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AU,EAAE,GAAG,KAAK,CAAC;IACjD,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,MAAM,UAAU,GAAsB,EAAE,CAAC;IAEzC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;QACzC,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,IAAK,KAAK,CAAC,IAA8B,EAAE,OAAO,CAAC,EAAE,CAAC;YAC5G,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CACjC;MAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAC,CAC3E;QAAA,CAAC,UAAU,CACT,GAAG,CAAC,CAAC,SAAS,CAAC,CACf,KAAK,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAC/B,IAAI,UAAU,CAAC,CAEf;UAAA,CAAC,QAAQ,CACX;QAAA,EAAE,UAAU,CACZ;QAAA,CAAC,UAAU,CACb;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,UAAU,CAAC,QAAQ,CAAC,CACvB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAElD,eAAe,gBAAgB,CAAC","sourcesContent":["import * as React from 'react';\n\nimport type {\n MapViewProps,\n MapViewRef,\n CameraPosition,\n CameraUpdate,\n LatLng,\n Point,\n LatLngPoint,\n} from './types';\nimport ExpoGaodeMapModule from './ExpoGaodeMapModule';\nimport { normalizeLatLng } from './utils/GeoUtils';\nimport { ErrorHandler } from './utils/ErrorHandler';\nimport { MapContext } from './components/MapContext';\nimport { MapUI } from './components/MapUI';\nimport { createLazyNativeViewManager } from './utils/lazyNativeViewManager';\nimport { View, StyleSheet } from 'react-native';\nimport type { FitToCoordinatesOptions } from './types/route-playback.types';\n\nexport type { MapViewRef } from './types';\n\nconst getNativeView = createLazyNativeViewManager<MapViewProps & { ref?: React.Ref<MapViewRef> }>('ExpoGaodeMapView');\nconst MIN_ZOOM = 3;\nconst MAX_ZOOM = 20;\n\nfunction estimateZoom(latitudeDelta: number, longitudeDelta: number, options?: FitToCoordinatesOptions) {\n const span = Math.max(latitudeDelta, longitudeDelta, 0.0001);\n const rawZoom = Math.log2(360 / span);\n return Math.max(options?.minZoom ?? MIN_ZOOM, Math.min(options?.maxZoom ?? MAX_ZOOM, Number(rawZoom.toFixed(2))));\n}\n\n\n/**\n * 高德地图视图组件,提供地图操作API和覆盖物管理功能\n * \n * @param props - 组件属性\n * @param ref - 外部ref引用,用于访问地图API方法\n * @returns 返回包含地图视图和上下文提供者的React组件\n * \n * @remarks\n * 该组件内部维护两个ref:\n * - nativeRef: 指向原生地图视图的引用\n * - internalRef: 内部使用的API引用,通过MapContext共享\n * \n * 提供的主要API功能包括:\n * - 相机控制(移动、缩放、获取当前位置)\n * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)\n * \n * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const privacyStatus = ExpoGaodeMapModule.getPrivacyStatus();\n if (!privacyStatus.isReady) {\n throw ErrorHandler.privacyNotAgreed('map');\n }\n\n const nativeRef = React.useRef<MapViewRef>(null);\n const internalRef = React.useRef<MapViewRef | null>(null);\n const NativeView = React.useMemo(() => getNativeView(), []);\n\n const callNativeMethod = React.useCallback(<T extends (...args: never[]) => unknown>(\n methodName: keyof MapViewRef,\n ...args: Parameters<T>\n ) => {\n if (!nativeRef.current) {\n throw ErrorHandler.mapViewNotInitialized(methodName as string);\n }\n\n const nativeMethod = Reflect.get(\n nativeRef.current as object,\n methodName,\n nativeRef.current as object\n );\n\n if (typeof nativeMethod !== 'function') {\n throw new Error(`Method '${methodName}' is not available on native view. Make sure the native module is linked and rebuilt.`);\n }\n\n return (nativeMethod as (...methodArgs: Parameters<T>) => ReturnType<T>).apply(\n nativeRef.current,\n args\n );\n }, []);\n \n /**\n * 🔑 性能优化:通用 API 方法包装器\n * 统一处理初始化检查和错误处理,减少重复代码\n */\n const createApiMethod = React.useCallback(<T extends (...args: never[]) => unknown>(\n methodName: keyof MapViewRef\n ) => {\n return ((...args: Parameters<T>) => {\n try {\n return callNativeMethod<T>(methodName, ...args);\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, methodName as string);\n }\n }) as T;\n }, [callNativeMethod]);\n\n /**\n * 使用通用包装器创建所有 API 方法\n * 所有方法共享相同的错误处理逻辑\n */\n const apiRef: MapViewRef = React.useMemo(() => ({\n moveCamera: (position: CameraUpdate, duration?: number) => {\n try {\n const normalizedPosition = {\n ...position,\n target: position.target ? normalizeLatLng(position.target) : undefined,\n };\n return callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n normalizedPosition,\n duration ?? 0\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'moveCamera');\n }\n },\n getLatLng: createApiMethod<(point: Point) => Promise<LatLng>>('getLatLng'),\n setCenter: (center: LatLngPoint, animated?: boolean) => {\n try {\n return callNativeMethod<(normalizedCenter: LatLng, animatedFlag: boolean) => Promise<void>>(\n 'setCenter',\n normalizeLatLng(center),\n animated ?? false\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'setCenter');\n }\n },\n setZoom: (zoom: number, animated?: boolean) => {\n try {\n return callNativeMethod<(zoomLevel: number, animatedFlag: boolean) => Promise<void>>(\n 'setZoom',\n zoom,\n animated ?? false\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'setZoom');\n }\n },\n getCameraPosition: createApiMethod<() => Promise<CameraPosition>>('getCameraPosition'),\n takeSnapshot: createApiMethod<() => Promise<string>>('takeSnapshot'),\n fitToCoordinates: async (points: LatLngPoint[], options?: FitToCoordinatesOptions) => {\n try {\n const normalized = points.map((point) => normalizeLatLng(point));\n if (normalized.length === 0) {\n return;\n }\n\n const currentCamera = await callNativeMethod<() => Promise<CameraPosition>>('getCameraPosition');\n if (normalized.length === 1) {\n await callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n {\n target: normalized[0],\n zoom: options?.singlePointZoom ?? currentCamera.zoom ?? 16,\n bearing: options?.preserveBearing === false ? options?.bearing : currentCamera.bearing ?? options?.bearing,\n tilt: options?.preserveTilt === false ? options?.tilt : currentCamera.tilt ?? options?.tilt,\n },\n options?.duration ?? 0\n );\n return;\n }\n\n const latitudes = normalized.map((point) => point.latitude);\n const longitudes = normalized.map((point) => point.longitude);\n const paddingFactor = options?.paddingFactor ?? 1.2;\n const north = Math.max(...latitudes);\n const south = Math.min(...latitudes);\n const east = Math.max(...longitudes);\n const west = Math.min(...longitudes);\n\n await callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n {\n target: {\n latitude: (north + south) / 2,\n longitude: (east + west) / 2,\n },\n zoom: estimateZoom((north - south) * paddingFactor, (east - west) * paddingFactor, options),\n bearing: options?.preserveBearing === false ? options?.bearing : currentCamera.bearing ?? options?.bearing,\n tilt: options?.preserveTilt === false ? options?.tilt : currentCamera.tilt ?? options?.tilt,\n },\n options?.duration ?? 0\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'fitToCoordinates');\n }\n },\n }), [callNativeMethod, createApiMethod]);\n\n /**\n * 将传入的apiRef赋值给internalRef.current\n * 用于在组件内部保存对地图API实例的引用\n */\n React.useEffect(() => {\n internalRef.current = apiRef;\n }, [apiRef]);\n\n /**\n * 获取当前地图实例的API引用\n * @returns 返回地图API的引用对象,可用于调用地图相关方法\n */\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n // 分离 children:区分原生覆盖物和普通 UI 组件\n const { children, style, ...otherProps } = props;\n const overlays: React.ReactNode[] = [];\n const uiControls: React.ReactNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child) && (child.type === MapUI || (child.type as { isMapUI?: boolean })?.isMapUI)) {\n uiControls.push(child);\n } else {\n overlays.push(child);\n }\n });\n\n return (\n <MapContext.Provider value={apiRef}>\n <View style={[{ flex: 1, position: 'relative', overflow: 'hidden' ,}, style]}>\n <NativeView\n ref={nativeRef}\n style={StyleSheet.absoluteFill}\n {...otherProps}\n >\n {overlays}\n </NativeView>\n {uiControls}\n </View>\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../../src/map/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAKhD,MAAM,aAAa,GAAG,2BAA2B,CAAiD,kBAAkB,CAAC,CAAC;AACtH,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,QA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ate,\n LatLng,\n Point,\n LatLngPoint,\n} from './types';\nimport ExpoGaodeMapModule from './ExpoGaodeMapModule';\nimport { normalizeLatLng } from './utils/GeoUtils';\nimport { ErrorHandler } from './utils/ErrorHandler';\nimport { MapContext } from './components/MapContext';\nimport { MapUI } from './components/MapUI';\nimport { createLazyNativeViewManager } from './utils/lazyNativeViewManager';\nimport { View, StyleSheet } from 'react-native';\nimport type { FitToCoordinatesOptions } from './types/route-playback.types';\n\nexport type { MapViewRef } from './types';\n\nconst getNativeView = createLazyNativeViewManager<MapViewProps & { ref?: React.Ref<MapViewRef> }>('ExpoGaodeMapView');\nconst MIN_ZOOM = 3;\nconst MAX_ZOOM = 20;\n\nfunction estimateZoom(latitudeDelta: number, longitudeDelta: number, options?: FitToCoordinatesOptions) {\n const span = Math.max(latitudeDelta, longitudeDelta, 0.0001);\n const rawZoom = Math.log2(360 / span);\n return Math.max(options?.minZoom ?? MIN_ZOOM, Math.min(options?.maxZoom ?? MAX_ZOOM, Number(rawZoom.toFixed(2))));\n}\n\nfunction splitMapChildren(children: React.ReactNode) {\n const overlays: React.ReactNode[] = [];\n const uiControls: React.ReactNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (\n React.isValidElement(child) &&\n (child.type === MapUI || (child.type as { isMapUI?: boolean })?.isMapUI)\n ) {\n uiControls.push(child);\n } else {\n overlays.push(child);\n }\n });\n\n return { overlays, uiControls };\n}\n\n/**\n * 高德地图视图组件,提供地图操作API和覆盖物管理功能\n * \n * @param props - 组件属性\n * @param ref - 外部ref引用,用于访问地图API方法\n * @returns 返回包含地图视图和上下文提供者的React组件\n * \n * @remarks\n * 该组件内部维护 nativeRef,用于将 JS ref API 转发到原生地图视图。\n * MapContext 会向子组件共享同一组地图 API 方法。\n * \n * 提供的主要API功能包括:\n * - 相机控制(移动、缩放、获取当前位置)\n * - 屏幕坐标转换、截图、根据坐标集合拟合相机\n * \n * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const privacyStatus = ExpoGaodeMapModule.getPrivacyStatus();\n if (!privacyStatus.isReady) {\n throw ErrorHandler.privacyNotAgreed('map');\n }\n\n const nativeRef = React.useRef<MapViewRef>(null);\n const NativeView = React.useMemo(() => getNativeView(), []);\n\n const callNativeMethod = React.useCallback(<T extends (...args: never[]) => unknown>(\n methodName: keyof MapViewRef,\n ...args: Parameters<T>\n ) => {\n if (!nativeRef.current) {\n throw ErrorHandler.mapViewNotInitialized(methodName as string);\n }\n\n const nativeMethod = Reflect.get(\n nativeRef.current as object,\n methodName,\n nativeRef.current as object\n );\n\n if (typeof nativeMethod !== 'function') {\n throw new Error(`Method '${methodName}' is not available on native view. Make sure the native module is linked and rebuilt.`);\n }\n\n return (nativeMethod as (...methodArgs: Parameters<T>) => ReturnType<T>).apply(\n nativeRef.current,\n args\n );\n }, []);\n \n /**\n * 通用 API 方法包装器,统一处理初始化检查和错误包装。\n */\n const createApiMethod = React.useCallback(<T extends (...args: never[]) => unknown>(\n methodName: keyof MapViewRef\n ) => {\n return ((...args: Parameters<T>) => {\n try {\n return callNativeMethod<T>(methodName, ...args);\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, methodName as string);\n }\n }) as T;\n }, [callNativeMethod]);\n\n /**\n * 使用通用包装器创建所有 API 方法\n * 所有方法共享相同的错误处理逻辑\n */\n const apiRef: MapViewRef = React.useMemo(() => ({\n moveCamera: (position: CameraUpdate, duration?: number) => {\n try {\n const normalizedPosition = {\n ...position,\n target: position.target ? normalizeLatLng(position.target) : undefined,\n };\n return callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n normalizedPosition,\n duration ?? 0\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'moveCamera');\n }\n },\n getLatLng: createApiMethod<(point: Point) => Promise<LatLng>>('getLatLng'),\n setCenter: (center: LatLngPoint, animated?: boolean) => {\n try {\n return callNativeMethod<(normalizedCenter: LatLng, animatedFlag: boolean) => Promise<void>>(\n 'setCenter',\n normalizeLatLng(center),\n animated ?? false\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'setCenter');\n }\n },\n setZoom: (zoom: number, animated?: boolean) => {\n try {\n return callNativeMethod<(zoomLevel: number, animatedFlag: boolean) => Promise<void>>(\n 'setZoom',\n zoom,\n animated ?? false\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'setZoom');\n }\n },\n getCameraPosition: createApiMethod<() => Promise<CameraPosition>>('getCameraPosition'),\n takeSnapshot: createApiMethod<() => Promise<string>>('takeSnapshot'),\n fitToCoordinates: async (points: LatLngPoint[], options?: FitToCoordinatesOptions) => {\n try {\n const normalized = points.map((point) => normalizeLatLng(point));\n if (normalized.length === 0) {\n return;\n }\n\n const currentCamera = await callNativeMethod<() => Promise<CameraPosition>>('getCameraPosition');\n if (normalized.length === 1) {\n await callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n {\n target: normalized[0],\n zoom: options?.singlePointZoom ?? currentCamera.zoom ?? 16,\n bearing: options?.preserveBearing === false ? options?.bearing : currentCamera.bearing ?? options?.bearing,\n tilt: options?.preserveTilt === false ? options?.tilt : currentCamera.tilt ?? options?.tilt,\n },\n options?.duration ?? 0\n );\n return;\n }\n\n const latitudes = normalized.map((point) => point.latitude);\n const longitudes = normalized.map((point) => point.longitude);\n const paddingFactor = options?.paddingFactor ?? 1.2;\n const north = Math.max(...latitudes);\n const south = Math.min(...latitudes);\n const east = Math.max(...longitudes);\n const west = Math.min(...longitudes);\n\n await callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n {\n target: {\n latitude: (north + south) / 2,\n longitude: (east + west) / 2,\n },\n zoom: estimateZoom((north - south) * paddingFactor, (east - west) * paddingFactor, options),\n bearing: options?.preserveBearing === false ? options?.bearing : currentCamera.bearing ?? options?.bearing,\n tilt: options?.preserveTilt === false ? options?.tilt : currentCamera.tilt ?? options?.tilt,\n },\n options?.duration ?? 0\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'fitToCoordinates');\n }\n },\n }), [callNativeMethod, createApiMethod]);\n\n /**\n * 获取当前地图实例的API引用\n * @returns 返回地图API的引用对象,可用于调用地图相关方法\n */\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n // 分离 children:区分原生覆盖物和普通 UI 组件\n const { children, style, ...otherProps } = props;\n const { overlays, uiControls } = React.useMemo(\n () => splitMapChildren(children),\n [children]\n );\n const containerStyle = React.useMemo(\n () => [styles.container, style],\n [style]\n );\n\n return (\n <MapContext.Provider value={apiRef}>\n <View style={containerStyle}>\n <NativeView\n ref={nativeRef}\n style={StyleSheet.absoluteFill}\n {...otherProps}\n >\n {overlays}\n </NativeView>\n {uiControls}\n </View>\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n position: 'relative',\n overflow: 'hidden',\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../../src/map/components/overlays/Circle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C;;;;;;GAMG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,qBAWjC;;
|
|
1
|
+
{"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../../src/map/components/overlays/Circle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C;;;;;;GAMG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,qBAWjC;;AAED,wBAAkC"}
|
|
@@ -15,34 +15,5 @@ function Circle(props) {
|
|
|
15
15
|
const normalizedCenter = normalizeLatLng(center);
|
|
16
16
|
return (<NativeCircleView center={normalizedCenter} {...restProps}/>);
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
* 🔑 性能优化:浅比较关键属性
|
|
20
|
-
*/
|
|
21
|
-
function arePropsEqual(prevProps, nextProps) {
|
|
22
|
-
// 比较中心点坐标
|
|
23
|
-
const prevCenter = normalizeLatLng(prevProps.center);
|
|
24
|
-
const nextCenter = normalizeLatLng(nextProps.center);
|
|
25
|
-
if (prevCenter.latitude !== nextCenter.latitude ||
|
|
26
|
-
prevCenter.longitude !== nextCenter.longitude) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
// 比较半径
|
|
30
|
-
if (prevProps.radius !== nextProps.radius) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
// 比较样式属性
|
|
34
|
-
if (prevProps.strokeWidth !== nextProps.strokeWidth ||
|
|
35
|
-
prevProps.strokeColor !== nextProps.strokeColor ||
|
|
36
|
-
prevProps.fillColor !== nextProps.fillColor ||
|
|
37
|
-
prevProps.zIndex !== nextProps.zIndex) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
// 比较回调
|
|
41
|
-
if (prevProps.onCirclePress !== nextProps.onCirclePress) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
// 导出优化后的组件
|
|
47
|
-
export default React.memo(Circle, arePropsEqual);
|
|
18
|
+
export default React.memo(Circle);
|
|
48
19
|
//# sourceMappingURL=Circle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.js","sourceRoot":"","sources":["../../../../src/map/components/overlays/Circle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MA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AAED,eAAe,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport type { CircleProps } from '../../types';\nimport { normalizeLatLng } from '../../utils/GeoUtils';\nimport { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';\n\nconst getNativeCircleView = createLazyNativeViewManager<CircleProps>('CircleView');\n\n/**\n * 高德地图圆形覆盖物组件(声明式)\n *\n *\n * @param props 圆形组件的属性配置\n * @returns 渲染原生圆形组件\n */\nfunction Circle(props: CircleProps) {\n const NativeCircleView = React.useMemo(() => getNativeCircleView(), []);\n const { center, ...restProps } = props;\n const normalizedCenter = normalizeLatLng(center);\n \n return (\n <NativeCircleView \n center={normalizedCenter}\n {...restProps} \n />\n );\n}\n\nexport default React.memo(Circle);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cluster.d.ts","sourceRoot":"","sources":["../../../../src/map/components/overlays/Cluster.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,KAAK,EAAE,YAAY,qBAGnC;;
|
|
1
|
+
{"version":3,"file":"Cluster.d.ts","sourceRoot":"","sources":["../../../../src/map/components/overlays/Cluster.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,KAAK,EAAE,YAAY,qBAGnC;;AAED,wBAAmC"}
|
|
@@ -11,46 +11,5 @@ function Cluster(props) {
|
|
|
11
11
|
const NativeCluster = React.useMemo(() => getNativeCluster(), []);
|
|
12
12
|
return <NativeCluster {...props}/>;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
* 🔑 性能优化:浅比较关键属性
|
|
16
|
-
* 只检查最常变化的属性,避免深度比较开销
|
|
17
|
-
*/
|
|
18
|
-
function arePropsEqual(prevProps, nextProps) {
|
|
19
|
-
// 比较 points 数组引用(最常变化)
|
|
20
|
-
if (prevProps.points !== nextProps.points) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
// 比较 radius
|
|
24
|
-
if (prevProps.radius !== nextProps.radius) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
// 比较基础图标
|
|
28
|
-
if (prevProps.icon !== nextProps.icon) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
// 比较 minClusterSize
|
|
32
|
-
if (prevProps.minClusterSize !== nextProps.minClusterSize) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
// 比较聚合样式
|
|
36
|
-
if (prevProps.clusterStyle !== nextProps.clusterStyle) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
// 比较聚合文本样式
|
|
40
|
-
if (prevProps.clusterTextStyle !== nextProps.clusterTextStyle) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
// 比较 clusterBuckets
|
|
44
|
-
if (prevProps.clusterBuckets !== nextProps.clusterBuckets) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
// 比较 onClusterPress 回调
|
|
48
|
-
if (prevProps.onClusterPress !== nextProps.onClusterPress) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
// 其他属性相同,不重新渲染
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
// 导出优化后的组件
|
|
55
|
-
export default React.memo(Cluster, arePropsEqual);
|
|
14
|
+
export default React.memo(Cluster);
|
|
56
15
|
//# sourceMappingURL=Cluster.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cluster.js","sourceRoot":"","sources":["../../../../src/map/components/overlays/Cluster.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,MAAM,gBAAgB,GAAG,2BAA2B,CAAe,aAAa,CAAC,CAAC;AAElF;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAmB;IAClC,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;IAClE,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACtC,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"Cluster.js","sourceRoot":"","sources":["../../../../src/map/components/overlays/Cluster.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,MAAM,gBAAgB,GAAG,2BAA2B,CAAe,aAAa,CAAC,CAAC;AAElF;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAmB;IAClC,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;IAClE,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACtC,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ClusterProps } from '../../types';\nimport { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';\n\nconst getNativeCluster = createLazyNativeViewManager<ClusterProps>('ClusterView');\n\n/**\n * 高德地图点聚合组件\n *\n * @param props 点聚合组件的属性配置\n * @returns 渲染原生点聚合组件\n */\nfunction Cluster(props: ClusterProps) {\n const NativeCluster = React.useMemo(() => getNativeCluster(), []);\n return <NativeCluster {...props} />;\n}\n\nexport default React.memo(Cluster);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeatMap.d.ts","sourceRoot":"","sources":["../../../../src/map/components/overlays/HeatMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"HeatMap.d.ts","sourceRoot":"","sources":["../../../../src/map/components/overlays/HeatMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAmBhD;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,KAAK,EAAE,YAAY,qBAcnC;;AA+BD,wBAAmC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { StyleSheet } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { normalizeLatLng } from '../../utils/GeoUtils';
|
|
4
4
|
import { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';
|
|
5
5
|
const getNativeHeatMap = createLazyNativeViewManager('HeatMapView');
|
|
6
6
|
/**
|
|
@@ -12,7 +12,7 @@ const getNativeHeatMap = createLazyNativeViewManager('HeatMapView');
|
|
|
12
12
|
function HeatMap(props) {
|
|
13
13
|
const NativeHeatMap = React.useMemo(() => getNativeHeatMap(), []);
|
|
14
14
|
const { data, ...restProps } = props;
|
|
15
|
-
const normalizedData =
|
|
15
|
+
const normalizedData = React.useMemo(() => normalizeHeatMapData(data), [data]);
|
|
16
16
|
return (<NativeHeatMap data={normalizedData} {...restProps} collapsable={false} pointerEvents="none" style={styles.hidden}/>);
|
|
17
17
|
}
|
|
18
18
|
const styles = StyleSheet.create({
|
|
@@ -22,24 +22,24 @@ const styles = StyleSheet.create({
|
|
|
22
22
|
backgroundColor: 'transparent',
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
function normalizeHeatMapData(data) {
|
|
26
|
+
return data.map((point) => {
|
|
27
|
+
const normalized = normalizeLatLng(point);
|
|
28
|
+
if (Array.isArray(point)) {
|
|
29
|
+
return {
|
|
30
|
+
...normalized,
|
|
31
|
+
intensity: typeof point[2] === 'number' ? point[2] : undefined,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const extra = point;
|
|
35
|
+
return {
|
|
36
|
+
...normalized,
|
|
37
|
+
intensity: typeof extra.intensity === 'number' ? extra.intensity : undefined,
|
|
38
|
+
weight: typeof extra.weight === 'number' ? extra.weight : undefined,
|
|
39
|
+
count: typeof extra.count === 'number' ? extra.count : undefined,
|
|
40
|
+
value: typeof extra.value === 'number' ? extra.value : undefined,
|
|
41
|
+
};
|
|
42
|
+
});
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
export default React.memo(HeatMap, arePropsEqual);
|
|
44
|
+
export default React.memo(HeatMap);
|
|
45
45
|
//# sourceMappingURL=HeatMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeatMap.js","sourceRoot":"","sources":["../../../../src/map/components/overlays/HeatMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"HeatMap.js","sourceRoot":"","sources":["../../../../src/map/components/overlays/HeatMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,eAAe,EAAE,M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aAC/D,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAG,KAAoC,CAAC;QACnD,OAAO;YACL,GAAG,UAAU;YACb,SAAS,EAAE,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;YAC5E,MAAM,EAAE,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YACnE,KAAK,EAAE,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YAChE,KAAK,EAAE,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACjE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { StyleSheet } from 'react-native';\nimport type { ViewProps } from 'react-native';\nimport type { HeatMapProps } from '../../types';\nimport type { LatLng } from '../../types';\nimport { normalizeLatLng } from '../../utils/GeoUtils';\nimport { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';\n\ntype NativeHeatMapPoint = LatLng & {\n intensity?: number;\n weight?: number;\n count?: number;\n value?: number;\n};\n\ntype NativeHeatMapProps = Omit<HeatMapProps, 'data'> & ViewProps & {\n data: NativeHeatMapPoint[];\n};\n\nconst getNativeHeatMap = createLazyNativeViewManager<NativeHeatMapProps>('HeatMapView');\n\n\n/**\n * 高德地图热力图组件\n *\n * @param props - 热力图配置属性,继承自NativeHeatMap组件的属性\n * @returns 渲染高德地图原生热力图组件\n */\nfunction HeatMap(props: HeatMapProps) {\n const NativeHeatMap = React.useMemo(() => getNativeHeatMap(), []);\n const { data, ...restProps } = props;\n const normalizedData = React.useMemo(() => normalizeHeatMapData(data), [data]);\n\n return (\n <NativeHeatMap\n data={normalizedData}\n {...restProps}\n collapsable={false}\n pointerEvents=\"none\"\n style={styles.hidden}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n hidden: {\n width: 0,\n height: 0,\n backgroundColor: 'transparent',\n },\n});\n\nfunction normalizeHeatMapData(data: HeatMapProps['data']): NativeHeatMapPoint[] {\n return data.map((point) => {\n const normalized = normalizeLatLng(point);\n if (Array.isArray(point)) {\n return {\n ...normalized,\n intensity: typeof point[2] === 'number' ? point[2] : undefined,\n };\n }\n\n const extra = point as Partial<NativeHeatMapPoint>;\n return {\n ...normalized,\n intensity: typeof extra.intensity === 'number' ? extra.intensity : undefined,\n weight: typeof extra.weight === 'number' ? extra.weight : undefined,\n count: typeof extra.count === 'number' ? extra.count : undefined,\n value: typeof extra.value === 'number' ? extra.value : undefined,\n };\n });\n}\n\nexport default React.memo(HeatMap);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../../../src/map/components/overlays/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../../../src/map/components/overlays/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB/C;;;;;;;;;GASG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,qBAiJjC;;AAED,wBAAkC"}
|