expo-gaode-map 2.2.23-next.0 → 2.2.23

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.
Files changed (93) hide show
  1. package/README.md +7 -4
  2. package/android/src/main/cpp/cluster_jni.cpp +274 -0
  3. package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +296 -147
  4. package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapOfflineModule.kt +2 -2
  5. package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +14 -12
  6. package/android/src/main/java/expo/modules/gaodemap/MapPreloadManager.kt +2 -1
  7. package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +2 -0
  8. package/android/src/main/java/expo/modules/gaodemap/modules/SDKInitializer.kt +1 -8
  9. package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +9 -12
  10. package/android/src/main/java/expo/modules/gaodemap/overlays/CircleViewModule.kt +4 -4
  11. package/android/src/main/java/expo/modules/gaodemap/overlays/ClusterView.kt +15 -20
  12. package/android/src/main/java/expo/modules/gaodemap/overlays/HeatMapView.kt +5 -8
  13. package/android/src/main/java/expo/modules/gaodemap/overlays/HeatMapViewModule.kt +4 -4
  14. package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +63 -81
  15. package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerViewModule.kt +5 -1
  16. package/android/src/main/java/expo/modules/gaodemap/overlays/MultiPointView.kt +16 -13
  17. package/android/src/main/java/expo/modules/gaodemap/overlays/MultiPointViewModule.kt +1 -1
  18. package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonView.kt +24 -10
  19. package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonViewModule.kt +3 -3
  20. package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineView.kt +12 -14
  21. package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineViewModule.kt +2 -2
  22. package/android/src/main/java/expo/modules/gaodemap/services/LocationForegroundService.kt +2 -0
  23. package/android/src/main/java/expo/modules/gaodemap/utils/GeometryUtils.kt +179 -0
  24. package/android/src/main/java/expo/modules/gaodemap/utils/LatLngParser.kt +91 -0
  25. package/build/ExpoGaodeMapModule.d.ts.map +1 -1
  26. package/build/ExpoGaodeMapModule.js +241 -60
  27. package/build/ExpoGaodeMapModule.js.map +1 -1
  28. package/build/ExpoGaodeMapView.d.ts.map +1 -1
  29. package/build/ExpoGaodeMapView.js +17 -2
  30. package/build/ExpoGaodeMapView.js.map +1 -1
  31. package/build/components/FoldableMapView.d.ts +2 -2
  32. package/build/components/FoldableMapView.d.ts.map +1 -1
  33. package/build/components/FoldableMapView.js +12 -12
  34. package/build/components/FoldableMapView.js.map +1 -1
  35. package/build/components/MapUI.js.map +1 -1
  36. package/build/index.d.ts +0 -1
  37. package/build/index.d.ts.map +1 -1
  38. package/build/index.js +0 -2
  39. package/build/index.js.map +1 -1
  40. package/build/types/index.d.ts +2 -1
  41. package/build/types/index.d.ts.map +1 -1
  42. package/build/types/index.js.map +1 -1
  43. package/build/types/map-view.types.d.ts +3 -3
  44. package/build/types/map-view.types.d.ts.map +1 -1
  45. package/build/types/map-view.types.js.map +1 -1
  46. package/build/types/native-module.types.d.ts +102 -63
  47. package/build/types/native-module.types.d.ts.map +1 -1
  48. package/build/types/native-module.types.js.map +1 -1
  49. package/build/types/overlays.types.d.ts +5 -3
  50. package/build/types/overlays.types.d.ts.map +1 -1
  51. package/build/types/overlays.types.js.map +1 -1
  52. package/build/utils/ErrorHandler.d.ts +3 -3
  53. package/build/utils/ErrorHandler.d.ts.map +1 -1
  54. package/build/utils/ErrorHandler.js +1 -1
  55. package/build/utils/ErrorHandler.js.map +1 -1
  56. package/build/utils/GeoUtils.d.ts +5 -2
  57. package/build/utils/GeoUtils.d.ts.map +1 -1
  58. package/build/utils/GeoUtils.js +40 -7
  59. package/build/utils/GeoUtils.js.map +1 -1
  60. package/ios/ExpoGaodeMapModule.swift +250 -156
  61. package/ios/ExpoGaodeMapView.swift +5 -12
  62. package/ios/MapPreloadManager.swift +1 -1
  63. package/ios/overlays/CircleView.swift +15 -31
  64. package/ios/overlays/CircleViewModule.swift +3 -3
  65. package/ios/overlays/ClusterView.swift +5 -10
  66. package/ios/overlays/HeatMapView.swift +30 -41
  67. package/ios/overlays/HeatMapViewModule.swift +2 -2
  68. package/ios/overlays/MarkerView.swift +146 -57
  69. package/ios/overlays/MarkerViewModule.swift +4 -0
  70. package/ios/overlays/MultiPointView.swift +19 -19
  71. package/ios/overlays/MultiPointViewModule.swift +2 -2
  72. package/ios/overlays/PolygonView.swift +43 -51
  73. package/ios/overlays/PolygonViewModule.swift +5 -5
  74. package/ios/overlays/PolylineView.swift +8 -40
  75. package/ios/overlays/PolylineViewModule.swift +3 -3
  76. package/ios/utils/ClusterNative.h +44 -13
  77. package/ios/utils/ClusterNative.mm +148 -4
  78. package/ios/utils/ColorParser.swift +1 -1
  79. package/ios/utils/GeometryUtils.swift +34 -0
  80. package/ios/utils/LatLngParser.swift +87 -0
  81. package/package.json +1 -1
  82. package/shared/cpp/ColorParser.cpp +1 -1
  83. package/shared/cpp/GeometryEngine.cpp +159 -0
  84. package/shared/cpp/GeometryEngine.hpp +89 -0
  85. package/shared/cpp/QuadTree.cpp +2 -2
  86. package/shared/cpp/README.md +55 -0
  87. package/shared/cpp/tests/benchmark_js.js +41 -0
  88. package/shared/cpp/tests/run.sh +1 -0
  89. package/shared/cpp/tests/test_main.cpp +191 -14
  90. package/build/utils/ModuleLoader.d.ts +0 -74
  91. package/build/utils/ModuleLoader.d.ts.map +0 -1
  92. package/build/utils/ModuleLoader.js +0 -106
  93. package/build/utils/ModuleLoader.js.map +0 -1
