Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-App
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
reason
2022-08-13 22:15:23 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
65d2e22b80b0b2f98594b18b988ab149ec2fc3d6
65d2e22b
1 parent
6f76cb34
百度定位逻辑
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
40 deletions
lib/poem/page/poem_publish.dart
lib/poem/page/select_address_page.dart
pubspec.yaml
lib/poem/page/poem_publish.dart
View file @
65d2e22
...
...
@@ -110,11 +110,12 @@ class PoemPublishState extends State<PoemPublish> {
NavigatorUtils
.
pushResult
(
context
,
PoemRouter
.
addressSelectPage
,
(
result
)
{
setState
(()
{
final
BMFPoiInfo
model
=
result
as
BMFPoiInfo
;
_longitude
=
model
.
pt
!.
longitude
.
toString
();
_latitude
=
model
.
pt
!.
latitude
.
toString
();
final
BMFSuggestionInfo
model
=
result
as
BMFSuggestionInfo
;
_longitude
=
model
.
location
!.
longitude
.
toString
();
_latitude
=
model
.
location
!.
latitude
.
toString
();
_address
=
'
${model.
province!}
${model.city!}
${model.area!}
${model.name
!}
'
;
'
${model.
city!}
${model.district!}
${model.address
!}
'
;
});
});
},
...
...
lib/poem/page/select_address_page.dart
View file @
65d2e22
...
...
@@ -20,7 +20,7 @@ class AddressSelectPage extends StatefulWidget {
}
class
AddressSelectPageState
extends
State
<
AddressSelectPage
>
{
List
<
BMF
Poi
Info
>
_list
=
[];
List
<
BMF
Suggestion
Info
>
_list
=
[];
int
_index
=
0
;
final
ScrollController
_controller
=
ScrollController
();
late
BMFMapController
_myMapController
;
...
...
@@ -65,8 +65,6 @@ class AddressSelectPageState extends State<AddressSelectPage> {
});
}
isLoading
=
true
;
///设置定位参数
_locationAction
();
_startLocation
();
...
...
@@ -99,20 +97,26 @@ class AddressSelectPageState extends State<AddressSelectPage> {
false
);
// 构造检索参数
BMFPoiNearbySearchOption
poiNearbySearchOption
=
BMFPoiNearbySearchOption
(
keywords:
<
String
>[
'小吃'
,
'学校'
,
'酒店'
,
'公司'
,
'住宅'
],
location:
BMFCoordinate
(
_locationResult
.
latitude
!,
_locationResult
.
longitude
!),
radius:
1000
,
isRadiusLimit:
true
);
BMFPoiNearbySearch
nearbySearch
=
BMFPoiNearbySearch
();
nearbySearch
.
onGetPoiNearbySearchResult
(
callback:
(
BMFPoiSearchResult
result
,
BMFSearchErrorCode
errorCode
)
{
_list
=
result
.
poiInfoList
!;
BMFSuggestionSearchOption
suggestionSearchOption
=
BMFSuggestionSearchOption
(
keyword:
'街道'
,
cityname:
_locationResult
.
city
,
location:
BMFCoordinate
(
_locationResult
.
latitude
!,
_locationResult
.
longitude
!),
cityLimit:
true
,
);
BMFSuggestionSearch
suggestionSearch
=
BMFSuggestionSearch
();
suggestionSearch
.
onGetSuggestSearchResult
(
callback:
(
BMFSuggestionSearchResult
result
,
BMFSearchErrorCode
errorCode
)
{
print
(
"sug检索回调 result =
${result.toMap()}
\n
errorCode =
${errorCode}
"
);
_list
=
result
.
suggestionList
!;
if
(
_list
.
isEmpty
)
{
Toast
.
show
(
"暂时无法搜索到该位置!"
);
}
isLoading
=
false
;
setState
(()
{});
});
bool
flag
=
await
nearbySearch
.
poiNearbySearch
(
poiNearbySearchOption
);
isLoading
=
false
;
bool
flag
=
await
suggestionSearch
.
suggestionSearch
(
suggestionSearchOption
);
}
/// 设置地图参数
...
...
@@ -141,6 +145,7 @@ class AddressSelectPageState extends State<AddressSelectPage> {
/// 启动定位
Future
<
void
>
_startLocation
()
async
{
isLoading
=
true
;
if
(
Platform
.
isIOS
)
{
await
myLocPlugin
.
singleLocation
({
'isReGeocode'
:
true
,
'isNetworkState'
:
true
});
...
...
@@ -173,27 +178,33 @@ class AddressSelectPageState extends State<AddressSelectPage> {
appBar:
SearchBar
(
hintText:
'搜索地址'
,
onPressed:
(
text
)
async
{
isLoading
=
true
;
_controller
.
animateTo
(
0.0
,
duration:
const
Duration
(
milliseconds:
10
),
curve:
Curves
.
ease
);
_index
=
0
;
// 构造检索参数
BMFPoiNearbySearchOption
poiNearbySearchOption
=
BMFPoiNearbySearchOption
(
keywords:
<
String
>[
text
],
location:
BMFCoordinate
(
_locationResult
.
latitude
!,
_locationResult
.
longitude
!),
radius:
1000
,
isRadiusLimit:
true
);
BMFPoiNearbySearch
nearbySearch
=
BMFPoiNearbySearch
();
nearbySearch
.
onGetPoiNearbySearchResult
(
callback:
(
BMFPoiSearchResult
result
,
BMFSearchErrorCode
errorCode
)
{
_list
=
result
.
poiInfoList
!;
BMFSuggestionSearchOption
suggestionSearchOption
=
BMFSuggestionSearchOption
(
keyword:
text
,
cityname:
_locationResult
.
city
,
location:
BMFCoordinate
(
_locationResult
.
latitude
!,
_locationResult
.
longitude
!),
cityLimit:
true
,
);
BMFSuggestionSearch
suggestionSearch
=
BMFSuggestionSearch
();
suggestionSearch
.
onGetSuggestSearchResult
(
callback:
(
BMFSuggestionSearchResult
result
,
BMFSearchErrorCode
errorCode
)
{
print
(
"sug检索回调 result =
${result.toMap()}
\n
errorCode =
${errorCode}
"
);
_list
=
result
.
suggestionList
!;
if
(
_list
.
isEmpty
)
{
Toast
.
show
(
"暂时无法搜索到该位置!"
);
}
isLoading
=
false
;
setState
(()
{});
});
bool
flag
=
await
nearbySearch
.
poiNearbySearch
(
poiNearbySearchOption
);
bool
flag
=
await
suggestionSearch
.
suggestionSearch
(
suggestionSearchOption
);
},
),
body:
SafeArea
(
...
...
@@ -223,14 +234,15 @@ class AddressSelectPageState extends State<AddressSelectPage> {
onTap:
()
{
_index
=
index
;
_myMapController
.
updateMapOptions
(
BMFMapOptions
(
center:
BMFCoordinate
(
_list
[
index
].
pt
!.
latitude
,
_list
[
index
].
pt
!.
longitude
)));
center:
BMFCoordinate
(
_list
[
index
].
location
!.
latitude
,
_list
[
index
].
location
!.
longitude
)));
/// 创建BMFMarker
BMFMarker
marker
=
BMFMarker
.
icon
(
position:
BMFCoordinate
(
_list
[
index
].
pt
!.
latitude
,
_list
[
index
].
pt
!.
longitude
),
_list
[
index
].
location
!.
latitude
,
_list
[
index
].
location
!.
longitude
),
title:
'flutterMaker'
,
identifier:
'flutter_marker'
,
icon:
'assets/images/map/icon_mark.png'
);
...
...
@@ -240,8 +252,8 @@ class AddressSelectPageState extends State<AddressSelectPage> {
///设置中心点
_myMapController
.
setCenterCoordinate
(
BMFCoordinate
(
_list
[
index
].
pt
!.
latitude
,
_list
[
index
].
pt
!.
longitude
),
BMFCoordinate
(
_list
[
index
].
location
!.
latitude
,
_list
[
index
].
location
!.
longitude
),
false
);
setState
(()
{});
...
...
@@ -275,7 +287,7 @@ class _AddressItem extends StatelessWidget {
this
.
onTap
,
})
:
super
(
key:
key
);
final
BMF
Poi
Info
poi
;
final
BMF
Suggestion
Info
poi
;
final
bool
isSelected
;
final
GestureTapCallback
?
onTap
;
...
...
@@ -291,7 +303,7 @@ class _AddressItem extends StatelessWidget {
children:
<
Widget
>[
Expanded
(
child:
Text
(
'
${poi.
province}
${poi.city}
${poi.area}
${poi.name
}
'
,
'
${poi.
city}
${poi.district}
${poi.address
}
'
,
),
),
Visibility
(
...
...
pubspec.yaml
View file @
65d2e22
...
...
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version
:
1.0.0+1
1
version
:
1.0.0+1
2
environment
:
sdk
:
"
>=2.16.2
<3.0.0"
...
...
Please
register
or
login
to post a comment