expo-gaode-map-search 1.2.0-beta.0 → 1.3.0
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/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
- package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
- package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-expo-gaode-map-search.jar +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/aar/expo-gaode-map-search-debug.aar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +9 -9
- package/android/build.gradle +4 -3
- package/android/src/main/java/expo/modules/gaodemap/search/ExpoGaodeMapSearchModule.kt +354 -0
- package/build/ExpoGaodeMapSearchModule.js +33 -0
- package/ios/ExpoGaodeMapSearchModule.swift +415 -0
- package/package.json +16 -9
- package/src/ExpoGaodeMapSearch.types.ts +179 -0
- package/src/ExpoGaodeMapSearchModule.ts +46 -0
- package/src/index.ts +170 -0
- package/.eslintrc.js +0 -2
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/package.json.backup +0 -54
|
Binary file
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
#
|
|
1
|
+
#Tue Dec 09 10:50:17 CST 2025
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
1
|
|
2
2
|
0
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len
CHANGED
|
Binary file
|
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream
CHANGED
|
Binary file
|
package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
-- Merging decision tree log ---
|
|
2
2
|
manifest
|
|
3
|
-
ADDED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/
|
|
4
|
-
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/
|
|
3
|
+
ADDED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/tempAndroidManifest8133282779697147590.xml:2:13-83
|
|
4
|
+
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/tempAndroidManifest8133282779697147590.xml:2:13-83
|
|
5
5
|
package
|
|
6
|
-
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/
|
|
6
|
+
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/tempAndroidManifest8133282779697147590.xml
|
|
7
7
|
xmlns:android
|
|
8
|
-
ADDED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/
|
|
8
|
+
ADDED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/tempAndroidManifest8133282779697147590.xml:2:23-81
|
|
9
9
|
uses-sdk
|
|
10
|
-
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/
|
|
11
|
-
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/
|
|
12
|
-
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/
|
|
10
|
+
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/tempAndroidManifest8133282779697147590.xml reason: use-sdk injection requested
|
|
11
|
+
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/tempAndroidManifest8133282779697147590.xml
|
|
12
|
+
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/tempAndroidManifest8133282779697147590.xml
|
|
13
13
|
android:targetSdkVersion
|
|
14
|
-
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/
|
|
14
|
+
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/tempAndroidManifest8133282779697147590.xml
|
|
15
15
|
android:minSdkVersion
|
|
16
|
-
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/
|
|
16
|
+
INJECTED from /Users/wangqiang/Desktop/expo-gaode-map/packages/search/android/build/intermediates/tmp/ProcessLibraryManifest/debug/tempAndroidManifest8133282779697147590.xml
|
package/android/build.gradle
CHANGED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
package expo.modules.gaodemap.search
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.amap.api.services.core.LatLonPoint
|
|
5
|
+
import com.amap.api.services.core.PoiItem
|
|
6
|
+
import com.amap.api.services.help.Inputtips
|
|
7
|
+
import com.amap.api.services.help.InputtipsQuery
|
|
8
|
+
import com.amap.api.services.help.Tip
|
|
9
|
+
import com.amap.api.services.poisearch.PoiResult
|
|
10
|
+
import com.amap.api.services.poisearch.PoiSearch
|
|
11
|
+
import com.amap.api.services.route.RouteSearch
|
|
12
|
+
import com.amap.api.services.routepoisearch.RoutePOISearch
|
|
13
|
+
import com.amap.api.services.routepoisearch.RoutePOISearchQuery
|
|
14
|
+
import com.amap.api.services.routepoisearch.RoutePOISearchResult
|
|
15
|
+
import expo.modules.kotlin.Promise
|
|
16
|
+
import expo.modules.kotlin.modules.Module
|
|
17
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
18
|
+
|
|
19
|
+
class ExpoGaodeMapSearchModule : Module() {
|
|
20
|
+
private val context: Context
|
|
21
|
+
get() = appContext.reactContext ?: throw Exception("React context is null")
|
|
22
|
+
|
|
23
|
+
override fun definition() = ModuleDefinition {
|
|
24
|
+
Name("ExpoGaodeMapSearch")
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* POI 搜索
|
|
28
|
+
*/
|
|
29
|
+
AsyncFunction("searchPOI") { options: Map<String, Any?>, promise: Promise ->
|
|
30
|
+
try {
|
|
31
|
+
val keyword = options["keyword"] as? String
|
|
32
|
+
?: throw Exception("keyword is required")
|
|
33
|
+
|
|
34
|
+
val city = options["city"] as? String ?: ""
|
|
35
|
+
val types = options["types"] as? String ?: ""
|
|
36
|
+
val pageSize = (options["pageSize"] as? Number)?.toInt() ?: 20
|
|
37
|
+
val pageNum = (options["pageNum"] as? Number)?.toInt() ?: 1
|
|
38
|
+
|
|
39
|
+
val query = PoiSearch.Query(keyword, types, city)
|
|
40
|
+
query.pageSize = pageSize
|
|
41
|
+
query.pageNum = pageNum - 1 // 高德 SDK 从 0 开始
|
|
42
|
+
|
|
43
|
+
val poiSearch = PoiSearch(context, query)
|
|
44
|
+
|
|
45
|
+
poiSearch.setOnPoiSearchListener(object : PoiSearch.OnPoiSearchListener {
|
|
46
|
+
override fun onPoiSearched(result: PoiResult?, rCode: Int) {
|
|
47
|
+
if (rCode == 1000) {
|
|
48
|
+
promise.resolve(convertPoiResult(result))
|
|
49
|
+
} else {
|
|
50
|
+
promise.reject("SEARCH_ERROR", "Search failed with code: $rCode", null)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override fun onPoiItemSearched(item: PoiItem?, rCode: Int) {
|
|
55
|
+
// 不使用单个 POI 搜索
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
poiSearch.searchPOIAsyn()
|
|
60
|
+
} catch (e: Exception) {
|
|
61
|
+
promise.reject("SEARCH_ERROR", e.message, e)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 周边搜索
|
|
67
|
+
*/
|
|
68
|
+
AsyncFunction("searchNearby") { options: Map<String, Any?>, promise: Promise ->
|
|
69
|
+
try {
|
|
70
|
+
val keyword = options["keyword"] as? String
|
|
71
|
+
?: throw Exception("keyword is required")
|
|
72
|
+
|
|
73
|
+
val center = options["center"] as? Map<String, Any?>
|
|
74
|
+
?: throw Exception("center is required")
|
|
75
|
+
|
|
76
|
+
val latitude = (center["latitude"] as? Number)?.toDouble()
|
|
77
|
+
?: throw Exception("center.latitude is required")
|
|
78
|
+
val longitude = (center["longitude"] as? Number)?.toDouble()
|
|
79
|
+
?: throw Exception("center.longitude is required")
|
|
80
|
+
|
|
81
|
+
val radius = (options["radius"] as? Number)?.toInt() ?: 1000
|
|
82
|
+
val types = options["types"] as? String ?: ""
|
|
83
|
+
val pageSize = (options["pageSize"] as? Number)?.toInt() ?: 20
|
|
84
|
+
val pageNum = (options["pageNum"] as? Number)?.toInt() ?: 1
|
|
85
|
+
|
|
86
|
+
val query = PoiSearch.Query(keyword, types)
|
|
87
|
+
query.pageSize = pageSize
|
|
88
|
+
query.pageNum = pageNum - 1
|
|
89
|
+
|
|
90
|
+
val poiSearch = PoiSearch(context, query)
|
|
91
|
+
poiSearch.setBound(PoiSearch.SearchBound(
|
|
92
|
+
LatLonPoint(latitude, longitude), radius
|
|
93
|
+
))
|
|
94
|
+
|
|
95
|
+
poiSearch.setOnPoiSearchListener(object : PoiSearch.OnPoiSearchListener {
|
|
96
|
+
override fun onPoiSearched(result: PoiResult?, rCode: Int) {
|
|
97
|
+
if (rCode == 1000) {
|
|
98
|
+
promise.resolve(convertPoiResult(result))
|
|
99
|
+
} else {
|
|
100
|
+
promise.reject("SEARCH_ERROR", "Search failed with code: $rCode", null)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
override fun onPoiItemSearched(item: PoiItem?, rCode: Int) {}
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
poiSearch.searchPOIAsyn()
|
|
108
|
+
} catch (e: Exception) {
|
|
109
|
+
promise.reject("SEARCH_ERROR", e.message, e)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 沿途搜索
|
|
115
|
+
*/
|
|
116
|
+
AsyncFunction("searchAlong") { options: Map<String, Any?>, promise: Promise ->
|
|
117
|
+
try {
|
|
118
|
+
val keyword = options["keyword"] as? String
|
|
119
|
+
?: throw Exception("keyword is required")
|
|
120
|
+
|
|
121
|
+
val polyline = options["polyline"] as? List<Map<String, Any?>>
|
|
122
|
+
?: throw Exception("polyline is required")
|
|
123
|
+
|
|
124
|
+
if (polyline.size < 2) {
|
|
125
|
+
throw Exception("polyline must have at least 2 points")
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 转换路线点
|
|
129
|
+
val points = polyline.map { point ->
|
|
130
|
+
val lat = (point["latitude"] as? Number)?.toDouble()
|
|
131
|
+
?: throw Exception("Invalid polyline point")
|
|
132
|
+
val lng = (point["longitude"] as? Number)?.toDouble()
|
|
133
|
+
?: throw Exception("Invalid polyline point")
|
|
134
|
+
LatLonPoint(lat, lng)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
val startPoint = points.first()
|
|
138
|
+
val endPoint = points.last()
|
|
139
|
+
|
|
140
|
+
// 构造沿途搜索参数
|
|
141
|
+
val searchRange = 250 // 搜索半径(米)
|
|
142
|
+
// 使用枚举类型作为搜索类型
|
|
143
|
+
val searchType = when(keyword.lowercase()) {
|
|
144
|
+
"加油站", "加油" -> RoutePOISearch.RoutePOISearchType.TypeGasStation
|
|
145
|
+
"atm", "银行" -> RoutePOISearch.RoutePOISearchType.TypeATM
|
|
146
|
+
"汽修", "维修" -> RoutePOISearch.RoutePOISearchType.TypeMaintenanceStation
|
|
147
|
+
"厕所", "卫生间" -> RoutePOISearch.RoutePOISearchType.TypeToilet
|
|
148
|
+
else -> RoutePOISearch.RoutePOISearchType.TypeGasStation // 默认搜索加油站
|
|
149
|
+
}
|
|
150
|
+
val query = RoutePOISearchQuery(startPoint, endPoint, 1, searchType, searchRange)
|
|
151
|
+
|
|
152
|
+
val routePOISearch = RoutePOISearch(context, query)
|
|
153
|
+
|
|
154
|
+
routePOISearch.setPoiSearchListener(object : RoutePOISearch.OnRoutePOISearchListener {
|
|
155
|
+
override fun onRoutePoiSearched(result: RoutePOISearchResult?, rCode: Int) {
|
|
156
|
+
if (rCode == 1000 && result != null) {
|
|
157
|
+
promise.resolve(convertRoutePOIResult(result))
|
|
158
|
+
} else {
|
|
159
|
+
promise.reject("SEARCH_ERROR", "Route search failed with code: $rCode", null)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
routePOISearch.searchRoutePOIAsyn()
|
|
165
|
+
} catch (e: Exception) {
|
|
166
|
+
promise.reject("SEARCH_ERROR", e.message, e)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 多边形搜索(使用矩形范围代替)
|
|
172
|
+
*/
|
|
173
|
+
AsyncFunction("searchPolygon") { options: Map<String, Any?>, promise: Promise ->
|
|
174
|
+
try {
|
|
175
|
+
val keyword = options["keyword"] as? String
|
|
176
|
+
?: throw Exception("keyword is required")
|
|
177
|
+
|
|
178
|
+
val polygon = options["polygon"] as? List<Map<String, Any?>>
|
|
179
|
+
?: throw Exception("polygon is required")
|
|
180
|
+
|
|
181
|
+
val types = options["types"] as? String ?: ""
|
|
182
|
+
val pageSize = (options["pageSize"] as? Number)?.toInt() ?: 20
|
|
183
|
+
val pageNum = (options["pageNum"] as? Number)?.toInt() ?: 1
|
|
184
|
+
|
|
185
|
+
// 计算边界矩形
|
|
186
|
+
val points = polygon.map { point ->
|
|
187
|
+
val lat = (point["latitude"] as? Number)?.toDouble()
|
|
188
|
+
?: throw Exception("Invalid polygon point")
|
|
189
|
+
val lng = (point["longitude"] as? Number)?.toDouble()
|
|
190
|
+
?: throw Exception("Invalid polygon point")
|
|
191
|
+
LatLonPoint(lat, lng)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
val minLat = points.minOf { it.latitude }
|
|
195
|
+
val maxLat = points.maxOf { it.latitude }
|
|
196
|
+
val minLng = points.minOf { it.longitude }
|
|
197
|
+
val maxLng = points.maxOf { it.longitude }
|
|
198
|
+
|
|
199
|
+
val query = PoiSearch.Query(keyword, types)
|
|
200
|
+
query.pageSize = pageSize
|
|
201
|
+
query.pageNum = pageNum - 1
|
|
202
|
+
|
|
203
|
+
val poiSearch = PoiSearch(context, query)
|
|
204
|
+
// 使用矩形搜索代替多边形搜索
|
|
205
|
+
poiSearch.setBound(PoiSearch.SearchBound(
|
|
206
|
+
LatLonPoint(minLat, minLng),
|
|
207
|
+
LatLonPoint(maxLat, maxLng)
|
|
208
|
+
))
|
|
209
|
+
|
|
210
|
+
poiSearch.setOnPoiSearchListener(object : PoiSearch.OnPoiSearchListener {
|
|
211
|
+
override fun onPoiSearched(result: PoiResult?, rCode: Int) {
|
|
212
|
+
if (rCode == 1000) {
|
|
213
|
+
promise.resolve(convertPoiResult(result))
|
|
214
|
+
} else {
|
|
215
|
+
promise.reject("SEARCH_ERROR", "Search failed with code: $rCode", null)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
override fun onPoiItemSearched(item: PoiItem?, rCode: Int) {}
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
poiSearch.searchPOIAsyn()
|
|
223
|
+
} catch (e: Exception) {
|
|
224
|
+
promise.reject("SEARCH_ERROR", e.message, e)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 输入提示
|
|
230
|
+
*/
|
|
231
|
+
AsyncFunction("getInputTips") { options: Map<String, Any?>, promise: Promise ->
|
|
232
|
+
try {
|
|
233
|
+
val keyword = options["keyword"] as? String
|
|
234
|
+
?: throw Exception("keyword is required")
|
|
235
|
+
|
|
236
|
+
val city = options["city"] as? String ?: ""
|
|
237
|
+
val types = options["types"] as? String ?: ""
|
|
238
|
+
|
|
239
|
+
val query = InputtipsQuery(keyword, city)
|
|
240
|
+
if (types.isNotEmpty()) {
|
|
241
|
+
query.cityLimit = true
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
val inputtips = Inputtips(context, query)
|
|
245
|
+
|
|
246
|
+
inputtips.setInputtipsListener { tipList, rCode ->
|
|
247
|
+
if (rCode == 1000) {
|
|
248
|
+
promise.resolve(convertTipsResult(tipList))
|
|
249
|
+
} else {
|
|
250
|
+
promise.reject("TIPS_ERROR", "Input tips failed with code: $rCode", null)
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
inputtips.requestInputtipsAsyn()
|
|
255
|
+
} catch (e: Exception) {
|
|
256
|
+
promise.reject("TIPS_ERROR", e.message, e)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 转换 POI 搜索结果
|
|
263
|
+
*/
|
|
264
|
+
private fun convertPoiResult(result: PoiResult?): Map<String, Any?> {
|
|
265
|
+
if (result == null) {
|
|
266
|
+
return mapOf(
|
|
267
|
+
"pois" to emptyList<Map<String, Any?>>(),
|
|
268
|
+
"total" to 0,
|
|
269
|
+
"pageNum" to 1,
|
|
270
|
+
"pageSize" to 20,
|
|
271
|
+
"pageCount" to 0
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
val pois = result.pois?.map { poi ->
|
|
276
|
+
mapOf(
|
|
277
|
+
"id" to poi.poiId,
|
|
278
|
+
"name" to poi.title,
|
|
279
|
+
"address" to poi.snippet,
|
|
280
|
+
"location" to mapOf(
|
|
281
|
+
"latitude" to poi.latLonPoint?.latitude,
|
|
282
|
+
"longitude" to poi.latLonPoint?.longitude
|
|
283
|
+
),
|
|
284
|
+
"typeCode" to poi.typeCode,
|
|
285
|
+
"typeDes" to poi.typeDes,
|
|
286
|
+
"tel" to poi.tel,
|
|
287
|
+
"distance" to poi.distance,
|
|
288
|
+
"cityName" to poi.cityName,
|
|
289
|
+
"cityCode" to poi.cityCode,
|
|
290
|
+
"provinceName" to poi.provinceName,
|
|
291
|
+
"adName" to poi.adName,
|
|
292
|
+
"adCode" to poi.adCode
|
|
293
|
+
)
|
|
294
|
+
} ?: emptyList()
|
|
295
|
+
|
|
296
|
+
return mapOf(
|
|
297
|
+
"pois" to pois,
|
|
298
|
+
"total" to result.pageCount * result.query.pageSize,
|
|
299
|
+
"pageNum" to (result.query.pageNum + 1),
|
|
300
|
+
"pageSize" to result.query.pageSize,
|
|
301
|
+
"pageCount" to result.pageCount
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* 转换输入提示结果
|
|
307
|
+
*/
|
|
308
|
+
private fun convertTipsResult(tips: List<Tip>?): Map<String, Any?> {
|
|
309
|
+
val tipList = tips?.map { tip ->
|
|
310
|
+
mapOf(
|
|
311
|
+
"id" to tip.poiID,
|
|
312
|
+
"name" to tip.name,
|
|
313
|
+
"address" to tip.address,
|
|
314
|
+
"location" to tip.point?.let {
|
|
315
|
+
mapOf(
|
|
316
|
+
"latitude" to it.latitude,
|
|
317
|
+
"longitude" to it.longitude
|
|
318
|
+
)
|
|
319
|
+
},
|
|
320
|
+
"typeCode" to tip.typeCode,
|
|
321
|
+
"cityName" to tip.district,
|
|
322
|
+
"adName" to tip.district
|
|
323
|
+
)
|
|
324
|
+
} ?: emptyList()
|
|
325
|
+
|
|
326
|
+
return mapOf("tips" to tipList)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 转换沿途 POI 搜索结果
|
|
331
|
+
*/
|
|
332
|
+
private fun convertRoutePOIResult(result: RoutePOISearchResult): Map<String, Any?> {
|
|
333
|
+
val pois = result.routePois?.map { poi ->
|
|
334
|
+
mapOf(
|
|
335
|
+
"id" to poi.id,
|
|
336
|
+
"name" to poi.title,
|
|
337
|
+
"address" to "", // RoutePOIItem 没有 address 属性
|
|
338
|
+
"location" to mapOf(
|
|
339
|
+
"latitude" to poi.point?.latitude,
|
|
340
|
+
"longitude" to poi.point?.longitude
|
|
341
|
+
),
|
|
342
|
+
"distance" to poi.distance
|
|
343
|
+
)
|
|
344
|
+
} ?: emptyList()
|
|
345
|
+
|
|
346
|
+
return mapOf(
|
|
347
|
+
"pois" to pois,
|
|
348
|
+
"total" to pois.size,
|
|
349
|
+
"pageNum" to 1,
|
|
350
|
+
"pageSize" to pois.size,
|
|
351
|
+
"pageCount" to 1
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
}
|
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const expo_modules_core_1 = require("expo-modules-core");
|
|
4
|
+
/**
|
|
5
|
+
* 在加载原生搜索模块前,强制校验基础地图组件是否已安装。
|
|
6
|
+
* 支持两种“基础地图提供者”:expo-gaode-map 或 expo-gaode-map-navigation(导航内置地图)。
|
|
7
|
+
* 这样可避免导航与核心包的 SDK 冲突时无法使用搜索模块的问题。
|
|
8
|
+
*/
|
|
9
|
+
function ensureBaseInstalled() {
|
|
10
|
+
let installed = false;
|
|
11
|
+
try {
|
|
12
|
+
// 优先检测核心地图包
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
14
|
+
require('expo-gaode-map');
|
|
15
|
+
installed = true;
|
|
16
|
+
}
|
|
17
|
+
catch (_) {
|
|
18
|
+
// 再尝试导航包(内置地图能力)
|
|
19
|
+
try {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
21
|
+
require('expo-gaode-map-navigation');
|
|
22
|
+
installed = true;
|
|
23
|
+
}
|
|
24
|
+
catch (_) {
|
|
25
|
+
installed = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!installed) {
|
|
29
|
+
const msg = '[expo-gaode-map-search] 需要先安装基础地图组件,支持以下任一包:\n' +
|
|
30
|
+
' - expo-gaode-map(核心地图包),或\n' +
|
|
31
|
+
' - expo-gaode-map-navigation(导航包,内置地图能力)\n' +
|
|
32
|
+
'请先安装并完成原生配置后再重试。';
|
|
33
|
+
throw new Error(msg);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
ensureBaseInstalled();
|
|
4
37
|
/**
|
|
5
38
|
* 高德地图搜索模块
|
|
6
39
|
*
|