package/README.md CHANGED
@@ -20,17 +20,20 @@
20
20
  ## ✨ 主要特性
21
21
 
22
22
  ### 核心功能(expo-gaode-map)
23
- - ✅ 完整的地图功能(多种地图类型、手势控制、相机操作,离线地图)
24
- - ✅ 精准定位(连续定位、单次定位、坐标转换)
23
+ - ✅ 完整的地图功能(多种地图类型、手势控制、相机操作,离线地图,自定义地图样式)
24
+ - ✅ 精准定位(连续定位、单次定位、坐标转换,定位蓝点配置)
25
25
  - ✅ 丰富的覆盖物(Circle、Marker、Polyline、Polygon、HeatMap、Cluster 等)
26
26
  - ✅ 友好的错误提示系统(详细的解决方案和文档链接)
27
27
  - ✅ 完整的 TypeScript 类型定义
28
28
  - ✅ 跨平台支持(Android、iOS)
29
29
  - ✅ 同时支持 React Native 新旧架构(Paper & Fabric)
30
30
  - ✅ 高测试覆盖率(75.7%,207 个单元测试)
31
- - ✅ 友好的错误提示系统
32
31
  - ✅ 支持自定义Marker覆盖物
33
- - ✅ 默认优化地图加载,减少内存占用
32
+ - ✅ 默认实现了优化地图加载,减少内存占用
33
+ - ✅ 几何运算(距离计算、面积计算等,由 C++ 实现)
34
+ - ✅ 丰富的使用案例
35
+ - ✅ 提供AI编程助手,帮助开发者快速集成和使用(https://TomWq.github.io/expo-gaode-map/guide/ai-skills.html)
36
+ - ✅ 更多内容和功能请查看 [完整文档](https://TomWq.github.io/expo-gaode-map/)
34
37
 
35
38
 
36
39
 
@@ -11,6 +11,7 @@ typedef void* jstring;
11
11
  typedef double jdouble;
12
12
  typedef int jint;
13
13
  typedef int jsize;
14
+ typedef void* jobjectArray;
14
15
  typedef unsigned char jboolean;
15
16
  #ifndef JNI_TRUE
16
17
  #define JNI_TRUE 1
@@ -232,6 +233,55 @@ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeIsPointInPolygon(
232
233
  #endif
233
234
  }
234
235
 
236
+ extern "C" JNIEXPORT jint JNICALL
237
+ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeFindPointInPolygons(
238
+ JNIEnv* env,
239
+ jclass,
240
+ jdouble pointLat,
241
+ jdouble pointLon,
242
+ jobjectArray polygonsLat,
243
+ jobjectArray polygonsLon
244
+ ) {
245
+ #if GAODE_HAVE_JNI
246
+ if (!polygonsLat || !polygonsLon) return -1;
247
+
248
+ const jsize polygonCount = env->GetArrayLength(polygonsLat);
249
+ if (polygonCount == 0) return -1;
250
+
251
+ std::vector<std::vector<gaodemap::GeoPoint>> polygons;
252
+ polygons.reserve(static_cast<size_t>(polygonCount));
253
+
254
+ for (jsize i = 0; i < polygonCount; ++i) {
255
+ jdoubleArray latArray = (jdoubleArray)env->GetObjectArrayElement(polygonsLat, i);
256
+ jdoubleArray lonArray = (jdoubleArray)env->GetObjectArrayElement(polygonsLon, i);
257
+
258
+ if (!latArray || !lonArray) continue;
259
+
260
+ const jsize pointCount = env->GetArrayLength(latArray);
261
+ jdouble* latValues = env->GetDoubleArrayElements(latArray, nullptr);
262
+ jdouble* lonValues = env->GetDoubleArrayElements(lonArray, nullptr);
263
+
264
+ std::vector<gaodemap::GeoPoint> polygon;
265
+ polygon.reserve(static_cast<size_t>(pointCount));
266
+ for (jsize j = 0; j < pointCount; ++j) {
267
+ polygon.push_back({latValues[j], lonValues[j]});
268
+ }
269
+
270
+ polygons.push_back(std::move(polygon));
271
+
272
+ env->ReleaseDoubleArrayElements(latArray, latValues, JNI_ABORT);
273
+ env->ReleaseDoubleArrayElements(lonArray, lonValues, JNI_ABORT);
274
+ env->DeleteLocalRef(latArray);
275
+ env->DeleteLocalRef(lonArray);
276
+ }
277
+
278
+ return gaodemap::findPointInPolygons(pointLat, pointLon, polygons);
279
+ #else
280
+ (void)env; (void)pointLat; (void)pointLon; (void)polygonsLat; (void)polygonsLon;
281
+ return -1;
282
+ #endif
283
+ }
284
+
235
285
  extern "C" JNIEXPORT jdouble JNICALL
236
286
  Java_expo_modules_gaodemap_utils_GeometryUtils_nativeCalculatePolygonArea(
237
287
  JNIEnv* env,
@@ -502,6 +552,60 @@ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeGetPointAtDistance(
502
552
  #endif
503
553
  }
504
554
 
555
+ extern "C" JNIEXPORT jdoubleArray JNICALL
556
+ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeCalculatePathBounds(
557
+ JNIEnv* env,
558
+ jclass,
559
+ jdoubleArray latitudes,
560
+ jdoubleArray longitudes
561
+ ) {
562
+ #if GAODE_HAVE_JNI
563
+ if (!latitudes || !longitudes) {
564
+ return nullptr;
565
+ }
566
+
567
+ const jsize countLat = env->GetArrayLength(latitudes);
568
+ const jsize countLon = env->GetArrayLength(longitudes);
569
+ if (countLat == 0 || countLat != countLon) {
570
+ return nullptr;
571
+ }
572
+
573
+ jdouble* latValues = env->GetDoubleArrayElements(latitudes, nullptr);
574
+ jdouble* lonValues = env->GetDoubleArrayElements(longitudes, nullptr);
575
+
576
+ std::vector<gaodemap::GeoPoint> points;
577
+ points.reserve(static_cast<size_t>(countLat));
578
+
579
+ for (jsize i = 0; i < countLat; ++i) {
580
+ points.push_back({latValues[i], lonValues[i]});
581
+ }
582
+
583
+ env->ReleaseDoubleArrayElements(latitudes, latValues, JNI_ABORT);
584
+ env->ReleaseDoubleArrayElements(longitudes, lonValues, JNI_ABORT);
585
+
586
+ gaodemap::PathBounds bounds = gaodemap::calculatePathBounds(points);
587
+
588
+ jdoubleArray resultArray = env->NewDoubleArray(6);
589
+ if (resultArray == nullptr) return nullptr;
590
+
591
+ jdouble buffer[6] = {
592
+ bounds.north,
593
+ bounds.south,
594
+ bounds.east,
595
+ bounds.west,
596
+ bounds.centerLat,
597
+ bounds.centerLon
598
+ };
599
+ env->SetDoubleArrayRegion(resultArray, 0, 6, buffer);
600
+ return resultArray;
601
+ #else
602
+ (void)env;
603
+ (void)latitudes;
604
+ (void)longitudes;
605
+ return nullptr;
606
+ #endif
607
+ }
608
+
505
609
  extern "C" JNIEXPORT jdoubleArray JNICALL
506
610
  Java_expo_modules_gaodemap_utils_GeometryUtils_nativeCalculateCentroid(
507
611
  JNIEnv* env,
@@ -572,3 +676,173 @@ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeEncodeGeoHash(
572
676
  return nullptr;
573
677
  #endif
574
678
  }
679
+
680
+ extern "C" JNIEXPORT jdoubleArray JNICALL
681
+ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeParsePolyline(
682
+ JNIEnv* env,
683
+ jclass,
684
+ jstring polylineStr
685
+ ) {
686
+ #if GAODE_HAVE_JNI
687
+ if (!polylineStr) {
688
+ return nullptr;
689
+ }
690
+
691
+ const char* nativeString = env->GetStringUTFChars(polylineStr, nullptr);
692
+ if (!nativeString) return nullptr;
693
+
694
+ std::string cppPolylineStr(nativeString);
695
+ env->ReleaseStringUTFChars(polylineStr, nativeString);
696
+
697
+ std::vector<gaodemap::GeoPoint> points = gaodemap::parsePolyline(cppPolylineStr);
698
+
699
+ if (points.empty()) {
700
+ return env->NewDoubleArray(0);
701
+ }
702
+
703
+ jdoubleArray result = env->NewDoubleArray(static_cast<jsize>(points.size() * 2));
704
+ if (result == nullptr) return nullptr;
705
+
706
+ std::vector<double> flatBuffer;
707
+ flatBuffer.reserve(points.size() * 2);
708
+ for (const auto& p : points) {
709
+ flatBuffer.push_back(p.lat);
710
+ flatBuffer.push_back(p.lon);
711
+ }
712
+
713
+ env->SetDoubleArrayRegion(result, 0, static_cast<jsize>(flatBuffer.size()), flatBuffer.data());
714
+ return result;
715
+ #else
716
+ (void)env;
717
+ (void)polylineStr;
718
+ return nullptr;
719
+ #endif
720
+ }
721
+
722
+ extern "C" JNIEXPORT jintArray JNICALL
723
+ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeLatLngToTile(
724
+ JNIEnv* env,
725
+ jclass,
726
+ jdouble lat,
727
+ jdouble lon,
728
+ jint zoom
729
+ ) {
730
+ #if GAODE_HAVE_JNI
731
+ gaodemap::TileResult result = gaodemap::latLngToTile(lat, lon, zoom);
732
+ jintArray array = env->NewIntArray(3);
733
+ jint buffer[3] = {result.x, result.y, result.z};
734
+ env->SetIntArrayRegion(array, 0, 3, buffer);
735
+ return array;
736
+ #else
737
+ (void)env; (void)lat; (void)lon; (void)zoom;
738
+ return nullptr;
739
+ #endif
740
+ }
741
+
742
+ extern "C" JNIEXPORT jdoubleArray JNICALL
743
+ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeTileToLatLng(
744
+ JNIEnv* env,
745
+ jclass,
746
+ jint x,
747
+ jint y,
748
+ jint zoom
749
+ ) {
750
+ #if GAODE_HAVE_JNI
751
+ gaodemap::GeoPoint result = gaodemap::tileToLatLng(x, y, zoom);
752
+ jdoubleArray array = env->NewDoubleArray(2);
753
+ jdouble buffer[2] = {result.lat, result.lon};
754
+ env->SetDoubleArrayRegion(array, 0, 2, buffer);
755
+ return array;
756
+ #else
757
+ (void)env; (void)x; (void)y; (void)zoom;
758
+ return nullptr;
759
+ #endif
760
+ }
761
+
762
+ extern "C" JNIEXPORT jdoubleArray JNICALL
763
+ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeLatLngToPixel(
764
+ JNIEnv* env,
765
+ jclass,
766
+ jdouble lat,
767
+ jdouble lon,
768
+ jint zoom
769
+ ) {
770
+ #if GAODE_HAVE_JNI
771
+ gaodemap::PixelResult result = gaodemap::latLngToPixel(lat, lon, zoom);
772
+ jdoubleArray array = env->NewDoubleArray(2);
773
+ jdouble buffer[2] = {result.x, result.y};
774
+ env->SetDoubleArrayRegion(array, 0, 2, buffer);
775
+ return array;
776
+ #else
777
+ (void)env; (void)lat; (void)lon; (void)zoom;
778
+ return nullptr;
779
+ #endif
780
+ }
781
+
782
+ extern "C" JNIEXPORT jdoubleArray JNICALL
783
+ Java_expo_modules_gaodemap_utils_GeometryUtils_nativePixelToLatLng(
784
+ JNIEnv* env,
785
+ jclass,
786
+ jdouble x,
787
+ jdouble y,
788
+ jint zoom
789
+ ) {
790
+ #if GAODE_HAVE_JNI
791
+ gaodemap::GeoPoint result = gaodemap::pixelToLatLng(x, y, zoom);
792
+ jdoubleArray array = env->NewDoubleArray(2);
793
+ jdouble buffer[2] = {result.lat, result.lon};
794
+ env->SetDoubleArrayRegion(array, 0, 2, buffer);
795
+ return array;
796
+ #else
797
+ (void)env; (void)x; (void)y; (void)zoom;
798
+ return nullptr;
799
+ #endif
800
+ }
801
+
802
+ extern "C" JNIEXPORT jdoubleArray JNICALL
803
+ Java_expo_modules_gaodemap_utils_GeometryUtils_nativeGenerateHeatmapGrid(
804
+ JNIEnv* env,
805
+ jclass,
806
+ jdoubleArray latitudes,
807
+ jdoubleArray longitudes,
808
+ jdoubleArray weights,
809
+ jdouble gridSizeMeters
810
+ ) {
811
+ #if GAODE_HAVE_JNI
812
+ if (!latitudes || !longitudes || !weights) return nullptr;
813
+ const jsize count = env->GetArrayLength(latitudes);
814
+ if (count == 0 || count != env->GetArrayLength(longitudes) || count != env->GetArrayLength(weights)) {
815
+ return nullptr;
816
+ }
817
+
818
+ jdouble* latVals = env->GetDoubleArrayElements(latitudes, nullptr);
819
+ jdouble* lonVals = env->GetDoubleArrayElements(longitudes, nullptr);
820
+ jdouble* weightVals = env->GetDoubleArrayElements(weights, nullptr);
821
+
822
+ std::vector<gaodemap::HeatmapPoint> points;
823
+ points.reserve(count);
824
+ for (jsize i = 0; i < count; ++i) {
825
+ points.push_back({latVals[i], lonVals[i], weightVals[i]});
826
+ }
827
+
828
+ env->ReleaseDoubleArrayElements(latitudes, latVals, JNI_ABORT);
829
+ env->ReleaseDoubleArrayElements(longitudes, lonVals, JNI_ABORT);
830
+ env->ReleaseDoubleArrayElements(weights, weightVals, JNI_ABORT);
831
+
832
+ auto cells = gaodemap::generateHeatmapGrid(points, gridSizeMeters);
833
+
834
+ jdoubleArray result = env->NewDoubleArray(static_cast<jsize>(cells.size() * 3));
835
+ std::vector<double> buffer;
836
+ buffer.reserve(cells.size() * 3);
837
+ for (const auto& c : cells) {
838
+ buffer.push_back(c.lat);
839
+ buffer.push_back(c.lon);
840
+ buffer.push_back(c.intensity);
841
+ }
842
+ env->SetDoubleArrayRegion(result, 0, static_cast<jsize>(buffer.size()), buffer.data());
843
+ return result;
844
+ #else
845
+ (void)env; (void)latitudes; (void)longitudes; (void)weights; (void)gridSizeMeters;
846
+ return nullptr;
847
+ #endif
848
+ }