expo-gaode-map 2.2.35-next.0 → 2.2.35-next.1
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 +16 -10
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +54 -52
- package/build/components/FoldableMapView.d.ts.map +1 -1
- package/build/components/FoldableMapView.js +46 -52
- package/build/components/FoldableMapView.js.map +1 -1
- package/build/components/overlays/Marker.d.ts.map +1 -1
- package/build/components/overlays/Marker.js +26 -30
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/hooks/useRoutePlayback.d.ts +6 -0
- package/build/hooks/useRoutePlayback.d.ts.map +1 -1
- package/build/hooks/useRoutePlayback.js +23 -2
- package/build/hooks/useRoutePlayback.js.map +1 -1
- package/build/module/geometry.d.ts +3 -0
- package/build/module/geometry.d.ts.map +1 -1
- package/build/module/geometry.js +3 -0
- package/build/module/geometry.js.map +1 -1
- package/build/module/location.d.ts +39 -0
- package/build/module/location.d.ts.map +1 -1
- package/build/module/location.js +39 -0
- package/build/module/location.js.map +1 -1
- package/build/module/nativeModule.d.ts +11 -0
- package/build/module/nativeModule.d.ts.map +1 -1
- package/build/module/nativeModule.js +14 -0
- package/build/module/nativeModule.js.map +1 -1
- package/build/module/normalizers.d.ts +28 -0
- package/build/module/normalizers.d.ts.map +1 -1
- package/build/module/normalizers.js +25 -0
- package/build/module/normalizers.js.map +1 -1
- package/build/module/privacy.d.ts +7 -1
- package/build/module/privacy.d.ts.map +1 -1
- package/build/module/privacy.js +4 -1
- package/build/module/privacy.js.map +1 -1
- package/build/module/sdk.d.ts +3 -0
- package/build/module/sdk.d.ts.map +1 -1
- package/build/module/sdk.js.map +1 -1
- package/build/types/common.types.d.ts +2 -2
- package/build/types/common.types.d.ts.map +1 -1
- package/build/types/common.types.js.map +1 -1
- package/build/utils/GeoUtils.d.ts +3 -0
- package/build/utils/GeoUtils.d.ts.map +1 -1
- package/build/utils/GeoUtils.js.map +1 -1
- package/build/utils/PermissionUtils.d.ts.map +1 -1
- package/build/utils/PermissionUtils.js +3 -0
- package/build/utils/PermissionUtils.js.map +1 -1
- package/build/utils/RouteUtils.d.ts +45 -0
- package/build/utils/RouteUtils.d.ts.map +1 -1
- package/build/utils/RouteUtils.js +91 -7
- package/build/utils/RouteUtils.js.map +1 -1
- package/build/utils/lazyNativeViewManager.d.ts +3 -0
- package/build/utils/lazyNativeViewManager.d.ts.map +1 -1
- package/build/utils/lazyNativeViewManager.js.map +1 -1
- package/ios/modules/LocationManager.swift +2 -4
- package/ios/overlays/MarkerView.swift +40 -26
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -37,10 +37,16 @@
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
### 可选模块
|
|
40
|
-
- 🔍
|
|
40
|
+
- 🔍 **搜索功能** - 已内置在 `expo-gaode-map` 中,提供 POI 搜索、周边搜索、关键字搜索、地理编码等
|
|
41
41
|
- 🧭 **导航功能**(expo-gaode-map-navigation)- 驾车、步行、骑行、货车路径规划,实时导航
|
|
42
42
|
- 🌐 **Web API**(expo-gaode-map-web-api)- 纯 JavaScript 实现的路径规划、地理编码、POI 搜索等
|
|
43
43
|
|
|
44
|
+
> ⚠️ **Search 模块维护说明**
|
|
45
|
+
>
|
|
46
|
+
> 从 `2.2.34` 开始,搜索能力已经集成到 `expo-gaode-map`(core)和 `expo-gaode-map-navigation` 的 map 能力中,`expo-gaode-map-search` 将不再作为独立模块继续维护。`2.2.33` 是最后一个支持 `expo-gaode-map-search` 单独集成的版本;新项目请直接从 `expo-gaode-map` 或 `expo-gaode-map-navigation` 导入搜索 API。
|
|
47
|
+
>
|
|
48
|
+
> 高德官方 Android SDK 在 `10.0.700` 之后将远程依赖由“地图 + 定位”调整为“地图 + 定位 + 搜索”,依赖地址从 `com.amap.api:3dmap:latest.integration` 调整为 `com.amap.api:3dmap-location-search:latest.integration`。继续单独维护 search 模块会带来重复合包和依赖冲突成本,因此搜索能力改为随 core / navigation 一起维护。
|
|
49
|
+
|
|
44
50
|
## 📦 安装
|
|
45
51
|
|
|
46
52
|
> ⚠️ **版本兼容性说明**:
|
|
@@ -57,7 +63,6 @@
|
|
|
57
63
|
npm install expo-gaode-map
|
|
58
64
|
|
|
59
65
|
# 可选模块
|
|
60
|
-
npm install expo-gaode-map-search # 搜索功能
|
|
61
66
|
npm install expo-gaode-map-web-api # Web API
|
|
62
67
|
```
|
|
63
68
|
|
|
@@ -113,8 +118,8 @@ npx expo run:ios
|
|
|
113
118
|
| 地图显示 | ✅ | ❌ | ✅ | ❌ |
|
|
114
119
|
| 定位 | ✅ | ❌ | ✅ | ❌ |
|
|
115
120
|
| 覆盖物 | ✅ | ❌ | ✅ | ❌ |
|
|
116
|
-
| POI 搜索 |
|
|
117
|
-
| 地理编码 |
|
|
121
|
+
| POI 搜索 | ✅ | ⚠️ 2.2.33 及以下 | ✅ | ✅ |
|
|
122
|
+
| 地理编码 | ✅ | ⚠️ 2.2.33 及以下 | ✅ | ✅ |
|
|
118
123
|
| 路径规划 | ❌ | ❌ | ✅ | ✅ |
|
|
119
124
|
| 实时导航 | ❌ | ❌ | ✅ | ❌ |
|
|
120
125
|
| 平台 | 原生 | 原生 | 原生 | Web/原生 |
|
|
@@ -125,11 +130,11 @@ npx expo run:ios
|
|
|
125
130
|
expo-gaode-map/
|
|
126
131
|
├── packages/
|
|
127
132
|
│ ├── core/ # expo-gaode-map(核心包)
|
|
128
|
-
│ │ └──
|
|
129
|
-
│ ├── search/ # expo-gaode-map-search
|
|
130
|
-
│ │ └── POI
|
|
133
|
+
│ │ └── 地图显示、定位、覆盖物、搜索
|
|
134
|
+
│ ├── search/ # expo-gaode-map-search(独立搜索包,2.2.33 后不再维护)
|
|
135
|
+
│ │ └── POI 搜索、地理编码(历史兼容)
|
|
131
136
|
│ ├── navigation/ # expo-gaode-map-navigation(导航包)
|
|
132
|
-
│ │ └──
|
|
137
|
+
│ │ └── 地图+搜索+导航(替代 core)
|
|
133
138
|
│ └── web-api/ # expo-gaode-map-web-api(Web API)
|
|
134
139
|
│ └── 纯 JS 实现的POI 搜索、地理编码、路径规划等
|
|
135
140
|
└── 注意:core 和 navigation 不能同时安装
|
|
@@ -145,7 +150,8 @@ expo-gaode-map/
|
|
|
145
150
|
|
|
146
151
|
### 2. 搜索功能和 Web API 有什么区别?
|
|
147
152
|
|
|
148
|
-
-
|
|
153
|
+
- **内置原生搜索**(`expo-gaode-map` / `expo-gaode-map-navigation`):原生实现,性能更好,无需网络请求,需要配置原生环境
|
|
154
|
+
- **独立搜索包**(`expo-gaode-map-search`):仅建议历史项目固定 `2.2.33` 使用,后续不再单独维护
|
|
149
155
|
- **Web API**(`expo-gaode-map-web-api`):纯 JavaScript,无需原生配置,跨平台更好,需要网络请求,但功能更加强大和完善
|
|
150
156
|
|
|
151
157
|
### 3. 如何配置 API Key?
|
|
@@ -249,6 +255,6 @@ MIT
|
|
|
249
255
|
如果你在使用过程中遇到问题或有任何建议,欢迎:
|
|
250
256
|
|
|
251
257
|
- 📝 提交 [GitHub Issue](https://github.com/TomWq/expo-gaode-map/issues)
|
|
252
|
-
- 💬
|
|
258
|
+
- 💬 查看并参与 [GitHub Issues](https://github.com/TomWq/expo-gaode-map/issues)
|
|
253
259
|
- ⭐ 给项目点个 Star 支持一下
|
|
254
260
|
- QQ:582752848
|
|
@@ -26,6 +26,8 @@ class ExpoGaodeMapModule : Module() {
|
|
|
26
26
|
/** 定位管理器实例 */
|
|
27
27
|
private var locationManager: LocationManager? = null
|
|
28
28
|
|
|
29
|
+
private fun jsValue(value: Any?): Any? = value
|
|
30
|
+
|
|
29
31
|
override fun definition() = ModuleDefinition {
|
|
30
32
|
Name("ExpoGaodeMap")
|
|
31
33
|
|
|
@@ -93,7 +95,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
Function("getPrivacyStatus") {
|
|
96
|
-
SDKInitializer.getPrivacyStatus()
|
|
98
|
+
jsValue(SDKInitializer.getPrivacyStatus())
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/**
|
|
@@ -109,14 +111,14 @@ class ExpoGaodeMapModule : Module() {
|
|
|
109
111
|
* @return SDK 版本号
|
|
110
112
|
*/
|
|
111
113
|
Function("getVersion") {
|
|
112
|
-
SDKInitializer.getVersion()
|
|
114
|
+
jsValue(SDKInitializer.getVersion())
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
/**
|
|
116
118
|
* 检查原生 SDK 是否已配置 API Key
|
|
117
119
|
*/
|
|
118
120
|
Function("isNativeSDKConfigured") {
|
|
119
|
-
try {
|
|
121
|
+
jsValue(try {
|
|
120
122
|
val context = appContext.reactContext!!
|
|
121
123
|
val apiKey = context.packageManager
|
|
122
124
|
.getApplicationInfo(context.packageName, android.content.pm.PackageManager.GET_META_DATA)
|
|
@@ -124,7 +126,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
124
126
|
!apiKey.isNullOrEmpty()
|
|
125
127
|
} catch (_: Exception) {
|
|
126
128
|
false
|
|
127
|
-
}
|
|
129
|
+
})
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
|
|
@@ -187,11 +189,11 @@ class ExpoGaodeMapModule : Module() {
|
|
|
187
189
|
Function("distanceBetweenCoordinates") { p1: Map<String, Any>?, p2: Map<String, Any>? ->
|
|
188
190
|
val cord1 = LatLngParser.parseLatLng(p1)
|
|
189
191
|
val cord2 = LatLngParser.parseLatLng(p2)
|
|
190
|
-
if (cord1 != null && cord2 != null) {
|
|
192
|
+
jsValue(if (cord1 != null && cord2 != null) {
|
|
191
193
|
GeometryUtils.calculateDistance(cord1, cord2)
|
|
192
194
|
} else {
|
|
193
195
|
0.0
|
|
194
|
-
}
|
|
196
|
+
})
|
|
195
197
|
}
|
|
196
198
|
|
|
197
199
|
/**
|
|
@@ -213,16 +215,16 @@ class ExpoGaodeMapModule : Module() {
|
|
|
213
215
|
val normalized = LatLngParser.parseLatLngList(points)
|
|
214
216
|
val safeMinZoom = minZoom ?: 3
|
|
215
217
|
val safeMaxZoom = maxZoom ?: 20
|
|
216
|
-
if (normalized.isEmpty()) return@Function safeMinZoom.toDouble()
|
|
218
|
+
if (normalized.isEmpty()) return@Function jsValue(safeMinZoom.toDouble())
|
|
217
219
|
|
|
218
|
-
GeometryUtils.calculateFitZoom(
|
|
220
|
+
jsValue(GeometryUtils.calculateFitZoom(
|
|
219
221
|
normalized,
|
|
220
222
|
viewportWidthPx ?: 390.0,
|
|
221
223
|
viewportHeightPx ?: 844.0,
|
|
222
224
|
paddingPx ?: 48.0,
|
|
223
225
|
safeMinZoom,
|
|
224
226
|
safeMaxZoom
|
|
225
|
-
)
|
|
227
|
+
))
|
|
226
228
|
}
|
|
227
229
|
|
|
228
230
|
/**
|
|
@@ -232,7 +234,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
232
234
|
*/
|
|
233
235
|
Function("calculatePolygonArea") { points: List<Any>? ->
|
|
234
236
|
val rings = LatLngParser.parseLatLngListList(points)
|
|
235
|
-
if (rings.isEmpty()) return@Function 0.0
|
|
237
|
+
if (rings.isEmpty()) return@Function jsValue(0.0)
|
|
236
238
|
|
|
237
239
|
// 第一项是外轮廓
|
|
238
240
|
var totalArea = GeometryUtils.calculatePolygonArea(rings[0])
|
|
@@ -245,7 +247,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
// 确保面积不为负数
|
|
248
|
-
max(0.0, totalArea)
|
|
250
|
+
jsValue(max(0.0, totalArea))
|
|
249
251
|
}
|
|
250
252
|
|
|
251
253
|
/**
|
|
@@ -255,24 +257,24 @@ class ExpoGaodeMapModule : Module() {
|
|
|
255
257
|
* @return 是否在多边形内
|
|
256
258
|
*/
|
|
257
259
|
Function("isPointInPolygon") { point: Map<String, Any>?, polygon: List<Any>? ->
|
|
258
|
-
val pt = LatLngParser.parseLatLng(point) ?: return@Function false
|
|
260
|
+
val pt = LatLngParser.parseLatLng(point) ?: return@Function jsValue(false)
|
|
259
261
|
val rings = LatLngParser.parseLatLngListList(polygon)
|
|
260
|
-
if (rings.isEmpty()) return@Function false
|
|
262
|
+
if (rings.isEmpty()) return@Function jsValue(false)
|
|
261
263
|
|
|
262
264
|
// 点必须在外轮廓内
|
|
263
265
|
val inOuter = GeometryUtils.isPointInPolygon(pt, rings[0])
|
|
264
|
-
if (!inOuter) return@Function false
|
|
266
|
+
if (!inOuter) return@Function jsValue(false)
|
|
265
267
|
|
|
266
268
|
// 点不能在任何内孔内
|
|
267
269
|
if (rings.size > 1) {
|
|
268
270
|
for (i in 1 until rings.size) {
|
|
269
271
|
if (GeometryUtils.isPointInPolygon(pt, rings[i])) {
|
|
270
|
-
return@Function false
|
|
272
|
+
return@Function jsValue(false)
|
|
271
273
|
}
|
|
272
274
|
}
|
|
273
275
|
}
|
|
274
276
|
|
|
275
|
-
true
|
|
277
|
+
jsValue(true)
|
|
276
278
|
}
|
|
277
279
|
|
|
278
280
|
/**
|
|
@@ -285,11 +287,11 @@ class ExpoGaodeMapModule : Module() {
|
|
|
285
287
|
Function("isPointInCircle") { point: Map<String, Any>?, center: Map<String, Any>?, radius: Double ->
|
|
286
288
|
val pt = LatLngParser.parseLatLng(point)
|
|
287
289
|
val cn = LatLngParser.parseLatLng(center)
|
|
288
|
-
if (pt != null && cn != null) {
|
|
290
|
+
jsValue(if (pt != null && cn != null) {
|
|
289
291
|
GeometryUtils.isPointInCircle(pt, cn, radius)
|
|
290
292
|
} else {
|
|
291
293
|
false
|
|
292
|
-
}
|
|
294
|
+
})
|
|
293
295
|
}
|
|
294
296
|
|
|
295
297
|
/**
|
|
@@ -301,11 +303,11 @@ class ExpoGaodeMapModule : Module() {
|
|
|
301
303
|
Function("calculateRectangleArea") { southWest: Map<String, Any>?, northEast: Map<String, Any>? ->
|
|
302
304
|
val sw = LatLngParser.parseLatLng(southWest)
|
|
303
305
|
val ne = LatLngParser.parseLatLng(northEast)
|
|
304
|
-
if (sw != null && ne != null) {
|
|
306
|
+
jsValue(if (sw != null && ne != null) {
|
|
305
307
|
GeometryUtils.calculateRectangleArea(sw, ne)
|
|
306
308
|
} else {
|
|
307
309
|
0.0
|
|
308
|
-
}
|
|
310
|
+
})
|
|
309
311
|
}
|
|
310
312
|
|
|
311
313
|
/**
|
|
@@ -318,7 +320,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
318
320
|
val pathPoints = LatLngParser.parseLatLngList(path)
|
|
319
321
|
val targetPoint = LatLngParser.parseLatLng(target)
|
|
320
322
|
|
|
321
|
-
if (targetPoint != null && pathPoints.isNotEmpty()) {
|
|
323
|
+
jsValue(if (targetPoint != null && pathPoints.isNotEmpty()) {
|
|
322
324
|
val result = GeometryUtils.getNearestPointOnPath(pathPoints, targetPoint)
|
|
323
325
|
if (result != null) {
|
|
324
326
|
mapOf(
|
|
@@ -332,7 +334,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
332
334
|
}
|
|
333
335
|
} else {
|
|
334
336
|
null
|
|
335
|
-
}
|
|
337
|
+
})
|
|
336
338
|
}
|
|
337
339
|
|
|
338
340
|
/**
|
|
@@ -342,16 +344,16 @@ class ExpoGaodeMapModule : Module() {
|
|
|
342
344
|
*/
|
|
343
345
|
Function("calculateCentroid") { polygon: List<Any>? ->
|
|
344
346
|
val rings = LatLngParser.parseLatLngListList(polygon)
|
|
345
|
-
if (rings.isEmpty()) return@Function null
|
|
347
|
+
if (rings.isEmpty()) return@Function jsValue(null)
|
|
346
348
|
|
|
347
349
|
if (rings.size == 1) {
|
|
348
350
|
val result = GeometryUtils.calculateCentroid(rings[0])
|
|
349
|
-
return@Function result?.let {
|
|
351
|
+
return@Function jsValue(result?.let {
|
|
350
352
|
mapOf(
|
|
351
353
|
"latitude" to it.latitude,
|
|
352
354
|
"longitude" to it.longitude
|
|
353
355
|
)
|
|
354
|
-
}
|
|
356
|
+
})
|
|
355
357
|
}
|
|
356
358
|
|
|
357
359
|
// 带孔多边形的质心计算: Σ(Area_i * Centroid_i) / Σ(Area_i)
|
|
@@ -376,14 +378,14 @@ class ExpoGaodeMapModule : Module() {
|
|
|
376
378
|
}
|
|
377
379
|
}
|
|
378
380
|
|
|
379
|
-
if (abs(totalArea) > 1e-9) {
|
|
381
|
+
jsValue(if (abs(totalArea) > 1e-9) {
|
|
380
382
|
mapOf(
|
|
381
383
|
"latitude" to sumLat / totalArea,
|
|
382
384
|
"longitude" to sumLon / totalArea
|
|
383
385
|
)
|
|
384
386
|
} else {
|
|
385
387
|
null
|
|
386
|
-
}
|
|
388
|
+
})
|
|
387
389
|
}
|
|
388
390
|
|
|
389
391
|
/**
|
|
@@ -393,10 +395,10 @@ class ExpoGaodeMapModule : Module() {
|
|
|
393
395
|
*/
|
|
394
396
|
Function("calculatePathBounds") { pointsList: List<Any>? ->
|
|
395
397
|
val points = LatLngParser.parseLatLngList(pointsList)
|
|
396
|
-
if (points.isEmpty()) return@Function null
|
|
398
|
+
if (points.isEmpty()) return@Function jsValue(null)
|
|
397
399
|
|
|
398
400
|
val result = GeometryUtils.calculatePathBounds(points)
|
|
399
|
-
result?.let {
|
|
401
|
+
jsValue(result?.let {
|
|
400
402
|
mapOf(
|
|
401
403
|
"north" to it.north,
|
|
402
404
|
"south" to it.south,
|
|
@@ -407,7 +409,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
407
409
|
"longitude" to it.centerLon
|
|
408
410
|
)
|
|
409
411
|
)
|
|
410
|
-
}
|
|
412
|
+
})
|
|
411
413
|
}
|
|
412
414
|
|
|
413
415
|
/**
|
|
@@ -418,11 +420,11 @@ class ExpoGaodeMapModule : Module() {
|
|
|
418
420
|
*/
|
|
419
421
|
Function("encodeGeoHash") { coordinate: Map<String, Any>?, precision: Int ->
|
|
420
422
|
val latLng = LatLngParser.parseLatLng(coordinate)
|
|
421
|
-
if (latLng != null) {
|
|
423
|
+
jsValue(if (latLng != null) {
|
|
422
424
|
GeometryUtils.encodeGeoHash(latLng, precision)
|
|
423
425
|
} else {
|
|
424
426
|
""
|
|
425
|
-
}
|
|
427
|
+
})
|
|
426
428
|
}
|
|
427
429
|
|
|
428
430
|
/**
|
|
@@ -434,12 +436,12 @@ class ExpoGaodeMapModule : Module() {
|
|
|
434
436
|
Function("simplifyPolyline") { points: List<Any>?, tolerance: Double ->
|
|
435
437
|
val poly = LatLngParser.parseLatLngList(points)
|
|
436
438
|
val simplified = GeometryUtils.simplifyPolyline(poly, tolerance)
|
|
437
|
-
simplified.map {
|
|
439
|
+
jsValue(simplified.map {
|
|
438
440
|
mapOf(
|
|
439
441
|
"latitude" to it.latitude,
|
|
440
442
|
"longitude" to it.longitude
|
|
441
443
|
)
|
|
442
|
-
}
|
|
444
|
+
})
|
|
443
445
|
}
|
|
444
446
|
|
|
445
447
|
/**
|
|
@@ -449,7 +451,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
449
451
|
*/
|
|
450
452
|
Function("calculatePathLength") { points: List<Any>? ->
|
|
451
453
|
val poly = LatLngParser.parseLatLngList(points)
|
|
452
|
-
GeometryUtils.calculatePathLength(poly)
|
|
454
|
+
jsValue(GeometryUtils.calculatePathLength(poly))
|
|
453
455
|
}
|
|
454
456
|
|
|
455
457
|
/**
|
|
@@ -459,12 +461,12 @@ class ExpoGaodeMapModule : Module() {
|
|
|
459
461
|
*/
|
|
460
462
|
Function("parsePolyline") { polylineStr: String? ->
|
|
461
463
|
val result = GeometryUtils.parsePolyline(polylineStr)
|
|
462
|
-
result.map {
|
|
464
|
+
jsValue(result.map {
|
|
463
465
|
mapOf(
|
|
464
466
|
"latitude" to it.latitude,
|
|
465
467
|
"longitude" to it.longitude
|
|
466
468
|
)
|
|
467
|
-
}
|
|
469
|
+
})
|
|
468
470
|
}
|
|
469
471
|
|
|
470
472
|
/**
|
|
@@ -476,7 +478,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
476
478
|
Function("getPointAtDistance") { points: List<Any>?, distance: Double ->
|
|
477
479
|
val poly = LatLngParser.parseLatLngList(points)
|
|
478
480
|
val result = GeometryUtils.getPointAtDistance(poly, distance)
|
|
479
|
-
if (result != null) {
|
|
481
|
+
jsValue(if (result != null) {
|
|
480
482
|
mapOf(
|
|
481
483
|
"latitude" to result.point.latitude,
|
|
482
484
|
"longitude" to result.point.longitude,
|
|
@@ -484,7 +486,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
484
486
|
)
|
|
485
487
|
} else {
|
|
486
488
|
null
|
|
487
|
-
}
|
|
489
|
+
})
|
|
488
490
|
}
|
|
489
491
|
|
|
490
492
|
/**
|
|
@@ -495,7 +497,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
495
497
|
*/
|
|
496
498
|
Function("latLngToTile") { coordinate: Map<String, Any>?, zoom: Int ->
|
|
497
499
|
val latLng = LatLngParser.parseLatLng(coordinate)
|
|
498
|
-
if (latLng != null) {
|
|
500
|
+
jsValue(if (latLng != null) {
|
|
499
501
|
val result = GeometryUtils.latLngToTile(latLng, zoom)
|
|
500
502
|
if (result != null && result.size >= 2) {
|
|
501
503
|
mapOf("x" to result[0], "y" to result[1])
|
|
@@ -504,7 +506,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
504
506
|
}
|
|
505
507
|
} else {
|
|
506
508
|
null
|
|
507
|
-
}
|
|
509
|
+
})
|
|
508
510
|
}
|
|
509
511
|
|
|
510
512
|
/**
|
|
@@ -517,9 +519,9 @@ class ExpoGaodeMapModule : Module() {
|
|
|
517
519
|
val y = (tile?.get("y") as? Number)?.toInt() ?: 0
|
|
518
520
|
val zoom = (tile?.get("z") as? Number)?.toInt() ?: (tile?.get("zoom") as? Number)?.toInt() ?: 0
|
|
519
521
|
val result = GeometryUtils.tileToLatLng(x, y, zoom)
|
|
520
|
-
result?.let {
|
|
522
|
+
jsValue(result?.let {
|
|
521
523
|
mapOf("latitude" to it.latitude, "longitude" to it.longitude)
|
|
522
|
-
}
|
|
524
|
+
})
|
|
523
525
|
}
|
|
524
526
|
|
|
525
527
|
/**
|
|
@@ -530,7 +532,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
530
532
|
*/
|
|
531
533
|
Function("latLngToPixel") { coordinate: Map<String, Any>?, zoom: Int ->
|
|
532
534
|
val latLng = LatLngParser.parseLatLng(coordinate)
|
|
533
|
-
if (latLng != null) {
|
|
535
|
+
jsValue(if (latLng != null) {
|
|
534
536
|
val result = GeometryUtils.latLngToPixel(latLng, zoom)
|
|
535
537
|
if (result != null && result.size >= 2) {
|
|
536
538
|
mapOf("x" to result[0], "y" to result[1])
|
|
@@ -539,7 +541,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
539
541
|
}
|
|
540
542
|
} else {
|
|
541
543
|
null
|
|
542
|
-
}
|
|
544
|
+
})
|
|
543
545
|
}
|
|
544
546
|
|
|
545
547
|
/**
|
|
@@ -552,9 +554,9 @@ class ExpoGaodeMapModule : Module() {
|
|
|
552
554
|
val x = (pixel?.get("x") as? Number)?.toDouble() ?: 0.0
|
|
553
555
|
val y = (pixel?.get("y") as? Number)?.toDouble() ?: 0.0
|
|
554
556
|
val result = GeometryUtils.pixelToLatLng(x, y, zoom)
|
|
555
|
-
result?.let {
|
|
557
|
+
jsValue(result?.let {
|
|
556
558
|
mapOf("latitude" to it.latitude, "longitude" to it.longitude)
|
|
557
|
-
}
|
|
559
|
+
})
|
|
558
560
|
}
|
|
559
561
|
|
|
560
562
|
/**
|
|
@@ -566,11 +568,11 @@ class ExpoGaodeMapModule : Module() {
|
|
|
566
568
|
Function("findPointInPolygons") { point: Map<String, Any>?, polygons: List<List<Any>>? ->
|
|
567
569
|
val pt = LatLngParser.parseLatLng(point)
|
|
568
570
|
val polys = polygons?.map { LatLngParser.parseLatLngList(it) }
|
|
569
|
-
if (pt != null && polys != null) {
|
|
571
|
+
jsValue(if (pt != null && polys != null) {
|
|
570
572
|
GeometryUtils.findPointInPolygons(pt, polys)
|
|
571
573
|
} else {
|
|
572
574
|
-1
|
|
573
|
-
}
|
|
575
|
+
})
|
|
574
576
|
}
|
|
575
577
|
|
|
576
578
|
/**
|
|
@@ -579,7 +581,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
579
581
|
* @param gridSizeMeters 网格大小(米)
|
|
580
582
|
*/
|
|
581
583
|
Function("generateHeatmapGrid") { points: List<Map<String, Any>>?, gridSizeMeters: Double ->
|
|
582
|
-
if (points.isNullOrEmpty()) return@Function emptyList<Map<String, Any>>()
|
|
584
|
+
if (points.isNullOrEmpty()) return@Function jsValue(emptyList<Map<String, Any>>())
|
|
583
585
|
|
|
584
586
|
val count = points.size
|
|
585
587
|
val latitudes = DoubleArray(count)
|
|
@@ -593,13 +595,13 @@ class ExpoGaodeMapModule : Module() {
|
|
|
593
595
|
}
|
|
594
596
|
|
|
595
597
|
val result = GeometryUtils.generateHeatmapGrid(latitudes, longitudes, weights, gridSizeMeters)
|
|
596
|
-
result.map {
|
|
598
|
+
jsValue(result.map {
|
|
597
599
|
mapOf(
|
|
598
600
|
"latitude" to it.latitude,
|
|
599
601
|
"longitude" to it.longitude,
|
|
600
602
|
"intensity" to it.intensity
|
|
601
603
|
)
|
|
602
|
-
}
|
|
604
|
+
})
|
|
603
605
|
}
|
|
604
606
|
|
|
605
607
|
// ==================== 定位配置 ====================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FoldableMapView.d.ts","sourceRoot":"","sources":["../../src/components/FoldableMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAIpE,OAAO,EAAoB,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qBAAqB;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe;IACf,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IACvE,eAAe;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,cAAc;IACd,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AA2ED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"FoldableMapView.d.ts","sourceRoot":"","sources":["../../src/components/FoldableMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAIpE,OAAO,EAAoB,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qBAAqB;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe;IACf,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IACvE,eAAe;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,cAAc;IACd,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AA2ED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA0F1D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,EACnC,MAAM,CAAC,EAAE,cAAc;;;;EA8DxB"}
|
|
@@ -63,11 +63,30 @@ export const FoldableMapView = ({ foldableConfig, ...mapProps }) => {
|
|
|
63
63
|
const [currentFoldState, setCurrentFoldState] = useState(FoldState.UNKNOWN);
|
|
64
64
|
const [deviceInfo, setDeviceInfo] = useState(PlatformDetector.getDeviceInfo());
|
|
65
65
|
const config = useMemo(() => createFoldableConfig(foldableConfig), [foldableConfig]);
|
|
66
|
-
const configRef = useRef(config);
|
|
67
66
|
const foldStateRef = useRef(currentFoldState);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const handleFoldStateChange = React.useEffectEvent(async (newInfo, debugPrefix) => {
|
|
68
|
+
const newFoldState = PlatformDetector.getFoldState();
|
|
69
|
+
const previousFoldState = foldStateRef.current;
|
|
70
|
+
if (config.debug) {
|
|
71
|
+
console.log(`[${debugPrefix}] 屏幕尺寸变化`);
|
|
72
|
+
console.log('新设备信息:', newInfo);
|
|
73
|
+
console.log('新折叠状态:', newFoldState);
|
|
74
|
+
}
|
|
75
|
+
if (newFoldState !== previousFoldState && previousFoldState !== FoldState.UNKNOWN) {
|
|
76
|
+
try {
|
|
77
|
+
await applyFoldStateCameraAdjustment(mapRef, previousFoldState, newFoldState, config, debugPrefix);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (config.debug) {
|
|
81
|
+
console.error(`[${debugPrefix}] 处理折叠状态变化失败:`, error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
foldStateRef.current = newFoldState;
|
|
86
|
+
setCurrentFoldState(newFoldState);
|
|
87
|
+
setDeviceInfo(newInfo);
|
|
88
|
+
config.onFoldStateChange(newFoldState, newInfo);
|
|
89
|
+
});
|
|
71
90
|
useEffect(() => {
|
|
72
91
|
foldStateRef.current = currentFoldState;
|
|
73
92
|
}, [currentFoldState]);
|
|
@@ -78,7 +97,7 @@ export const FoldableMapView = ({ foldableConfig, ...mapProps }) => {
|
|
|
78
97
|
useEffect(() => {
|
|
79
98
|
// 仅在 Android 折叠屏设备上启用
|
|
80
99
|
if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {
|
|
81
|
-
if (
|
|
100
|
+
if (config.debug) {
|
|
82
101
|
console.log('[FoldableMapView] 非折叠屏设备,跳过适配');
|
|
83
102
|
}
|
|
84
103
|
return;
|
|
@@ -86,42 +105,19 @@ export const FoldableMapView = ({ foldableConfig, ...mapProps }) => {
|
|
|
86
105
|
const initialState = PlatformDetector.getFoldState();
|
|
87
106
|
foldStateRef.current = initialState;
|
|
88
107
|
setCurrentFoldState(initialState);
|
|
89
|
-
if (
|
|
108
|
+
if (config.debug) {
|
|
90
109
|
console.log('[FoldableMapView] 初始化折叠屏适配');
|
|
91
110
|
console.log('设备信息:', deviceInfo);
|
|
92
111
|
console.log('初始折叠状态:', initialState);
|
|
93
112
|
}
|
|
94
113
|
// 监听屏幕尺寸变化
|
|
95
114
|
const removeListener = PlatformDetector.addDimensionChangeListener(async (newInfo) => {
|
|
96
|
-
|
|
97
|
-
const previousFoldState = foldStateRef.current;
|
|
98
|
-
const latestConfig = configRef.current;
|
|
99
|
-
if (latestConfig.debug) {
|
|
100
|
-
console.log('[FoldableMapView] 屏幕尺寸变化');
|
|
101
|
-
console.log('新设备信息:', newInfo);
|
|
102
|
-
console.log('新折叠状态:', newFoldState);
|
|
103
|
-
}
|
|
104
|
-
// 折叠状态变化时的处理
|
|
105
|
-
if (newFoldState !== previousFoldState && previousFoldState !== FoldState.UNKNOWN) {
|
|
106
|
-
try {
|
|
107
|
-
await applyFoldStateCameraAdjustment(mapRef, previousFoldState, newFoldState, latestConfig, 'FoldableMapView');
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
if (latestConfig.debug) {
|
|
111
|
-
console.error('[FoldableMapView] 处理折叠状态变化失败:', error);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
foldStateRef.current = newFoldState;
|
|
116
|
-
setCurrentFoldState(newFoldState);
|
|
117
|
-
setDeviceInfo(newInfo);
|
|
118
|
-
// 触发回调
|
|
119
|
-
latestConfig.onFoldStateChange(newFoldState, newInfo);
|
|
115
|
+
await handleFoldStateChange(newInfo, 'FoldableMapView');
|
|
120
116
|
});
|
|
121
117
|
return () => {
|
|
122
118
|
removeListener();
|
|
123
119
|
};
|
|
124
|
-
}, [deviceInfo.isFoldable]);
|
|
120
|
+
}, [config.debug, deviceInfo.isFoldable]);
|
|
125
121
|
return (<ExpoGaodeMapView ref={mapRef} {...mapProps}/>);
|
|
126
122
|
};
|
|
127
123
|
/**
|
|
@@ -134,13 +130,27 @@ export function useFoldableMap(mapRef, config) {
|
|
|
134
130
|
const [deviceInfo, setDeviceInfo] = useState(PlatformDetector.getDeviceInfo());
|
|
135
131
|
const mergedConfig = useMemo(() => createFoldableConfig(config), [config]);
|
|
136
132
|
const foldStateRef = useRef(foldState);
|
|
137
|
-
const configRef = useRef(mergedConfig);
|
|
138
133
|
useEffect(() => {
|
|
139
134
|
foldStateRef.current = foldState;
|
|
140
135
|
}, [foldState]);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
const handleFoldStateChange = React.useEffectEvent(async (newInfo) => {
|
|
137
|
+
const newFoldState = PlatformDetector.getFoldState();
|
|
138
|
+
const previousFoldState = foldStateRef.current;
|
|
139
|
+
if (newFoldState !== previousFoldState && previousFoldState !== FoldState.UNKNOWN) {
|
|
140
|
+
try {
|
|
141
|
+
await applyFoldStateCameraAdjustment(mapRef, previousFoldState, newFoldState, mergedConfig, 'useFoldableMap');
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
if (mergedConfig.debug) {
|
|
145
|
+
console.error('[useFoldableMap] 调整失败:', error);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
foldStateRef.current = newFoldState;
|
|
150
|
+
setFoldState(newFoldState);
|
|
151
|
+
setDeviceInfo(newInfo);
|
|
152
|
+
mergedConfig.onFoldStateChange(newFoldState, newInfo);
|
|
153
|
+
});
|
|
144
154
|
useEffect(() => {
|
|
145
155
|
if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {
|
|
146
156
|
return;
|
|
@@ -149,23 +159,7 @@ export function useFoldableMap(mapRef, config) {
|
|
|
149
159
|
foldStateRef.current = initialState;
|
|
150
160
|
setFoldState(initialState);
|
|
151
161
|
const removeListener = PlatformDetector.addDimensionChangeListener(async (newInfo) => {
|
|
152
|
-
|
|
153
|
-
const previousFoldState = foldStateRef.current;
|
|
154
|
-
const latestConfig = configRef.current;
|
|
155
|
-
if (newFoldState !== previousFoldState && previousFoldState !== FoldState.UNKNOWN) {
|
|
156
|
-
try {
|
|
157
|
-
await applyFoldStateCameraAdjustment(mapRef, previousFoldState, newFoldState, latestConfig, 'useFoldableMap');
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
if (latestConfig.debug) {
|
|
161
|
-
console.error('[useFoldableMap] 调整失败:', error);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
foldStateRef.current = newFoldState;
|
|
166
|
-
setFoldState(newFoldState);
|
|
167
|
-
setDeviceInfo(newInfo);
|
|
168
|
-
latestConfig.onFoldStateChange(newFoldState, newInfo);
|
|
162
|
+
await handleFoldStateChange(newInfo);
|
|
169
163
|
});
|
|
170
164
|
return () => {
|
|
171
165
|
removeListener();
|