expo-gaode-map-navigation 2.0.17 → 2.0.19
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/android/build.gradle +10 -25
- package/build/ExpoGaodeMapNaviView.js +2 -1
- package/build/ExpoGaodeMapNaviView.js.map +1 -1
- package/build/ExpoGaodeMapNavigationModule.d.ts +1 -1
- package/build/ExpoGaodeMapNavigationModule.d.ts.map +1 -1
- package/build/ExpoGaodeMapNavigationModule.js.map +1 -1
- package/build/map/ExpoGaodeMapModule.d.ts +3 -2
- package/build/map/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapModule.js +13 -4
- package/build/map/ExpoGaodeMapModule.js.map +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.js +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.js.map +1 -1
- package/build/map/ExpoGaodeMapView.js +2 -8
- package/build/map/ExpoGaodeMapView.js.map +1 -1
- package/build/map/components/FoldableMapView.d.ts +3 -2
- package/build/map/components/FoldableMapView.d.ts.map +1 -1
- package/build/map/components/FoldableMapView.js +2 -1
- package/build/map/components/FoldableMapView.js.map +1 -1
- package/build/map/components/MapUI.js +2 -1
- package/build/map/components/MapUI.js.map +1 -1
- package/build/map/components/overlays/Circle.d.ts +1 -1
- package/build/map/components/overlays/Circle.d.ts.map +1 -1
- package/build/map/components/overlays/Circle.js +2 -1
- package/build/map/components/overlays/Circle.js.map +1 -1
- package/build/map/components/overlays/Cluster.d.ts +1 -1
- package/build/map/components/overlays/Cluster.d.ts.map +1 -1
- package/build/map/components/overlays/Cluster.js +2 -1
- package/build/map/components/overlays/Cluster.js.map +1 -1
- package/build/map/components/overlays/HeatMap.d.ts +1 -1
- package/build/map/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/map/components/overlays/HeatMap.js +2 -1
- package/build/map/components/overlays/HeatMap.js.map +1 -1
- package/build/map/components/overlays/Marker.d.ts +1 -1
- package/build/map/components/overlays/Marker.d.ts.map +1 -1
- package/build/map/components/overlays/Marker.js +2 -5
- package/build/map/components/overlays/Marker.js.map +1 -1
- package/build/map/components/overlays/MultiPoint.d.ts +1 -2
- package/build/map/components/overlays/MultiPoint.d.ts.map +1 -1
- package/build/map/components/overlays/MultiPoint.js +2 -1
- package/build/map/components/overlays/MultiPoint.js.map +1 -1
- package/build/map/components/overlays/Polygon.d.ts +1 -1
- package/build/map/components/overlays/Polygon.d.ts.map +1 -1
- package/build/map/components/overlays/Polygon.js +2 -1
- package/build/map/components/overlays/Polygon.js.map +1 -1
- package/build/map/components/overlays/Polyline.d.ts +1 -1
- package/build/map/components/overlays/Polyline.d.ts.map +1 -1
- package/build/map/components/overlays/Polyline.js +2 -1
- package/build/map/components/overlays/Polyline.js.map +1 -1
- package/build/map/search/ExpoGaodeMapSearchModule.d.ts +1 -1
- package/build/map/search/ExpoGaodeMapSearchModule.d.ts.map +1 -1
- package/build/map/search/ExpoGaodeMapSearchModule.js.map +1 -1
- package/build/map/types/common.types.d.ts +1 -1
- package/build/map/types/common.types.d.ts.map +1 -1
- package/build/map/types/common.types.js.map +1 -1
- package/build/map/types/map-view.types.d.ts +2 -2
- package/build/map/types/map-view.types.d.ts.map +1 -1
- package/build/map/types/map-view.types.js.map +1 -1
- package/build/map/utils/ErrorHandler.d.ts +4 -0
- package/build/map/utils/ErrorHandler.d.ts.map +1 -1
- package/build/map/utils/ErrorHandler.js +8 -0
- package/build/map/utils/ErrorHandler.js.map +1 -1
- package/build/map/utils/GeoUtils.d.ts +1 -1
- package/build/map/utils/GeoUtils.d.ts.map +1 -1
- package/build/map/utils/GeoUtils.js +2 -2
- package/build/map/utils/GeoUtils.js.map +1 -1
- package/build/route-geometry.d.ts.map +1 -1
- package/build/route-geometry.js +24 -8
- package/build/route-geometry.js.map +1 -1
- package/build/src/ExpoGaodeMapNaviView.d.ts +67 -0
- package/build/src/ExpoGaodeMapNaviView.d.ts.map +1 -0
- package/build/src/ExpoGaodeMapNaviView.js +138 -0
- package/build/src/ExpoGaodeMapNaviView.js.map +1 -0
- package/build/src/ExpoGaodeMapNavigation.types.d.ts +2 -0
- package/build/src/ExpoGaodeMapNavigation.types.d.ts.map +1 -0
- package/build/src/ExpoGaodeMapNavigation.types.js +3 -0
- package/build/src/ExpoGaodeMapNavigation.types.js.map +1 -0
- package/build/src/ExpoGaodeMapNavigationModule.d.ts +4 -0
- package/build/src/ExpoGaodeMapNavigationModule.d.ts.map +1 -0
- package/build/src/ExpoGaodeMapNavigationModule.js +27 -0
- package/build/src/ExpoGaodeMapNavigationModule.js.map +1 -0
- package/build/src/index.d.ts +47 -0
- package/build/src/index.d.ts.map +1 -0
- package/build/src/index.js +48 -0
- package/build/src/index.js.map +1 -0
- package/build/src/map/ExpoGaodeMapModule.d.ts +256 -0
- package/build/src/map/ExpoGaodeMapModule.d.ts.map +1 -0
- package/build/src/map/ExpoGaodeMapModule.js +813 -0
- package/build/src/map/ExpoGaodeMapModule.js.map +1 -0
- package/build/src/map/ExpoGaodeMapOfflineModule.d.ts +145 -0
- package/build/src/map/ExpoGaodeMapOfflineModule.d.ts.map +1 -0
- package/build/src/map/ExpoGaodeMapOfflineModule.js +24 -0
- package/build/src/map/ExpoGaodeMapOfflineModule.js.map +1 -0
- package/build/src/map/ExpoGaodeMapView.d.ts +23 -0
- package/build/src/map/ExpoGaodeMapView.d.ts.map +1 -0
- package/build/src/map/ExpoGaodeMapView.js +173 -0
- package/build/src/map/ExpoGaodeMapView.js.map +1 -0
- package/build/src/map/components/FoldableMapView.d.ts +39 -0
- package/build/src/map/components/FoldableMapView.d.ts.map +1 -0
- package/build/src/map/components/FoldableMapView.js +171 -0
- package/build/src/map/components/FoldableMapView.js.map +1 -0
- package/build/src/map/components/MapContext.d.ts +13 -0
- package/build/src/map/components/MapContext.d.ts.map +1 -0
- package/build/src/map/components/MapContext.js +18 -0
- package/build/src/map/components/MapContext.js.map +1 -0
- package/build/src/map/components/MapUI.d.ts +19 -0
- package/build/src/map/components/MapUI.d.ts.map +1 -0
- package/build/src/map/components/MapUI.js +24 -0
- package/build/src/map/components/MapUI.js.map +1 -0
- package/build/src/map/components/overlays/Circle.d.ts +13 -0
- package/build/src/map/components/overlays/Circle.d.ts.map +1 -0
- package/build/src/map/components/overlays/Circle.js +20 -0
- package/build/src/map/components/overlays/Circle.js.map +1 -0
- package/build/src/map/components/overlays/Cluster.d.ts +12 -0
- package/build/src/map/components/overlays/Cluster.d.ts.map +1 -0
- package/build/src/map/components/overlays/Cluster.js +16 -0
- package/build/src/map/components/overlays/Cluster.js.map +1 -0
- package/build/src/map/components/overlays/HeatMap.d.ts +12 -0
- package/build/src/map/components/overlays/HeatMap.d.ts.map +1 -0
- package/build/src/map/components/overlays/HeatMap.js +46 -0
- package/build/src/map/components/overlays/HeatMap.js.map +1 -0
- package/build/src/map/components/overlays/Marker.d.ts +16 -0
- package/build/src/map/components/overlays/Marker.d.ts.map +1 -0
- package/build/src/map/components/overlays/Marker.js +125 -0
- package/build/src/map/components/overlays/Marker.js.map +1 -0
- package/build/src/map/components/overlays/MultiPoint.d.ts +9 -0
- package/build/src/map/components/overlays/MultiPoint.d.ts.map +1 -0
- package/build/src/map/components/overlays/MultiPoint.js +15 -0
- package/build/src/map/components/overlays/MultiPoint.js.map +1 -0
- package/build/src/map/components/overlays/Polygon.d.ts +12 -0
- package/build/src/map/components/overlays/Polygon.d.ts.map +1 -0
- package/build/src/map/components/overlays/Polygon.js +20 -0
- package/build/src/map/components/overlays/Polygon.js.map +1 -0
- package/build/src/map/components/overlays/Polyline.d.ts +12 -0
- package/build/src/map/components/overlays/Polyline.d.ts.map +1 -0
- package/build/src/map/components/overlays/Polyline.js +20 -0
- package/build/src/map/components/overlays/Polyline.js.map +1 -0
- package/build/src/map/components/overlays/index.d.ts +8 -0
- package/build/src/map/components/overlays/index.d.ts.map +1 -0
- package/build/src/map/components/overlays/index.js +8 -0
- package/build/src/map/components/overlays/index.js.map +1 -0
- package/build/src/map/index.d.ts +35 -0
- package/build/src/map/index.d.ts.map +1 -0
- package/build/src/map/index.js +48 -0
- package/build/src/map/index.js.map +1 -0
- package/build/src/map/search/ExpoGaodeMapSearch.types.d.ts +340 -0
- package/build/src/map/search/ExpoGaodeMapSearch.types.d.ts.map +1 -0
- package/build/src/map/search/ExpoGaodeMapSearch.types.js +19 -0
- package/build/src/map/search/ExpoGaodeMapSearch.types.js.map +1 -0
- package/build/src/map/search/ExpoGaodeMapSearchModule.d.ts +74 -0
- package/build/src/map/search/ExpoGaodeMapSearchModule.d.ts.map +1 -0
- package/build/src/map/search/ExpoGaodeMapSearchModule.js +48 -0
- package/build/src/map/search/ExpoGaodeMapSearchModule.js.map +1 -0
- package/build/src/map/search/index.d.ts +156 -0
- package/build/src/map/search/index.d.ts.map +1 -0
- package/build/src/map/search/index.js +171 -0
- package/build/src/map/search/index.js.map +1 -0
- package/build/src/map/types/common.types.d.ts +199 -0
- package/build/src/map/types/common.types.d.ts.map +1 -0
- package/build/src/map/types/common.types.js +33 -0
- package/build/src/map/types/common.types.js.map +1 -0
- package/build/src/map/types/index.d.ts +13 -0
- package/build/src/map/types/index.d.ts.map +1 -0
- package/build/src/map/types/index.js +7 -0
- package/build/src/map/types/index.js.map +1 -0
- package/build/src/map/types/location.types.d.ts +358 -0
- package/build/src/map/types/location.types.d.ts.map +1 -0
- package/build/src/map/types/location.types.js +93 -0
- package/build/src/map/types/location.types.js.map +1 -0
- package/build/src/map/types/map-view.types.d.ts +340 -0
- package/build/src/map/types/map-view.types.d.ts.map +1 -0
- package/build/src/map/types/map-view.types.js +6 -0
- package/build/src/map/types/map-view.types.js.map +1 -0
- package/build/src/map/types/native-module.types.d.ts +395 -0
- package/build/src/map/types/native-module.types.d.ts.map +1 -0
- package/build/src/map/types/native-module.types.js +5 -0
- package/build/src/map/types/native-module.types.js.map +1 -0
- package/build/src/map/types/offline.types.d.ts +133 -0
- package/build/src/map/types/offline.types.d.ts.map +1 -0
- package/build/src/map/types/offline.types.js +5 -0
- package/build/src/map/types/offline.types.js.map +1 -0
- package/build/src/map/types/overlays.types.d.ts +456 -0
- package/build/src/map/types/overlays.types.d.ts.map +1 -0
- package/build/src/map/types/overlays.types.js +6 -0
- package/build/src/map/types/overlays.types.js.map +1 -0
- package/build/src/map/types/route-playback.types.d.ts +28 -0
- package/build/src/map/types/route-playback.types.d.ts.map +1 -0
- package/build/src/map/types/route-playback.types.js +2 -0
- package/build/src/map/types/route-playback.types.js.map +1 -0
- package/build/src/map/utils/ErrorHandler.d.ts +121 -0
- package/build/src/map/utils/ErrorHandler.d.ts.map +1 -0
- package/build/src/map/utils/ErrorHandler.js +470 -0
- package/build/src/map/utils/ErrorHandler.js.map +1 -0
- package/build/src/map/utils/GeoUtils.d.ts +21 -0
- package/build/src/map/utils/GeoUtils.d.ts.map +1 -0
- package/build/src/map/utils/GeoUtils.js +78 -0
- package/build/src/map/utils/GeoUtils.js.map +1 -0
- package/build/src/map/utils/OfflineMapManager.d.ts +153 -0
- package/build/src/map/utils/OfflineMapManager.d.ts.map +1 -0
- package/build/src/map/utils/OfflineMapManager.js +217 -0
- package/build/src/map/utils/OfflineMapManager.js.map +1 -0
- package/build/src/map/utils/PermissionUtils.d.ts +92 -0
- package/build/src/map/utils/PermissionUtils.d.ts.map +1 -0
- package/build/src/map/utils/PermissionUtils.js +252 -0
- package/build/src/map/utils/PermissionUtils.js.map +1 -0
- package/build/src/map/utils/PlatformDetector.d.ts +103 -0
- package/build/src/map/utils/PlatformDetector.d.ts.map +1 -0
- package/build/src/map/utils/PlatformDetector.js +178 -0
- package/build/src/map/utils/PlatformDetector.js.map +1 -0
- package/build/src/map/utils/lazyNativeViewManager.d.ts +3 -0
- package/build/src/map/utils/lazyNativeViewManager.d.ts.map +1 -0
- package/build/src/map/utils/lazyNativeViewManager.js +11 -0
- package/build/src/map/utils/lazyNativeViewManager.js.map +1 -0
- package/build/src/route-geometry.d.ts +13 -0
- package/build/src/route-geometry.d.ts.map +1 -0
- package/build/src/route-geometry.js +154 -0
- package/build/src/route-geometry.js.map +1 -0
- package/build/src/route-planning.d.ts +21 -0
- package/build/src/route-planning.d.ts.map +1 -0
- package/build/src/route-planning.js +67 -0
- package/build/src/route-planning.js.map +1 -0
- package/build/src/types/coordinates.types.d.ts +25 -0
- package/build/src/types/coordinates.types.d.ts.map +1 -0
- package/build/src/types/coordinates.types.js +6 -0
- package/build/src/types/coordinates.types.js.map +1 -0
- package/build/src/types/independent.types.d.ts +385 -0
- package/build/src/types/independent.types.d.ts.map +1 -0
- package/build/src/types/independent.types.js +2 -0
- package/build/src/types/independent.types.js.map +1 -0
- package/build/src/types/index.d.ts +6 -0
- package/build/src/types/index.d.ts.map +1 -0
- package/build/src/types/index.js +7 -0
- package/build/src/types/index.js.map +1 -0
- package/build/src/types/native-module.types.d.ts +74 -0
- package/build/src/types/native-module.types.d.ts.map +1 -0
- package/build/src/types/native-module.types.js +3 -0
- package/build/src/types/native-module.types.js.map +1 -0
- package/build/src/types/naviview.types.d.ts +562 -0
- package/build/src/types/naviview.types.d.ts.map +1 -0
- package/build/src/types/naviview.types.js +2 -0
- package/build/src/types/naviview.types.js.map +1 -0
- package/build/src/types/route.types.d.ts +414 -0
- package/build/src/types/route.types.d.ts.map +1 -0
- package/build/src/types/route.types.js +137 -0
- package/build/src/types/route.types.js.map +1 -0
- package/build/src/web-api-fallback.d.ts +5 -0
- package/build/src/web-api-fallback.d.ts.map +1 -0
- package/build/src/web-api-fallback.js +160 -0
- package/build/src/web-api-fallback.js.map +1 -0
- package/build/src/web-route-following.d.ts +3 -0
- package/build/src/web-route-following.d.ts.map +1 -0
- package/build/src/web-route-following.js +178 -0
- package/build/src/web-route-following.js.map +1 -0
- package/build/types/native-module.types.d.ts +2 -2
- package/build/types/native-module.types.d.ts.map +1 -1
- package/build/types/native-module.types.js.map +1 -1
- package/build/types/naviview.types.d.ts +1 -1
- package/build/types/naviview.types.d.ts.map +1 -1
- package/build/types/naviview.types.js.map +1 -1
- package/build/web-api-fallback.d.ts.map +1 -1
- package/build/web-api-fallback.js +0 -1
- package/build/web-api-fallback.js.map +1 -1
- package/ios/map/ExpoGaodeMapView.swift +145 -3
- package/ios/map/cpp/ClusterEngine.cpp +4 -14
- package/ios/map/cpp/ClusterEngine.hpp +1 -12
- package/ios/map/cpp/ClusterTypes.hpp +18 -0
- package/ios/map/cpp/ColorParser.cpp +22 -3
- package/ios/map/cpp/GeometryEngine.cpp +1 -1
- package/ios/map/cpp/QuadTree.hpp +1 -1
- package/ios/map/managers/UIManager.swift +3 -0
- package/package.json +16 -8
- package/plugin/build/withGaodeMap.js +19 -14
- package/shared/cpp/ClusterEngine.cpp +4 -14
- package/shared/cpp/ClusterEngine.hpp +1 -12
- package/shared/cpp/ClusterTypes.hpp +18 -0
- package/shared/cpp/ColorParser.cpp +22 -3
- package/shared/cpp/GeometryEngine.cpp +1 -1
- package/shared/cpp/QuadTree.hpp +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-api-fallback.js","sourceRoot":"","sources":["../src/web-api-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,KAAK,UAAU,kBAAkB,CAAC,OAA4B;IAC5D,IAAI,CAAC;QACH,8DAA8D;QAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;QACjD,IAAI,OAAO,MAAM,EAAE,WAAW,KAAK,UAAU,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,GAAG,OAAO,2EAA2E,CACtF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,QAA6C;IAC3E,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACtB,OAAO,SAA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,CAAC,KAAK,UAAU,+BAA+B,CACnD,OAA4B;IAE5B,4CAA4C;IAC5C,8CAA8C;IAC9C,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC5E,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CACpC,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EACpD,GAAG,OAAO,CAAC,EAAE,CAAC,SAAS,IAAI,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAChD,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,KAAK,EACb;QACE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,WAAW;QACzD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,WAAW,EAAE,eAAe;KAC7B,CACF,CAAC;IAEF,OAAO,2BAA2B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { DriveStrategy } from './types';\nimport type { DriveRouteOptions, DriveRouteResult, RouteResult, TransitRouteOptions } from './types';\nimport { parsePolyline } from './route-geometry';\n\nasync function loadWebApiFallback(feature: '公交路径规划' | '规避路线预览') {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const webApi = require('expo-gaode-map-web-api');\n if (typeof webApi?.GaodeWebAPI !== 'function') {\n throw new Error('expo-gaode-map-web-api 未导出 GaodeWebAPI');\n }\n return webApi;\n } catch {\n throw new Error(\n `${feature}依赖 expo-gaode-map-web-api。请安装该包,并在 ExpoGaodeMapModule.initSDK 中提供 webKey。`\n );\n }\n}\n\nfunction normalizeAvoidPolygons(polygons?: DriveRouteOptions['avoidPolygons']): string | undefined {\n if (!polygons?.length) {\n return undefined;\n }\n\n const normalized = polygons\n .map((polygon) =>\n polygon\n .map((point) => `${point.longitude},${point.latitude}`)\n .join(';')\n )\n .filter(Boolean)\n .join('|');\n\n return normalized || undefined;\n}\n\nfunction normalizeDrivingStrategy(\n strategy?: DriveStrategy\n): number | undefined {\n // 导航 SDK 与 Web API 的策略枚举不完全一致。\n // 这里做“尽量等价”的映射,主要用于带规避参数时的路线预览。\n switch (strategy) {\n case DriveStrategy.FASTEST:\n return 38;\n case DriveStrategy.FEE_FIRST:\n return 1;\n case DriveStrategy.SHORTEST:\n return 2;\n case DriveStrategy.NO_EXPRESSWAYS:\n return 37;\n case DriveStrategy.AVOID_CONGESTION:\n return 33;\n case DriveStrategy.NO_HIGHWAY:\n return 35;\n case DriveStrategy.NO_HIGHWAY_AVOID_CONGESTION:\n return 40;\n case DriveStrategy.AVOID_COST_CONGESTION:\n case DriveStrategy.AVOID_CONGESTION_COST:\n return 41;\n case DriveStrategy.NO_HIGHWAY_AVOID_COST_CONGESTION:\n return 43;\n default:\n return undefined;\n }\n}\n\nfunction normalizeDrivingRouteResult(\n options: DriveRouteOptions,\n result: any\n): DriveRouteResult {\n // 把 Web API 的原始字段翻译成导航包已经对外稳定的 RouteResult 结构。\n // 这样上层代码不需要知道 Web API 的字段名,也不用为 fallback 单独写分支。\n const paths = result?.route?.paths ?? [];\n const routes = paths.map((path: any, index: number) => {\n const segments = (path?.steps ?? []).map((step: any) => ({\n instruction: step?.instruction ?? '',\n orientation: step?.orientation,\n road: step?.road_name,\n distance: Number(step?.step_distance ?? 0),\n duration: Number(step?.cost?.duration ?? 0),\n polyline: parsePolyline(step?.polyline),\n assistantAction: step?.assistant_action,\n tollDistance: step?.cost?.toll_distance ? Number(step.cost.toll_distance) : undefined,\n tollCost: step?.cost?.tolls ? Number(step.cost.tolls) : undefined,\n }));\n\n const restrictionCode = path?.restriction != null ? Number(path.restriction) : undefined;\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(path?.distance ?? 0),\n duration: Number(path?.cost?.duration ?? path?.duration ?? 0),\n segments,\n polyline: segments.flatMap((segment: { polyline: any[] }) => segment.polyline),\n tollDistance: path?.cost?.toll_distance ? Number(path.cost.toll_distance) : undefined,\n tollCost: path?.cost?.tolls ? Number(path.cost.tolls) : undefined,\n trafficLightCount: path?.cost?.traffic_lights ? Number(path.cost.traffic_lights) : undefined,\n restrictionCode,\n restrictionInfo:\n restrictionCode === 0\n ? '限行已规避或未限行'\n : restrictionCode === 1\n ? '限行无法规避'\n : undefined,\n strategy: options.strategy,\n };\n });\n\n return {\n count: Number(result?.count ?? routes.length),\n mainPathIndex: 0,\n routeIds: routes.map((route: RouteResult) => route.id),\n routes,\n taxiCost: result?.route?.taxi_cost ? Number(result.route.taxi_cost) : undefined,\n };\n}\n\nexport function shouldUseAvoidPreviewFallback(options: DriveRouteOptions): boolean {\n // 只有出现“规避道路 / 规避区域”时才需要走 Web API 预览。\n // 普通驾车算路仍然优先走原生能力。\n return Boolean(options.avoidRoad?.trim() || options.avoidPolygons?.length);\n}\n\nexport async function calculateDriveRouteWithAvoidPreview(\n options: DriveRouteOptions\n): Promise<DriveRouteResult> {\n // Web API 只负责“预览规避后的路线”,不是替代原生导航 SDK。\n // 失败时让调用方回退到原生实现,避免把可用路径规划直接变成报错。\n const { GaodeWebAPI } = await loadWebApiFallback('规避路线预览');\n const api = new GaodeWebAPI();\n const result = await api.route.driving(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n {\n strategy: normalizeDrivingStrategy(options.strategy),\n waypoints: options.waypoints?.map(\n (point) => `${point.longitude},${point.latitude}`\n ),\n avoidpolygons: normalizeAvoidPolygons(options.avoidPolygons),\n avoidroad: options.avoidRoad?.trim() || undefined,\n plate: options.carNumber,\n show_fields: 'cost,navi,polyline',\n }\n );\n\n return normalizeDrivingRouteResult(options, result);\n}\n\nfunction normalizeTransitRouteResult(\n options: TransitRouteOptions,\n result: any\n): DriveRouteResult {\n // 导航包内部仍保持独立实现;\n // 这里只是在“公交无法由导航 SDK 直算”时,把 Web API 结果映射成现有 RouteResult 形状。\n const routes = (result?.route?.transits ?? []).map((transit: any, index: number) => {\n const polyline = (transit?.segments ?? []).flatMap((segment: any) => [\n ...(segment.walking?.steps?.flatMap((step: any) => parsePolyline(step.polyline)) ?? []),\n ...(segment.bus?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ...(segment.railway?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ]);\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(transit?.distance ?? 0),\n duration: Number(transit?.cost?.duration ?? 0),\n segments: [],\n polyline,\n tollDistance: 0,\n tollCost: Number(transit?.cost?.transit_fee ?? 0),\n strategy: options.strategy,\n };\n });\n\n return {\n count: routes.length,\n mainPathIndex: 0,\n routes,\n };\n}\n\nexport async function calculateTransitRouteWithWebApi(\n options: TransitRouteOptions\n): Promise<DriveRouteResult> {\n // 公交换乘在当前 SDK 能力下统一回退到 Web API,再映射成同一份路线结构。\n // 运行时按需加载,避免把 navigation 包和 web-api 包在构建期强绑定。\n const { GaodeWebAPI, TransitStrategy } = await loadWebApiFallback('公交路径规划');\n const api = new GaodeWebAPI();\n const result = await api.route.transit(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n options.city1,\n options.city2,\n {\n strategy: options.strategy ?? TransitStrategy.RECOMMENDED,\n AlternativeRoute: options.alternativeRoute,\n show_fields: 'cost,polyline',\n }\n );\n\n return normalizeTransitRouteResult(options, result);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web-api-fallback.js","sourceRoot":"","sources":["../src/web-api-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,KAAK,UAAU,kBAAkB,CAAC,OAA4B;IAC5D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,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I,EAAE,QAAQ,IAAI,CAAC,CAAC;YAC9C,QAAQ,EAAE,EAAE;YACZ,QAAQ;YACR,YAAY,EAAE,CAAC;YACf,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,IAAI,CAAC,CAAC;YACjD,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,aAAa,EAAE,CAAC;QAChB,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,OAA4B;IAE5B,4CAA4C;IAC5C,8CAA8C;IAC9C,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC5E,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CACpC,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EACpD,GAAG,OAAO,CAAC,EAAE,CAAC,SAAS,IAAI,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAChD,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,KAAK,EACb;QACE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,WAAW;QACzD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,WAAW,EAAE,eAAe;KAC7B,CACF,CAAC;IAEF,OAAO,2BAA2B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { DriveStrategy } from './types';\nimport type { DriveRouteOptions, DriveRouteResult, RouteResult, TransitRouteOptions } from './types';\nimport { parsePolyline } from './route-geometry';\n\nasync function loadWebApiFallback(feature: '公交路径规划' | '规避路线预览') {\n try {\n const webApi = require('expo-gaode-map-web-api');\n if (typeof webApi?.GaodeWebAPI !== 'function') {\n throw new Error('expo-gaode-map-web-api 未导出 GaodeWebAPI');\n }\n return webApi;\n } catch {\n throw new Error(\n `${feature}依赖 expo-gaode-map-web-api。请安装该包,并在 ExpoGaodeMapModule.initSDK 中提供 webKey。`\n );\n }\n}\n\nfunction normalizeAvoidPolygons(polygons?: DriveRouteOptions['avoidPolygons']): string | undefined {\n if (!polygons?.length) {\n return undefined;\n }\n\n const normalized = polygons\n .map((polygon) =>\n polygon\n .map((point) => `${point.longitude},${point.latitude}`)\n .join(';')\n )\n .filter(Boolean)\n .join('|');\n\n return normalized || undefined;\n}\n\nfunction normalizeDrivingStrategy(\n strategy?: DriveStrategy\n): number | undefined {\n // 导航 SDK 与 Web API 的策略枚举不完全一致。\n // 这里做“尽量等价”的映射,主要用于带规避参数时的路线预览。\n switch (strategy) {\n case DriveStrategy.FASTEST:\n return 38;\n case DriveStrategy.FEE_FIRST:\n return 1;\n case DriveStrategy.SHORTEST:\n return 2;\n case DriveStrategy.NO_EXPRESSWAYS:\n return 37;\n case DriveStrategy.AVOID_CONGESTION:\n return 33;\n case DriveStrategy.NO_HIGHWAY:\n return 35;\n case DriveStrategy.NO_HIGHWAY_AVOID_CONGESTION:\n return 40;\n case DriveStrategy.AVOID_COST_CONGESTION:\n case DriveStrategy.AVOID_CONGESTION_COST:\n return 41;\n case DriveStrategy.NO_HIGHWAY_AVOID_COST_CONGESTION:\n return 43;\n default:\n return undefined;\n }\n}\n\nfunction normalizeDrivingRouteResult(\n options: DriveRouteOptions,\n result: any\n): DriveRouteResult {\n // 把 Web API 的原始字段翻译成导航包已经对外稳定的 RouteResult 结构。\n // 这样上层代码不需要知道 Web API 的字段名,也不用为 fallback 单独写分支。\n const paths = result?.route?.paths ?? [];\n const routes = paths.map((path: any, index: number) => {\n const segments = (path?.steps ?? []).map((step: any) => ({\n instruction: step?.instruction ?? '',\n orientation: step?.orientation,\n road: step?.road_name,\n distance: Number(step?.step_distance ?? 0),\n duration: Number(step?.cost?.duration ?? 0),\n polyline: parsePolyline(step?.polyline),\n assistantAction: step?.assistant_action,\n tollDistance: step?.cost?.toll_distance ? Number(step.cost.toll_distance) : undefined,\n tollCost: step?.cost?.tolls ? Number(step.cost.tolls) : undefined,\n }));\n\n const restrictionCode = path?.restriction != null ? Number(path.restriction) : undefined;\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(path?.distance ?? 0),\n duration: Number(path?.cost?.duration ?? path?.duration ?? 0),\n segments,\n polyline: segments.flatMap((segment: { polyline: any[] }) => segment.polyline),\n tollDistance: path?.cost?.toll_distance ? Number(path.cost.toll_distance) : undefined,\n tollCost: path?.cost?.tolls ? Number(path.cost.tolls) : undefined,\n trafficLightCount: path?.cost?.traffic_lights ? Number(path.cost.traffic_lights) : undefined,\n restrictionCode,\n restrictionInfo:\n restrictionCode === 0\n ? '限行已规避或未限行'\n : restrictionCode === 1\n ? '限行无法规避'\n : undefined,\n strategy: options.strategy,\n };\n });\n\n return {\n count: Number(result?.count ?? routes.length),\n mainPathIndex: 0,\n routeIds: routes.map((route: RouteResult) => route.id),\n routes,\n taxiCost: result?.route?.taxi_cost ? Number(result.route.taxi_cost) : undefined,\n };\n}\n\nexport function shouldUseAvoidPreviewFallback(options: DriveRouteOptions): boolean {\n // 只有出现“规避道路 / 规避区域”时才需要走 Web API 预览。\n // 普通驾车算路仍然优先走原生能力。\n return Boolean(options.avoidRoad?.trim() || options.avoidPolygons?.length);\n}\n\nexport async function calculateDriveRouteWithAvoidPreview(\n options: DriveRouteOptions\n): Promise<DriveRouteResult> {\n // Web API 只负责“预览规避后的路线”,不是替代原生导航 SDK。\n // 失败时让调用方回退到原生实现,避免把可用路径规划直接变成报错。\n const { GaodeWebAPI } = await loadWebApiFallback('规避路线预览');\n const api = new GaodeWebAPI();\n const result = await api.route.driving(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n {\n strategy: normalizeDrivingStrategy(options.strategy),\n waypoints: options.waypoints?.map(\n (point) => `${point.longitude},${point.latitude}`\n ),\n avoidpolygons: normalizeAvoidPolygons(options.avoidPolygons),\n avoidroad: options.avoidRoad?.trim() || undefined,\n plate: options.carNumber,\n show_fields: 'cost,navi,polyline',\n }\n );\n\n return normalizeDrivingRouteResult(options, result);\n}\n\nfunction normalizeTransitRouteResult(\n options: TransitRouteOptions,\n result: any\n): DriveRouteResult {\n // 导航包内部仍保持独立实现;\n // 这里只是在“公交无法由导航 SDK 直算”时,把 Web API 结果映射成现有 RouteResult 形状。\n const routes = (result?.route?.transits ?? []).map((transit: any, index: number) => {\n const polyline = (transit?.segments ?? []).flatMap((segment: any) => [\n ...(segment.walking?.steps?.flatMap((step: any) => parsePolyline(step.polyline)) ?? []),\n ...(segment.bus?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ...(segment.railway?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ]);\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(transit?.distance ?? 0),\n duration: Number(transit?.cost?.duration ?? 0),\n segments: [],\n polyline,\n tollDistance: 0,\n tollCost: Number(transit?.cost?.transit_fee ?? 0),\n strategy: options.strategy,\n };\n });\n\n return {\n count: routes.length,\n mainPathIndex: 0,\n routes,\n };\n}\n\nexport async function calculateTransitRouteWithWebApi(\n options: TransitRouteOptions\n): Promise<DriveRouteResult> {\n // 公交换乘在当前 SDK 能力下统一回退到 Web API,再映射成同一份路线结构。\n // 运行时按需加载,避免把 navigation 包和 web-api 包在构建期强绑定。\n const { GaodeWebAPI, TransitStrategy } = await loadWebApiFallback('公交路径规划');\n const api = new GaodeWebAPI();\n const result = await api.route.transit(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n options.city1,\n options.city2,\n {\n strategy: options.strategy ?? TransitStrategy.RECOMMENDED,\n AlternativeRoute: options.alternativeRoute,\n show_fields: 'cost,polyline',\n }\n );\n\n return normalizeTransitRouteResult(options, result);\n}\n"]}
|
|
@@ -96,6 +96,8 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
96
96
|
private var uiManager: UIManager!
|
|
97
97
|
/// 地图是否已加载完成
|
|
98
98
|
private var isMapLoaded = false
|
|
99
|
+
/// 定位 annotation 首次出现后是否已补应用定位样式
|
|
100
|
+
private var hasAppliedUserLocationStyleAfterLocationUpdate = false
|
|
99
101
|
/// 初始相机是否已应用(仅应用一次,避免与运行时相机控制冲突)
|
|
100
102
|
private var hasAppliedInitialCameraPosition = false
|
|
101
103
|
/// 是否正在处理 annotation 选择事件
|
|
@@ -481,6 +483,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
481
483
|
uiManager.setRotateEnabled(isRotateEnabled)
|
|
482
484
|
uiManager.setTiltEnabled(isTiltEnabled)
|
|
483
485
|
uiManager.setShowsUserLocation(showsUserLocation, followUser: followUserLocation)
|
|
486
|
+
applyUserLocationStyle()
|
|
484
487
|
mapView.distanceFilter = distanceFilter
|
|
485
488
|
mapView.headingFilter = headingFilter
|
|
486
489
|
}
|
|
@@ -511,6 +514,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
511
514
|
uiManager.setRotateEnabled(isRotateEnabled)
|
|
512
515
|
uiManager.setTiltEnabled(isTiltEnabled)
|
|
513
516
|
uiManager.setShowsUserLocation(showsUserLocation, followUser: followUserLocation)
|
|
517
|
+
applyUserLocationStyle()
|
|
514
518
|
uiManager.setShowsTraffic(showsTraffic)
|
|
515
519
|
uiManager.setShowsBuildings(showsBuildings)
|
|
516
520
|
uiManager.setShowsIndoorMap(showsIndoorMap)
|
|
@@ -683,6 +687,9 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
683
687
|
func setFollowUserLocation(_ follow: Bool) {
|
|
684
688
|
followUserLocation = follow
|
|
685
689
|
uiManager?.setShowsUserLocation(showsUserLocation, followUser: follow)
|
|
690
|
+
if showsUserLocation {
|
|
691
|
+
applyUserLocationStyle()
|
|
692
|
+
}
|
|
686
693
|
}
|
|
687
694
|
|
|
688
695
|
func setShowsUserLocation(_ show: Bool) {
|
|
@@ -695,6 +702,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
695
702
|
|
|
696
703
|
func setUserLocationRepresentation(_ config: [String: Any]) {
|
|
697
704
|
userLocationRepresentation = config
|
|
705
|
+
hasAppliedUserLocationStyleAfterLocationUpdate = false
|
|
698
706
|
if showsUserLocation {
|
|
699
707
|
uiManager?.setUserLocationRepresentation(config)
|
|
700
708
|
}
|
|
@@ -704,7 +712,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
704
712
|
* 应用用户位置样式
|
|
705
713
|
*/
|
|
706
714
|
private func applyUserLocationStyle() {
|
|
707
|
-
guard let config = userLocationRepresentation else { return }
|
|
715
|
+
guard showsUserLocation, let config = userLocationRepresentation else { return }
|
|
708
716
|
uiManager?.setUserLocationRepresentation(config)
|
|
709
717
|
}
|
|
710
718
|
|
|
@@ -974,6 +982,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
974
982
|
super.addSubview(resolvedMapView)
|
|
975
983
|
isMapLoaded = false
|
|
976
984
|
hasAppliedInitialCameraPosition = false
|
|
985
|
+
hasAppliedUserLocationStyleAfterLocationUpdate = false
|
|
977
986
|
|
|
978
987
|
cameraManager = CameraManager(mapView: resolvedMapView)
|
|
979
988
|
uiManager = UIManager(mapView: resolvedMapView)
|
|
@@ -1042,9 +1051,37 @@ extension ExpoGaodeMapView {
|
|
|
1042
1051
|
if let styleData = customMapStyleData {
|
|
1043
1052
|
uiManager.setCustomMapStyle(styleData)
|
|
1044
1053
|
}
|
|
1054
|
+
|
|
1055
|
+
applyUserLocationStyle()
|
|
1045
1056
|
|
|
1046
1057
|
onLoad(["loaded": true])
|
|
1047
1058
|
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* 定位更新回调
|
|
1062
|
+
*/
|
|
1063
|
+
public func mapView(_ mapView: MAMapView, didUpdate userLocation: MAUserLocation, updatingLocation: Bool) {
|
|
1064
|
+
guard updatingLocation, let location = userLocation.location else { return }
|
|
1065
|
+
|
|
1066
|
+
if !hasAppliedUserLocationStyleAfterLocationUpdate {
|
|
1067
|
+
applyUserLocationStyle()
|
|
1068
|
+
hasAppliedUserLocationStyleAfterLocationUpdate = true
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
let latitude = location.coordinate.latitude
|
|
1072
|
+
let longitude = location.coordinate.longitude
|
|
1073
|
+
guard latitude >= -90 && latitude <= 90,
|
|
1074
|
+
longitude >= -180 && longitude <= 180 else {
|
|
1075
|
+
return
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
onLocation([
|
|
1079
|
+
"latitude": latitude,
|
|
1080
|
+
"longitude": longitude,
|
|
1081
|
+
"accuracy": location.horizontalAccuracy,
|
|
1082
|
+
"timestamp": Date().timeIntervalSince1970 * 1000
|
|
1083
|
+
])
|
|
1084
|
+
}
|
|
1048
1085
|
|
|
1049
1086
|
/**
|
|
1050
1087
|
* 地图区域即将改变时触发 - 应用节流优化
|
|
@@ -1367,13 +1404,118 @@ extension ExpoGaodeMapView {
|
|
|
1367
1404
|
handleGaodePoiTouch(pois)
|
|
1368
1405
|
}
|
|
1369
1406
|
|
|
1407
|
+
private func getUserLocationAnnotationView(for mapView: MAMapView, annotation: MAAnnotation) -> MAAnnotationView? {
|
|
1408
|
+
guard let config = userLocationRepresentation,
|
|
1409
|
+
let imagePath = config["image"] as? String,
|
|
1410
|
+
!imagePath.isEmpty else {
|
|
1411
|
+
return nil
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
let reuseId = "ExpoGaodeMapUserLocationStyleReuseIdentifier"
|
|
1415
|
+
let annotationView: MAAnnotationView
|
|
1416
|
+
if let reusableView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseId) {
|
|
1417
|
+
annotationView = reusableView
|
|
1418
|
+
} else {
|
|
1419
|
+
annotationView = MAAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
|
|
1420
|
+
}
|
|
1421
|
+
annotationView.annotation = annotation
|
|
1422
|
+
annotationView.canShowCallout = false
|
|
1423
|
+
|
|
1424
|
+
let imageWidth = config["imageWidth"] as? Double
|
|
1425
|
+
let imageHeight = config["imageHeight"] as? Double
|
|
1426
|
+
let cacheKey = userLocationImageCacheKey(imagePath: imagePath, imageWidth: imageWidth, imageHeight: imageHeight)
|
|
1427
|
+
annotationView.accessibilityIdentifier = cacheKey
|
|
1428
|
+
|
|
1429
|
+
if let cached = IconBitmapCache.shared.image(forKey: cacheKey) {
|
|
1430
|
+
annotationView.image = cached
|
|
1431
|
+
return annotationView
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
annotationView.image = nil
|
|
1435
|
+
loadUserLocationImage(imagePath: imagePath, imageWidth: imageWidth, imageHeight: imageHeight, cacheKey: cacheKey) { [weak annotationView] image in
|
|
1436
|
+
guard let annotationView = annotationView,
|
|
1437
|
+
annotationView.accessibilityIdentifier == cacheKey else {
|
|
1438
|
+
return
|
|
1439
|
+
}
|
|
1440
|
+
annotationView.image = image
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
return annotationView
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
private func userLocationImageCacheKey(imagePath: String, imageWidth: Double?, imageHeight: Double?) -> String {
|
|
1447
|
+
let widthPart = imageWidth.map { String(Int($0.rounded())) } ?? "auto"
|
|
1448
|
+
let heightPart = imageHeight.map { String(Int($0.rounded())) } ?? "auto"
|
|
1449
|
+
return "userLocation|\(imagePath)|\(widthPart)x\(heightPart)"
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
private func loadUserLocationImage(
|
|
1453
|
+
imagePath: String,
|
|
1454
|
+
imageWidth: Double?,
|
|
1455
|
+
imageHeight: Double?,
|
|
1456
|
+
cacheKey: String,
|
|
1457
|
+
completion: @escaping (UIImage?) -> Void
|
|
1458
|
+
) {
|
|
1459
|
+
let finish: (UIImage?) -> Void = { image in
|
|
1460
|
+
if let image = image {
|
|
1461
|
+
IconBitmapCache.shared.setImage(image, forKey: cacheKey)
|
|
1462
|
+
}
|
|
1463
|
+
DispatchQueue.main.async {
|
|
1464
|
+
completion(image)
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
if imagePath.hasPrefix("http://") || imagePath.hasPrefix("https://") {
|
|
1469
|
+
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
|
|
1470
|
+
guard let self = self,
|
|
1471
|
+
let url = URL(string: imagePath),
|
|
1472
|
+
let data = try? Data(contentsOf: url),
|
|
1473
|
+
let image = UIImage(data: data) else {
|
|
1474
|
+
finish(nil)
|
|
1475
|
+
return
|
|
1476
|
+
}
|
|
1477
|
+
finish(self.resizeUserLocationImage(image, imageWidth: imageWidth, imageHeight: imageHeight))
|
|
1478
|
+
}
|
|
1479
|
+
return
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
let image: UIImage?
|
|
1483
|
+
if imagePath.hasPrefix("file://") {
|
|
1484
|
+
let path = String(imagePath.dropFirst(7))
|
|
1485
|
+
image = UIImage(contentsOfFile: path)
|
|
1486
|
+
} else {
|
|
1487
|
+
image = UIImage(named: imagePath)
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
guard let image = image else {
|
|
1491
|
+
finish(nil)
|
|
1492
|
+
return
|
|
1493
|
+
}
|
|
1494
|
+
finish(resizeUserLocationImage(image, imageWidth: imageWidth, imageHeight: imageHeight))
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
private func resizeUserLocationImage(_ image: UIImage, imageWidth: Double?, imageHeight: Double?) -> UIImage {
|
|
1498
|
+
guard let imageWidth = imageWidth,
|
|
1499
|
+
let imageHeight = imageHeight,
|
|
1500
|
+
imageWidth > 0,
|
|
1501
|
+
imageHeight > 0 else {
|
|
1502
|
+
return image
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
let targetSize = CGSize(width: imageWidth, height: imageHeight)
|
|
1506
|
+
let renderer = UIGraphicsImageRenderer(size: targetSize)
|
|
1507
|
+
return renderer.image { _ in
|
|
1508
|
+
image.draw(in: CGRect(origin: .zero, size: targetSize))
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1370
1512
|
/**
|
|
1371
1513
|
* 创建标注视图
|
|
1372
|
-
*
|
|
1514
|
+
* 定位蓝点默认返回 nil 使用系统样式;传入 image 时按官方建议自定义定位 annotationView。
|
|
1373
1515
|
*/
|
|
1374
1516
|
public func mapView(_ mapView: MAMapView, viewFor annotation: MAAnnotation) -> MAAnnotationView? {
|
|
1375
1517
|
if annotation.isKind(of: MAUserLocation.self) {
|
|
1376
|
-
return
|
|
1518
|
+
return getUserLocationAnnotationView(for: mapView, annotation: annotation)
|
|
1377
1519
|
}
|
|
1378
1520
|
|
|
1379
1521
|
// 🔑 支持 MAAnimatedAnnotation(平滑移动)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "ClusterEngine.hpp"
|
|
2
|
+
#include "GeometryEngine.hpp"
|
|
2
3
|
#include "QuadTree.hpp"
|
|
3
4
|
#include <cmath>
|
|
4
5
|
#include <algorithm>
|
|
@@ -11,19 +12,8 @@ static inline double cluster_toRadians(double degrees) {
|
|
|
11
12
|
return degrees * 0.017453292519943295;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
static double
|
|
15
|
-
|
|
16
|
-
const double lat2 = cluster_toRadians(b.lat);
|
|
17
|
-
const double dLat = lat2 - lat1;
|
|
18
|
-
const double dLon = cluster_toRadians(b.lon - a.lon);
|
|
19
|
-
|
|
20
|
-
const double sinHalfLat = std::sin(dLat * 0.5);
|
|
21
|
-
const double sinHalfLon = std::sin(dLon * 0.5);
|
|
22
|
-
|
|
23
|
-
const double h = sinHalfLat * sinHalfLat + std::cos(lat1) * std::cos(lat2) * sinHalfLon * sinHalfLon;
|
|
24
|
-
const double c = 2.0 * std::atan2(std::sqrt(h), std::sqrt(1.0 - h));
|
|
25
|
-
|
|
26
|
-
return 6371000.0 * c;
|
|
15
|
+
static double clusterDistanceMeters(const ClusterPoint& a, const ClusterPoint& b) {
|
|
16
|
+
return calculateDistance(a.lat, a.lon, b.lat, b.lon);
|
|
27
17
|
}
|
|
28
18
|
|
|
29
19
|
std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points, double radiusMeters) {
|
|
@@ -95,7 +85,7 @@ std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points
|
|
|
95
85
|
if (globalVisited[neighbor.index]) continue;
|
|
96
86
|
|
|
97
87
|
// Precise check
|
|
98
|
-
if (
|
|
88
|
+
if (clusterDistanceMeters(p, neighbor) <= radiusMeters) {
|
|
99
89
|
cluster.indices.push_back(neighbor.index);
|
|
100
90
|
globalVisited[neighbor.index] = true;
|
|
101
91
|
}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include
|
|
3
|
+
#include "ClusterTypes.hpp"
|
|
4
4
|
|
|
5
5
|
namespace gaodemap {
|
|
6
6
|
|
|
7
|
-
struct ClusterPoint {
|
|
8
|
-
double lat;
|
|
9
|
-
double lon;
|
|
10
|
-
int index;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
struct ClusterOutput {
|
|
14
|
-
int centerIndex;
|
|
15
|
-
std::vector<int> indices;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
7
|
std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points, double radiusMeters);
|
|
19
8
|
|
|
20
9
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "ColorParser.hpp"
|
|
2
2
|
#include <algorithm>
|
|
3
|
+
#include <cctype>
|
|
3
4
|
#include <sstream>
|
|
4
5
|
#include <vector>
|
|
5
6
|
#include <map>
|
|
@@ -109,13 +110,29 @@ static const std::map<std::string, uint32_t> NAMED_COLORS = {
|
|
|
109
110
|
{"transparent", 0x00000000}
|
|
110
111
|
};
|
|
111
112
|
|
|
113
|
+
static bool isSpace(unsigned char ch) {
|
|
114
|
+
return std::isspace(ch) != 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static char toLower(unsigned char ch) {
|
|
118
|
+
return static_cast<char>(std::tolower(ch));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static bool isHexDigit(unsigned char ch) {
|
|
122
|
+
return std::isxdigit(ch) != 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
112
125
|
uint32_t parseColor(const std::string& colorString) {
|
|
113
126
|
std::string str = colorString;
|
|
114
127
|
// Remove whitespace
|
|
115
|
-
str.erase(std::remove_if(str.begin(), str.end(),
|
|
128
|
+
str.erase(std::remove_if(str.begin(), str.end(), [](unsigned char ch) {
|
|
129
|
+
return isSpace(ch);
|
|
130
|
+
}), str.end());
|
|
116
131
|
// Lowercase for named colors check
|
|
117
132
|
std::string lowerStr = str;
|
|
118
|
-
std::transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(),
|
|
133
|
+
std::transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(), [](unsigned char ch) {
|
|
134
|
+
return toLower(ch);
|
|
135
|
+
});
|
|
119
136
|
|
|
120
137
|
if (NAMED_COLORS.count(lowerStr)) {
|
|
121
138
|
return NAMED_COLORS.at(lowerStr);
|
|
@@ -125,7 +142,9 @@ uint32_t parseColor(const std::string& colorString) {
|
|
|
125
142
|
return parseRgba(str); // pass original str with potential spaces if needed, but we removed them
|
|
126
143
|
}
|
|
127
144
|
|
|
128
|
-
if (lowerStr.find("#") == 0 || std::all_of(lowerStr.begin(), lowerStr.end(),
|
|
145
|
+
if (lowerStr.find("#") == 0 || std::all_of(lowerStr.begin(), lowerStr.end(), [](unsigned char ch) {
|
|
146
|
+
return isHexDigit(ch);
|
|
147
|
+
})) {
|
|
129
148
|
return parseHex(str);
|
|
130
149
|
}
|
|
131
150
|
|
package/ios/map/cpp/QuadTree.hpp
CHANGED
|
@@ -172,6 +172,9 @@ class UIManager: NSObject, MAMapViewDelegate {
|
|
|
172
172
|
// 是否显示方向指示
|
|
173
173
|
if let showsHeadingIndicator = config["showsHeadingIndicator"] as? Bool {
|
|
174
174
|
representation.showsHeadingIndicator = showsHeadingIndicator
|
|
175
|
+
if showsHeadingIndicator {
|
|
176
|
+
mapView.userTrackingMode = .followWithHeading
|
|
177
|
+
}
|
|
175
178
|
}
|
|
176
179
|
|
|
177
180
|
// 精度圈填充颜色
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-gaode-map-navigation",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.19",
|
|
4
|
+
"description": "Expo Modules AMap (Gaode Map) navigation for Expo/React Native: Config Plugin, route planning, turn-by-turn navigation, map features, and react-native-amap3d migration guidance.",
|
|
5
5
|
"author": "TomWq <582752848@qq.com> (https://github.com/TomWq)",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"build": "expo-module build && yarn build:plugin",
|
|
15
15
|
"build:plugin": "tsc --project plugin/tsconfig.json",
|
|
16
16
|
"clean": "expo-module clean",
|
|
17
|
-
"lint": "
|
|
17
|
+
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
18
18
|
"test": "npx jest --no-watchman --config jest.config.js --runInBand",
|
|
19
19
|
"prepare": "expo-module prepare && yarn build:plugin",
|
|
20
20
|
"postinstall": "node scripts/check-expo-modules.js",
|
|
@@ -25,11 +25,14 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@expo/vector-icons": "^15.0.3",
|
|
28
|
-
"@types/
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
28
|
+
"@types/node": "^22.18.0",
|
|
29
|
+
"@types/react": "~19.2.10",
|
|
30
|
+
"eslint": "^9.25.1",
|
|
31
|
+
"expo": "^57.0.1",
|
|
32
|
+
"expo-font": "~57.0.0",
|
|
33
|
+
"expo-module-scripts": "^56.0.3",
|
|
34
|
+
"react-native": "0.86.0",
|
|
35
|
+
"typescript": "^6.0.3"
|
|
33
36
|
},
|
|
34
37
|
"peerDependencies": {
|
|
35
38
|
"@expo/vector-icons": "*",
|
|
@@ -65,8 +68,13 @@
|
|
|
65
68
|
"expo-gaode-map-navigation",
|
|
66
69
|
"expo-amap",
|
|
67
70
|
"react-native-amap",
|
|
71
|
+
"react-native-amap3d",
|
|
72
|
+
"react-native-amap3d-alternative",
|
|
68
73
|
"react-native-gaode-map",
|
|
69
74
|
"rn-amap-navigation",
|
|
75
|
+
"expo-gaode",
|
|
76
|
+
"eas-build",
|
|
77
|
+
"fabric",
|
|
70
78
|
"amap",
|
|
71
79
|
"gaode-map",
|
|
72
80
|
"navigation",
|
|
@@ -155,12 +155,13 @@ const withGaodeMapAndroidManifest = (config, props) => {
|
|
|
155
155
|
if (!mainApplication['activity']) {
|
|
156
156
|
mainApplication['activity'] = [];
|
|
157
157
|
}
|
|
158
|
+
const activities = mainApplication['activity'];
|
|
158
159
|
const naviActivityName = 'com.amap.api.navi.AmapRouteActivity';
|
|
159
160
|
const naviConfigChanges = 'orientation|keyboardHidden|screenSize|navigation';
|
|
160
161
|
const naviTheme = '@android:style/Theme.NoTitleBar';
|
|
161
|
-
const activityIndex =
|
|
162
|
+
const activityIndex = activities.findIndex((item) => item.$?.['android:name'] === naviActivityName);
|
|
162
163
|
if (activityIndex === -1) {
|
|
163
|
-
|
|
164
|
+
activities.push({
|
|
164
165
|
$: {
|
|
165
166
|
'android:name': naviActivityName,
|
|
166
167
|
'android:theme': naviTheme,
|
|
@@ -169,13 +170,15 @@ const withGaodeMapAndroidManifest = (config, props) => {
|
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
172
|
else {
|
|
172
|
-
const existing =
|
|
173
|
-
existing
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
const existing = activities[activityIndex];
|
|
174
|
+
if (existing) {
|
|
175
|
+
existing.$ = {
|
|
176
|
+
...(existing.$ || {}),
|
|
177
|
+
'android:name': naviActivityName,
|
|
178
|
+
'android:theme': existing.$?.['android:theme'] || naviTheme,
|
|
179
|
+
'android:configChanges': existing.$?.['android:configChanges'] || naviConfigChanges,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
179
182
|
}
|
|
180
183
|
}
|
|
181
184
|
// 添加 API Key 到 application 标签
|
|
@@ -183,10 +186,11 @@ const withGaodeMapAndroidManifest = (config, props) => {
|
|
|
183
186
|
if (!mainApplication['meta-data']) {
|
|
184
187
|
mainApplication['meta-data'] = [];
|
|
185
188
|
}
|
|
189
|
+
const metaData = mainApplication['meta-data'];
|
|
186
190
|
// 检查是否已存在
|
|
187
|
-
const hasApiKey =
|
|
191
|
+
const hasApiKey = metaData.some((item) => item.$?.['android:name'] === 'com.amap.api.v2.apikey');
|
|
188
192
|
if (!hasApiKey) {
|
|
189
|
-
|
|
193
|
+
metaData.push({
|
|
190
194
|
$: {
|
|
191
195
|
'android:name': 'com.amap.api.v2.apikey',
|
|
192
196
|
'android:value': props.androidKey,
|
|
@@ -195,9 +199,10 @@ const withGaodeMapAndroidManifest = (config, props) => {
|
|
|
195
199
|
}
|
|
196
200
|
else {
|
|
197
201
|
// 更新现有的 API Key
|
|
198
|
-
const apiKeyIndex =
|
|
199
|
-
|
|
200
|
-
|
|
202
|
+
const apiKeyIndex = metaData.findIndex((item) => item.$?.['android:name'] === 'com.amap.api.v2.apikey');
|
|
203
|
+
const apiKeyMetaData = metaData[apiKeyIndex];
|
|
204
|
+
if (apiKeyMetaData) {
|
|
205
|
+
apiKeyMetaData.$ = {
|
|
201
206
|
'android:name': 'com.amap.api.v2.apikey',
|
|
202
207
|
'android:value': props.androidKey,
|
|
203
208
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "ClusterEngine.hpp"
|
|
2
|
+
#include "GeometryEngine.hpp"
|
|
2
3
|
#include "QuadTree.hpp"
|
|
3
4
|
#include <cmath>
|
|
4
5
|
#include <algorithm>
|
|
@@ -11,19 +12,8 @@ static inline double cluster_toRadians(double degrees) {
|
|
|
11
12
|
return degrees * 0.017453292519943295;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
static double
|
|
15
|
-
|
|
16
|
-
const double lat2 = cluster_toRadians(b.lat);
|
|
17
|
-
const double dLat = lat2 - lat1;
|
|
18
|
-
const double dLon = cluster_toRadians(b.lon - a.lon);
|
|
19
|
-
|
|
20
|
-
const double sinHalfLat = std::sin(dLat * 0.5);
|
|
21
|
-
const double sinHalfLon = std::sin(dLon * 0.5);
|
|
22
|
-
|
|
23
|
-
const double h = sinHalfLat * sinHalfLat + std::cos(lat1) * std::cos(lat2) * sinHalfLon * sinHalfLon;
|
|
24
|
-
const double c = 2.0 * std::atan2(std::sqrt(h), std::sqrt(1.0 - h));
|
|
25
|
-
|
|
26
|
-
return 6371000.0 * c;
|
|
15
|
+
static double clusterDistanceMeters(const ClusterPoint& a, const ClusterPoint& b) {
|
|
16
|
+
return calculateDistance(a.lat, a.lon, b.lat, b.lon);
|
|
27
17
|
}
|
|
28
18
|
|
|
29
19
|
std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points, double radiusMeters) {
|
|
@@ -95,7 +85,7 @@ std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points
|
|
|
95
85
|
if (globalVisited[neighbor.index]) continue;
|
|
96
86
|
|
|
97
87
|
// Precise check
|
|
98
|
-
if (
|
|
88
|
+
if (clusterDistanceMeters(p, neighbor) <= radiusMeters) {
|
|
99
89
|
cluster.indices.push_back(neighbor.index);
|
|
100
90
|
globalVisited[neighbor.index] = true;
|
|
101
91
|
}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include
|
|
3
|
+
#include "ClusterTypes.hpp"
|
|
4
4
|
|
|
5
5
|
namespace gaodemap {
|
|
6
6
|
|
|
7
|
-
struct ClusterPoint {
|
|
8
|
-
double lat;
|
|
9
|
-
double lon;
|
|
10
|
-
int index;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
struct ClusterOutput {
|
|
14
|
-
int centerIndex;
|
|
15
|
-
std::vector<int> indices;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
7
|
std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points, double radiusMeters);
|
|
19
8
|
|
|
20
9
|
}
|