expo-gaode-map-navigation 1.1.5 → 1.1.6
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
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#include "ColorParser.hpp"
|
|
2
|
+
#include <algorithm>
|
|
3
|
+
#include <sstream>
|
|
4
|
+
#include <vector>
|
|
5
|
+
#include <map>
|
|
6
|
+
#include <cmath>
|
|
7
|
+
|
|
8
|
+
namespace gaodemap {
|
|
9
|
+
|
|
10
|
+
static uint32_t argb(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
|
|
11
|
+
return (static_cast<uint32_t>(a) << 24) |
|
|
12
|
+
(static_cast<uint32_t>(r) << 16) |
|
|
13
|
+
(static_cast<uint32_t>(g) << 8) |
|
|
14
|
+
static_cast<uint32_t>(b);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static uint32_t parseHex(const std::string& hexStr) {
|
|
18
|
+
std::string cleanHex = hexStr;
|
|
19
|
+
if (cleanHex.empty()) return 0;
|
|
20
|
+
if (cleanHex[0] == '#') {
|
|
21
|
+
cleanHex = cleanHex.substr(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
uint32_t val = 0;
|
|
25
|
+
try {
|
|
26
|
+
val = static_cast<uint32_t>(std::stoul(cleanHex, nullptr, 16));
|
|
27
|
+
} catch (...) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (cleanHex.length() == 6) {
|
|
32
|
+
// RRGGBB -> 0xFFRRGGBB
|
|
33
|
+
return 0xFF000000 | val;
|
|
34
|
+
} else if (cleanHex.length() == 8) {
|
|
35
|
+
// AARRGGBB -> AARRGGBB (Android style)
|
|
36
|
+
// Wait, web usually uses #RRGGBBAA.
|
|
37
|
+
// Android Color.parseColor("#RRGGBB") or "#AARRGGBB".
|
|
38
|
+
// Let's assume Android style #AARRGGBB for consistency with existing Kotlin code.
|
|
39
|
+
return val;
|
|
40
|
+
} else if (cleanHex.length() == 3) {
|
|
41
|
+
// RGB -> RRGGBB
|
|
42
|
+
uint32_t r = (val >> 8) & 0xF;
|
|
43
|
+
uint32_t g = (val >> 4) & 0xF;
|
|
44
|
+
uint32_t b = val & 0xF;
|
|
45
|
+
return 0xFF000000 | (r << 20) | (r << 16) | (g << 12) | (g << 8) | (b << 4) | b;
|
|
46
|
+
} else if (cleanHex.length() == 4) {
|
|
47
|
+
// ARGB -> AARRGGBB
|
|
48
|
+
uint32_t a = (val >> 12) & 0xF;
|
|
49
|
+
uint32_t r = (val >> 8) & 0xF;
|
|
50
|
+
uint32_t g = (val >> 4) & 0xF;
|
|
51
|
+
uint32_t b = val & 0xF;
|
|
52
|
+
return (a << 28) | (a << 24) | (r << 20) | (r << 16) | (g << 12) | (g << 8) | (b << 4) | b;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static uint32_t parseRgba(const std::string& str) {
|
|
59
|
+
// rgba(r, g, b, a) or rgb(r, g, b)
|
|
60
|
+
bool hasAlpha = str.find("rgba") == 0;
|
|
61
|
+
size_t start = str.find('(');
|
|
62
|
+
size_t end = str.find(')');
|
|
63
|
+
if (start == std::string::npos || end == std::string::npos) return 0;
|
|
64
|
+
|
|
65
|
+
std::string content = str.substr(start + 1, end - start - 1);
|
|
66
|
+
std::stringstream ss(content);
|
|
67
|
+
std::string segment;
|
|
68
|
+
std::vector<std::string> parts;
|
|
69
|
+
|
|
70
|
+
while (std::getline(ss, segment, ',')) {
|
|
71
|
+
parts.push_back(segment);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (parts.size() < 3) return 0;
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
int r = std::stoi(parts[0]);
|
|
78
|
+
int g = std::stoi(parts[1]);
|
|
79
|
+
int b = std::stoi(parts[2]);
|
|
80
|
+
int a = 255;
|
|
81
|
+
|
|
82
|
+
if (hasAlpha && parts.size() >= 4) {
|
|
83
|
+
float alphaFloat = std::stof(parts[3]);
|
|
84
|
+
a = static_cast<int>(alphaFloat * 255.0f);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return argb(
|
|
88
|
+
static_cast<uint8_t>(std::max(0, std::min(255, a))),
|
|
89
|
+
static_cast<uint8_t>(std::max(0, std::min(255, r))),
|
|
90
|
+
static_cast<uint8_t>(std::max(0, std::min(255, g))),
|
|
91
|
+
static_cast<uint8_t>(std::max(0, std::min(255, b)))
|
|
92
|
+
);
|
|
93
|
+
} catch (...) {
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static const std::map<std::string, uint32_t> NAMED_COLORS = {
|
|
99
|
+
{"red", 0xFFFF0000},
|
|
100
|
+
{"blue", 0xFF0000FF},
|
|
101
|
+
{"green", 0xFF00FF00},
|
|
102
|
+
{"yellow", 0xFFFFFF00},
|
|
103
|
+
{"black", 0xFF000000},
|
|
104
|
+
{"white", 0xFFFFFFFF},
|
|
105
|
+
{"gray", 0xFF888888},
|
|
106
|
+
{"grey", 0xFF888888},
|
|
107
|
+
{"cyan", 0xFF00FFFF},
|
|
108
|
+
{"magenta", 0xFFFF00FF},
|
|
109
|
+
{"transparent", 0x00000000}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
uint32_t parseColor(const std::string& colorString) {
|
|
113
|
+
std::string str = colorString;
|
|
114
|
+
// Remove whitespace
|
|
115
|
+
str.erase(std::remove_if(str.begin(), str.end(), ::isspace), str.end());
|
|
116
|
+
// Lowercase for named colors check
|
|
117
|
+
std::string lowerStr = str;
|
|
118
|
+
std::transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(), ::tolower);
|
|
119
|
+
|
|
120
|
+
if (NAMED_COLORS.count(lowerStr)) {
|
|
121
|
+
return NAMED_COLORS.at(lowerStr);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (lowerStr.find("rgb") == 0) {
|
|
125
|
+
return parseRgba(str); // pass original str with potential spaces if needed, but we removed them
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (lowerStr.find("#") == 0 || std::all_of(lowerStr.begin(), lowerStr.end(), ::isxdigit)) {
|
|
129
|
+
return parseHex(str);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return 0; // Default black -> Default failure (0)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
|
|
6
|
+
namespace gaodemap {
|
|
7
|
+
|
|
8
|
+
// Returns color as ARGB integer (0xAARRGGBB)
|
|
9
|
+
// Returns 0 (transparent/black) if parsing fails, but 0 is also valid (transparent).
|
|
10
|
+
// Maybe return a bool success? Or default to Black (0xFF000000) or Transparent (0x00000000).
|
|
11
|
+
// Android defaults to Black in existing code.
|
|
12
|
+
uint32_t parseColor(const std::string& colorString);
|
|
13
|
+
|
|
14
|
+
}
|