Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx_map_poi_search
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx_map_poi_search
Commits
23dcb8f7
提交
23dcb8f7
authored
4月 02, 2025
作者:
史晓晨
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:调试逆地理编码;
上级
e58d685c
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
90 行增加
和
15 行删除
+90
-15
gradle-wrapper.properties
android/gradle/wrapper/gradle-wrapper.properties
+7
-0
ClxMapPoiSearchImpl.kt
.../kotlin/com/clx/clx_map_poi_search/ClxMapPoiSearchImpl.kt
+43
-1
ClxMapPoiSearchPlugin.kt
...otlin/com/clx/clx_map_poi_search/ClxMapPoiSearchPlugin.kt
+8
-10
IPoiSearch.kt
.../src/main/kotlin/com/clx/clx_map_poi_search/IPoiSearch.kt
+2
-0
build.gradle
example/android/build.gradle
+1
-1
main.dart
example/lib/main.dart
+9
-3
clx_map_poi_search.dart
lib/clx_map_poi_search.dart
+5
-0
clx_map_poi_search_method_channel.dart
lib/core/clx_map_poi_search_method_channel.dart
+10
-0
clx_map_poi_search_platform_interface.dart
lib/core/clx_map_poi_search_platform_interface.dart
+5
-0
没有找到文件。
android/gradle/wrapper/gradle-wrapper.properties
0 → 100644
浏览文件 @
23dcb8f7
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-7.6.3-all.zip
networkTimeout
=
10000
validateDistributionUrl
=
true
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
android/src/main/kotlin/com/clx/clx_map_poi_search/ClxMapPoiSearchImpl.kt
浏览文件 @
23dcb8f7
...
...
@@ -4,10 +4,16 @@ import android.content.Context
import
android.util.Log
import
com.amap.api.services.core.LatLonPoint
import
com.amap.api.services.core.PoiItem
import
com.amap.api.services.geocoder.GeocodeResult
import
com.amap.api.services.geocoder.GeocodeSearch
import
com.amap.api.services.geocoder.RegeocodeQuery
import
com.amap.api.services.geocoder.RegeocodeResult
import
com.amap.api.services.poisearch.PoiResult
import
com.amap.api.services.poisearch.PoiSearch
class
ClxMapPoiSearchImpl
:
PoiSearch
.
OnPoiSearchListener
,
IPoiSearch
{
class
ClxMapPoiSearchImpl
:
PoiSearch
.
OnPoiSearchListener
,
IPoiSearch
,
GeocodeSearch
.
OnGeocodeSearchListener
{
/**
* 通过关键字搜索poi
...
...
@@ -63,6 +69,22 @@ class ClxMapPoiSearchImpl : PoiSearch.OnPoiSearchListener, IPoiSearch {
poiSearch
.
searchPOIAsyn
()
}
/**
* 逆地址编码
*/
override
fun
onGeocodeSearch
(
context
:
Context
?,
latitude
:
Double
?,
longitude
:
Double
?)
{
Log
.
d
(
Constants
.
TAG
,
"onGeocodeSearch: latitude = $latitude, longitude = $longitude"
)
val
geocodeSearch
=
GeocodeSearch
(
context
)
geocodeSearch
.
setOnGeocodeSearchListener
(
this
)
// 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系
val
query
=
RegeocodeQuery
(
LatLonPoint
(
latitude
?:
0.0
,
longitude
?:
0.0
),
1000.0f
,
GeocodeSearch
.
AMAP
)
geocodeSearch
.
getFromLocationAsyn
(
query
);
}
/**===============================PoiSearch回调================================**/
...
...
@@ -81,6 +103,24 @@ class ClxMapPoiSearchImpl : PoiSearch.OnPoiSearchListener, IPoiSearch {
Log
.
d
(
Constants
.
TAG
,
"onPoiItemSearched: poiItem = $poiItem"
)
}
/**
* 逆地址编码回调
*/
override
fun
onRegeocodeSearched
(
result
:
RegeocodeResult
?,
code
:
Int
)
{
// val arguments: MutableMap<String, Any> = HashMap(2)
Log
.
d
(
Constants
.
TAG
,
"onRegeocodeSearched: result: $result"
)
val
map
=
Utils
.
buildSearchRegeocodeResultList
(
result
,
code
)
Log
.
d
(
Constants
.
TAG
,
"onRegeocodeSearched: map: $map"
)
listener
?.
onPoiResult
(
map
)
}
/**
* 地址编码回调
*/
override
fun
onGeocodeSearched
(
p0
:
GeocodeResult
?,
p1
:
Int
)
{
TODO
(
"Not yet implemented"
)
}
/**===============================poi搜索结果listener================================**/
private
var
listener
:
OnPoiSearchedResult
?
=
null
...
...
@@ -92,4 +132,5 @@ class ClxMapPoiSearchImpl : PoiSearch.OnPoiSearchListener, IPoiSearch {
interface
OnPoiSearchedResult
{
fun
onPoiResult
(
data
:
Map
<
String
,
Any
>)
}
}
\ No newline at end of file
android/src/main/kotlin/com/clx/clx_map_poi_search/ClxMapPoiSearchPlugin.kt
浏览文件 @
23dcb8f7
...
...
@@ -43,23 +43,21 @@ class ClxMapPoiSearchPlugin : FlutterPlugin, MethodCallHandler,
"searchPOI#initPoiSearch"
->
{
}
"searchPOI#keywords"
->
mMapPoiSearchImpl
?.
onSearchKeywords
(
mContext
,
keywords
mContext
,
keywords
)
"searchPOI#around"
->
mMapPoiSearchImpl
?.
onSearchAround
(
mContext
,
latitude
,
longitude
mContext
,
latitude
,
longitude
)
"searchPOI#aroundAll"
->
mMapPoiSearchImpl
?.
onSearchAroundAll
(
mContext
,
keywords
,
latitude
,
longitude
,
city
mContext
,
keywords
,
latitude
,
longitude
,
city
)
"GeocodeSearch"
->
mMapPoiSearchImpl
?.
onGeocodeSearch
(
mContext
,
latitude
,
longitude
)
else
->
result
.
notImplemented
()
}
}
...
...
android/src/main/kotlin/com/clx/clx_map_poi_search/IPoiSearch.kt
浏览文件 @
23dcb8f7
...
...
@@ -10,4 +10,5 @@ interface IPoiSearch {
fun
onSearchAroundAll
(
context
:
Context
?,
keywords
:
String
?,
latitude
:
Double
?,
longitude
:
Double
?,
city
:
String
?)
fun
onGeocodeSearch
(
context
:
Context
?,
latitude
:
Double
?,
longitude
:
Double
?)
}
\ No newline at end of file
example/android/build.gradle
浏览文件 @
23dcb8f7
...
...
@@ -26,6 +26,6 @@ subprojects {
project
.
evaluationDependsOn
(
':app'
)
}
task
clean
(
type:
Delete
)
{
task
s
.
register
(
"clean"
,
Delete
)
{
delete
rootProject
.
buildDir
}
example/lib/main.dart
浏览文件 @
23dcb8f7
...
...
@@ -29,11 +29,14 @@ class _MyAppState extends State<MyApp> {
// var result1 = await ClxMapPoiSearch.instance.aroundSearch(31.230378, 121.473658);
// print("------ result1: $result1");
var
result2
=
await
ClxMapPoiSearch
.
instance
.
aroundSearchAll
(
"停车场"
,
city:
"南京"
,);
print
(
"------ result2:
$result2
"
);
}
void
onSearch
()
async
{
var
result2
=
await
ClxMapPoiSearch
.
instance
.
aroundSearch
(
31.230378
,
121.473658
);
print
(
"------ result2:
$result2
"
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
...
...
@@ -41,10 +44,13 @@ class _MyAppState extends State<MyApp> {
appBar:
AppBar
(
title:
const
Text
(
'Plugin example app'
),
),
body:
const
Center
(
body:
InkWell
(
onTap:
onSearch
,
child:
const
Center
(
child:
Text
(
'Running on:'
),
),
),
),
);
}
}
lib/clx_map_poi_search.dart
浏览文件 @
23dcb8f7
...
...
@@ -37,4 +37,9 @@ class ClxMapPoiSearch {
return
ClxMapPoiSearchPlatform
.
instance
.
getDistanceBetweenMapPoints
(
pointF
,
pointT
);
}
/// 逆地址编码
Future
<
Map
<
String
,
dynamic
>?>
geocodeSearch
(
double
latitude
,
double
longitude
)
{
return
ClxMapPoiSearchPlatform
.
instance
.
geocodeSearch
(
latitude
,
longitude
);
}
}
lib/core/clx_map_poi_search_method_channel.dart
浏览文件 @
23dcb8f7
...
...
@@ -53,6 +53,16 @@ class MethodChannelClxMapPoiSearch extends ClxMapPoiSearchPlatform {
return
PoiResult
.
toPoiResult
(
searchPOIResult
[
"searchPOIResult"
]);
}
/// 逆地址编码
@override
Future
<
Map
<
String
,
dynamic
>?>
geocodeSearch
(
double
?
latitude
,
double
?
longitude
)
async
{
var
result
=
await
methodChannel
.
invokeMethod
<
dynamic
>(
'GeocodeSearch'
,
<
String
,
dynamic
>{
'latitude'
:
latitude
,
'longitude'
:
longitude
,
});
return
result
;
}
/// 两点间的直线距离计算
@override
Future
<
double
?>
getDistanceBetweenMapPoints
(
List
<
double
?>
pointF
,
List
<
double
?>
pointT
,)
async
{
...
...
lib/core/clx_map_poi_search_platform_interface.dart
浏览文件 @
23dcb8f7
...
...
@@ -53,6 +53,11 @@ abstract class ClxMapPoiSearchPlatform extends PlatformInterface {
throw
UnimplementedError
(
'aroundSearchAll() has not been implemented.'
);
}
/// 逆地址编码
Future
<
Map
<
String
,
dynamic
>?>
geocodeSearch
(
double
?
latitude
,
double
?
longitude
)
async
{
throw
UnimplementedError
(
'geocodeSearch() has not been implemented.'
);
}
/// 两点间的直线距离计算
Future
<
double
?>
getDistanceBetweenMapPoints
(
List
<
double
?>
pointF
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论