expo-gaode-map-navigation 1.1.5 → 1.1.7
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 +213 -73
- package/android/build.gradle +10 -0
- package/android/src/main/cpp/CMakeLists.txt +24 -0
- package/android/src/main/cpp/cluster_jni.cpp +848 -0
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +616 -92
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapOfflineModule.kt +493 -0
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +230 -14
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapViewModule.kt +37 -27
- package/android/src/main/java/expo/modules/gaodemap/map/MapPreloadManager.kt +494 -0
- package/android/src/main/java/expo/modules/gaodemap/map/companion/BitmapDescriptorCache.kt +30 -0
- package/android/src/main/java/expo/modules/gaodemap/map/companion/IconBitmapCache.kt +37 -0
- package/android/src/main/java/expo/modules/gaodemap/map/managers/UIManager.kt +76 -0
- package/android/src/main/java/expo/modules/gaodemap/map/modules/LocationManager.kt +15 -3
- package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +4 -59
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleView.kt +9 -12
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleViewModule.kt +5 -6
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterView.kt +539 -66
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterViewModule.kt +17 -1
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapView.kt +165 -33
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapViewModule.kt +15 -3
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerView.kt +1249 -672
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerViewModule.kt +40 -17
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointView.kt +177 -22
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointViewModule.kt +11 -3
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonView.kt +57 -14
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonViewModule.kt +9 -5
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineView.kt +90 -63
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineViewModule.kt +7 -3
- package/android/src/main/java/expo/modules/gaodemap/map/services/LocationForegroundService.kt +3 -2
- package/android/src/main/java/expo/modules/gaodemap/map/utils/BitmapDescriptorCache.kt +20 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/ClusterNative.kt +13 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/ColorParser.kt +20 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/GeometryUtils.kt +515 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/LatLngParser.kt +91 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/PermissionHelper.kt +248 -0
- package/build/ExpoGaodeMapNaviView.d.ts +7 -7
- package/build/ExpoGaodeMapNaviView.js +10 -11
- package/build/ExpoGaodeMapNavigationModule.d.ts +2 -1
- package/build/index.d.ts +35 -33
- package/build/index.js +70 -106
- package/build/map/ExpoGaodeMapModule.d.ts +2 -201
- package/build/map/ExpoGaodeMapModule.js +586 -18
- package/build/map/ExpoGaodeMapOfflineModule.d.ts +139 -0
- package/build/map/ExpoGaodeMapOfflineModule.js +8 -0
- package/build/map/ExpoGaodeMapView.js +66 -58
- package/build/map/components/FoldableMapView.d.ts +38 -0
- package/build/map/components/FoldableMapView.js +209 -0
- package/build/map/components/MapContext.d.ts +12 -0
- package/build/map/components/MapContext.js +54 -0
- package/build/map/components/MapUI.d.ts +18 -0
- package/build/map/components/MapUI.js +29 -0
- package/build/map/components/overlays/Circle.js +34 -3
- package/build/map/components/overlays/Cluster.d.ts +3 -1
- package/build/map/components/overlays/Cluster.js +31 -2
- package/build/map/components/overlays/HeatMap.d.ts +3 -1
- package/build/map/components/overlays/HeatMap.js +33 -3
- package/build/map/components/overlays/Marker.d.ts +1 -1
- package/build/map/components/overlays/Marker.js +37 -32
- package/build/map/components/overlays/MultiPoint.js +1 -1
- package/build/map/components/overlays/Polygon.js +30 -3
- package/build/map/components/overlays/Polyline.js +36 -3
- package/build/map/index.d.ts +25 -5
- package/build/map/index.js +59 -18
- package/build/map/types/common.types.d.ts +40 -0
- package/build/map/types/common.types.js +0 -4
- package/build/map/types/index.d.ts +3 -2
- package/build/map/types/map-view.types.d.ts +108 -3
- package/build/map/types/native-module.types.d.ts +363 -0
- package/build/map/types/native-module.types.js +5 -0
- package/build/map/types/offline.types.d.ts +132 -0
- package/build/map/types/offline.types.js +5 -0
- package/build/map/types/overlays.types.d.ts +137 -24
- package/build/map/utils/ErrorHandler.d.ts +110 -0
- package/build/map/utils/ErrorHandler.js +421 -0
- package/build/map/utils/GeoUtils.d.ts +20 -0
- package/build/map/utils/GeoUtils.js +76 -0
- package/build/map/utils/OfflineMapManager.d.ts +148 -0
- package/build/map/utils/OfflineMapManager.js +217 -0
- package/build/map/utils/PermissionUtils.d.ts +91 -0
- package/build/map/utils/PermissionUtils.js +255 -0
- package/build/map/utils/PlatformDetector.d.ts +102 -0
- package/build/map/utils/PlatformDetector.js +186 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.js +1 -0
- package/build/types/native-module.types.d.ts +69 -0
- package/build/types/native-module.types.js +2 -0
- package/build/types/naviview.types.d.ts +1 -1
- package/expo-module.config.json +12 -10
- package/ios/ExpoGaodeMapNavigation.podspec +9 -0
- package/ios/map/ExpoGaodeMapModule.swift +485 -75
- package/ios/map/ExpoGaodeMapOfflineModule.swift +479 -0
- package/ios/map/ExpoGaodeMapView.swift +611 -62
- package/ios/map/ExpoGaodeMapViewModule.swift +48 -26
- package/ios/map/MapPreloadManager.swift +348 -0
- package/ios/map/cpp/ClusterEngine.cpp +110 -0
- package/ios/map/cpp/ClusterEngine.hpp +20 -0
- package/ios/map/cpp/ColorParser.cpp +135 -0
- package/ios/map/cpp/ColorParser.hpp +14 -0
- package/ios/map/cpp/GeometryEngine.cpp +574 -0
- package/ios/map/cpp/GeometryEngine.hpp +159 -0
- package/ios/map/cpp/QuadTree.cpp +92 -0
- package/ios/map/cpp/QuadTree.hpp +42 -0
- package/ios/map/cpp/README.md +55 -0
- package/ios/map/managers/UIManager.swift +72 -1
- package/ios/map/modules/LocationManager.swift +123 -166
- package/ios/map/overlays/CircleView.swift +16 -32
- package/ios/map/overlays/CircleViewModule.swift +12 -12
- package/ios/map/overlays/ClusterAnnotation.swift +32 -0
- package/ios/map/overlays/ClusterView.swift +331 -45
- package/ios/map/overlays/ClusterViewModule.swift +20 -6
- package/ios/map/overlays/HeatMapView.swift +135 -32
- package/ios/map/overlays/HeatMapViewModule.swift +20 -8
- package/ios/map/overlays/MarkerView.swift +613 -130
- package/ios/map/overlays/MarkerViewModule.swift +38 -18
- package/ios/map/overlays/MultiPointView.swift +168 -10
- package/ios/map/overlays/MultiPointViewModule.swift +27 -5
- package/ios/map/overlays/PolygonView.swift +62 -23
- package/ios/map/overlays/PolygonViewModule.swift +18 -12
- package/ios/map/overlays/PolylineView.swift +21 -13
- package/ios/map/overlays/PolylineViewModule.swift +18 -12
- package/ios/map/utils/ClusterNative.h +96 -0
- package/ios/map/utils/ClusterNative.mm +377 -0
- package/ios/map/utils/ColorParser.swift +12 -1
- package/ios/map/utils/CppBridging.mm +13 -0
- package/ios/map/utils/GeometryUtils.swift +34 -0
- package/ios/map/utils/LatLngParser.swift +87 -0
- package/ios/map/utils/PermissionManager.swift +135 -6
- package/package.json +3 -2
- package/shared/cpp/ClusterEngine.cpp +110 -0
- package/shared/cpp/ClusterEngine.hpp +20 -0
- package/shared/cpp/ColorParser.cpp +135 -0
- package/shared/cpp/ColorParser.hpp +14 -0
- package/shared/cpp/GeometryEngine.cpp +574 -0
- package/shared/cpp/GeometryEngine.hpp +159 -0
- package/shared/cpp/QuadTree.cpp +92 -0
- package/shared/cpp/QuadTree.hpp +42 -0
- package/shared/cpp/README.md +55 -0
- package/shared/cpp/tests/benchmark_js.js +41 -0
- package/shared/cpp/tests/run.sh +17 -0
- package/shared/cpp/tests/test_main.cpp +276 -0
- package/build/map/ExpoGaodeMap.types.d.ts +0 -41
- package/build/map/ExpoGaodeMap.types.js +0 -24
- package/build/map/utils/EventManager.d.ts +0 -10
- package/build/map/utils/EventManager.js +0 -26
- package/build/map/utils/ModuleLoader.d.ts +0 -73
- package/build/map/utils/ModuleLoader.js +0 -112
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 高德地图 Expo 模块类型定义
|
|
3
|
-
*
|
|
4
|
-
* 此文件定义了 Expo 模块专用的类型,包括事件类型等
|
|
5
|
-
* 其他通用类型请从 './types' 导入
|
|
6
|
-
*/
|
|
7
|
-
import type { Coordinates, ReGeocode } from './types';
|
|
8
|
-
export * from './types';
|
|
9
|
-
/**
|
|
10
|
-
* Expo 模块事件类型
|
|
11
|
-
* 定义了原生模块可以触发的事件
|
|
12
|
-
*/
|
|
13
|
-
export type ExpoGaodeMapModuleEvents = {
|
|
14
|
-
/**
|
|
15
|
-
* 定位更新事件
|
|
16
|
-
* 当位置发生变化时触发
|
|
17
|
-
* @param location 位置信息,包含坐标和可选的逆地理编码信息
|
|
18
|
-
*/
|
|
19
|
-
onLocationUpdate: (location: Coordinates | ReGeocode) => void;
|
|
20
|
-
/**
|
|
21
|
-
* 方向更新事件(iOS)
|
|
22
|
-
* 当设备方向发生变化时触发
|
|
23
|
-
* @param heading 方向信息
|
|
24
|
-
*/
|
|
25
|
-
onHeadingUpdate: (heading: {
|
|
26
|
-
/** 磁北方向角度 (0-359.9) */
|
|
27
|
-
magneticHeading: number;
|
|
28
|
-
/** 真北方向角度 (0-359.9) */
|
|
29
|
-
trueHeading: number;
|
|
30
|
-
/** 方向精度 */
|
|
31
|
-
headingAccuracy: number;
|
|
32
|
-
/** X 轴原始数据 */
|
|
33
|
-
x: number;
|
|
34
|
-
/** Y 轴原始数据 */
|
|
35
|
-
y: number;
|
|
36
|
-
/** Z 轴原始数据 */
|
|
37
|
-
z: number;
|
|
38
|
-
/** 时间戳 */
|
|
39
|
-
timestamp: number;
|
|
40
|
-
}) => void;
|
|
41
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* 高德地图 Expo 模块类型定义
|
|
4
|
-
*
|
|
5
|
-
* 此文件定义了 Expo 模块专用的类型,包括事件类型等
|
|
6
|
-
* 其他通用类型请从 './types' 导入
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
// 重新导出所有通用类型,方便使用
|
|
24
|
-
__exportStar(require("./types"), exports);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 通用事件管理器
|
|
3
|
-
* 用于管理地图覆盖物的事件回调
|
|
4
|
-
*/
|
|
5
|
-
export declare class EventManager<T extends Record<string, any>> {
|
|
6
|
-
private callbacks;
|
|
7
|
-
register(id: string, callbacks: T): void;
|
|
8
|
-
unregister(id: string): void;
|
|
9
|
-
trigger<K extends keyof T>(id: string, eventType: K, data?: any): void;
|
|
10
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventManager = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 通用事件管理器
|
|
6
|
-
* 用于管理地图覆盖物的事件回调
|
|
7
|
-
*/
|
|
8
|
-
class EventManager {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.callbacks = new Map();
|
|
11
|
-
}
|
|
12
|
-
register(id, callbacks) {
|
|
13
|
-
this.callbacks.set(id, callbacks);
|
|
14
|
-
}
|
|
15
|
-
unregister(id) {
|
|
16
|
-
this.callbacks.delete(id);
|
|
17
|
-
}
|
|
18
|
-
trigger(id, eventType, data) {
|
|
19
|
-
const callbacks = this.callbacks.get(id);
|
|
20
|
-
const callback = callbacks === null || callbacks === void 0 ? void 0 : callbacks[eventType];
|
|
21
|
-
if (typeof callback === 'function') {
|
|
22
|
-
callback(data);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.EventManager = EventManager;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 模块检测器 - 用于检测可选模块是否已安装
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* 可选模块名称常量
|
|
6
|
-
*/
|
|
7
|
-
export declare const OptionalModules: {
|
|
8
|
-
readonly SEARCH: "expo-gaode-map-search";
|
|
9
|
-
readonly NAVIGATION: "expo-gaode-map-navigation";
|
|
10
|
-
readonly ROUTE: "expo-gaode-map-route";
|
|
11
|
-
readonly GEOCODER: "expo-gaode-map-geocoder";
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* 延迟加载可选模块
|
|
15
|
-
* 使用示例:
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* import { OptionalModules, lazyLoad } from 'expo-gaode-map';
|
|
20
|
-
*
|
|
21
|
-
* let SearchModule = null;
|
|
22
|
-
*
|
|
23
|
-
* function loadSearch() {
|
|
24
|
-
* if (SearchModule == null) {
|
|
25
|
-
* try {
|
|
26
|
-
* SearchModule = require('expo-gaode-map-search');
|
|
27
|
-
* } catch (error) {
|
|
28
|
-
* console.warn('搜索模块未安装');
|
|
29
|
-
* return null;
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* return SearchModule;
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* // 使用
|
|
36
|
-
* const search = loadSearch();
|
|
37
|
-
* if (search) {
|
|
38
|
-
* const results = await search.searchPOI({ keyword: '餐厅' });
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
/**
|
|
43
|
-
* 检查必需模块,如果未安装则抛出错误
|
|
44
|
-
* @param moduleName 模块名称
|
|
45
|
-
* @param featureName 功能名称(用于错误提示)
|
|
46
|
-
*/
|
|
47
|
-
export declare function requireModule(moduleName: string, featureName: string): void;
|
|
48
|
-
/**
|
|
49
|
-
* 获取已安装的可选模块列表
|
|
50
|
-
* 注意: 此函数无法在运行时准确检测,仅作为文档说明
|
|
51
|
-
*/
|
|
52
|
-
export declare function getInstalledModules(): string[];
|
|
53
|
-
/**
|
|
54
|
-
* 打印已安装模块信息(用于调试)
|
|
55
|
-
*/
|
|
56
|
-
export declare function printModuleInfo(): void;
|
|
57
|
-
/**
|
|
58
|
-
* 创建延迟加载器
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* import { createLazyLoader } from 'expo-gaode-map';
|
|
63
|
-
*
|
|
64
|
-
* const loadSearch = createLazyLoader(() => require('expo-gaode-map-search'));
|
|
65
|
-
*
|
|
66
|
-
* // 使用时
|
|
67
|
-
* const SearchModule = loadSearch();
|
|
68
|
-
* if (SearchModule) {
|
|
69
|
-
* const results = await SearchModule.searchPOI({ keyword: '餐厅' });
|
|
70
|
-
* }
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
export declare function createLazyLoader<T>(loader: () => T): () => T | null;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* 模块检测器 - 用于检测可选模块是否已安装
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.OptionalModules = void 0;
|
|
7
|
-
exports.requireModule = requireModule;
|
|
8
|
-
exports.getInstalledModules = getInstalledModules;
|
|
9
|
-
exports.printModuleInfo = printModuleInfo;
|
|
10
|
-
exports.createLazyLoader = createLazyLoader;
|
|
11
|
-
/**
|
|
12
|
-
* 可选模块名称常量
|
|
13
|
-
*/
|
|
14
|
-
exports.OptionalModules = {
|
|
15
|
-
SEARCH: 'expo-gaode-map-search',
|
|
16
|
-
NAVIGATION: 'expo-gaode-map-navigation',
|
|
17
|
-
ROUTE: 'expo-gaode-map-route',
|
|
18
|
-
GEOCODER: 'expo-gaode-map-geocoder',
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* 延迟加载可选模块
|
|
22
|
-
* 使用示例:
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* import { OptionalModules, lazyLoad } from 'expo-gaode-map';
|
|
27
|
-
*
|
|
28
|
-
* let SearchModule = null;
|
|
29
|
-
*
|
|
30
|
-
* function loadSearch() {
|
|
31
|
-
* if (SearchModule == null) {
|
|
32
|
-
* try {
|
|
33
|
-
* SearchModule = require('expo-gaode-map-search');
|
|
34
|
-
* } catch (error) {
|
|
35
|
-
* console.warn('搜索模块未安装');
|
|
36
|
-
* return null;
|
|
37
|
-
* }
|
|
38
|
-
* }
|
|
39
|
-
* return SearchModule;
|
|
40
|
-
* }
|
|
41
|
-
*
|
|
42
|
-
* // 使用
|
|
43
|
-
* const search = loadSearch();
|
|
44
|
-
* if (search) {
|
|
45
|
-
* const results = await search.searchPOI({ keyword: '餐厅' });
|
|
46
|
-
* }
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
/**
|
|
50
|
-
* 检查必需模块,如果未安装则抛出错误
|
|
51
|
-
* @param moduleName 模块名称
|
|
52
|
-
* @param featureName 功能名称(用于错误提示)
|
|
53
|
-
*/
|
|
54
|
-
function requireModule(moduleName, featureName) {
|
|
55
|
-
console.warn(`[expo-gaode-map] 使用 ${featureName} 需要安装 ${moduleName}。\n` +
|
|
56
|
-
`请运行: npm install ${moduleName}\n` +
|
|
57
|
-
`然后使用 try-catch 包裹 require('${moduleName}') 来加载`);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* 获取已安装的可选模块列表
|
|
61
|
-
* 注意: 此函数无法在运行时准确检测,仅作为文档说明
|
|
62
|
-
*/
|
|
63
|
-
function getInstalledModules() {
|
|
64
|
-
console.warn('[expo-gaode-map] getInstalledModules() 无法在运行时检测。\n' +
|
|
65
|
-
'请在编译时检查 package.json 中安装的模块');
|
|
66
|
-
return [];
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 打印已安装模块信息(用于调试)
|
|
70
|
-
*/
|
|
71
|
-
function printModuleInfo() {
|
|
72
|
-
console.log('[expo-gaode-map] 核心模块: 已加载');
|
|
73
|
-
console.log('[expo-gaode-map] 可选模块检测:');
|
|
74
|
-
console.log(' - 使用 try-catch 包裹 require() 来检测可选模块');
|
|
75
|
-
console.log(' - 可用的可选模块:');
|
|
76
|
-
Object.entries(exports.OptionalModules).forEach(([key, value]) => {
|
|
77
|
-
console.log(` - ${key}: ${value}`);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* 创建延迟加载器
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```typescript
|
|
85
|
-
* import { createLazyLoader } from 'expo-gaode-map';
|
|
86
|
-
*
|
|
87
|
-
* const loadSearch = createLazyLoader(() => require('expo-gaode-map-search'));
|
|
88
|
-
*
|
|
89
|
-
* // 使用时
|
|
90
|
-
* const SearchModule = loadSearch();
|
|
91
|
-
* if (SearchModule) {
|
|
92
|
-
* const results = await SearchModule.searchPOI({ keyword: '餐厅' });
|
|
93
|
-
* }
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
function createLazyLoader(loader) {
|
|
97
|
-
let cached = null;
|
|
98
|
-
let attempted = false;
|
|
99
|
-
return () => {
|
|
100
|
-
if (!attempted) {
|
|
101
|
-
attempted = true;
|
|
102
|
-
try {
|
|
103
|
-
cached = loader();
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
console.warn('[expo-gaode-map] 模块加载失败:', error);
|
|
107
|
-
cached = null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return cached;
|
|
111
|
-
};
|
|
112
|
-
}
|