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-10-14 10:36:10 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
24c6e0de3abe85b7e0c43290dabb3baa2129d0dd
24c6e0de
1 parent
26e3041a
替换google map
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
39 deletions
lib/models/poisearch_model.dart
lib/poem/page/poem_publish.dart
lib/poem/page/select_address_page.dart
pubspec.yaml
lib/models/poisearch_model.dart
0 → 100644
View file @
24c6e0d
class
PoiSearch
{
PoiSearch
({
required
this
.
cityCode
,
required
this
.
cityName
,
required
this
.
provinceName
,
required
this
.
title
,
required
this
.
adName
,
required
this
.
provinceCode
,
required
this
.
latitude
,
required
this
.
longitude
,
});
PoiSearch
.
fromJsonMap
(
Map
<
String
,
dynamic
>
map
)
:
cityCode
=
map
[
'cityCode'
]
as
String
,
cityName
=
map
[
'cityName'
]
as
String
,
provinceName
=
map
[
'provinceName'
]
as
String
,
title
=
map
[
'title'
]
as
String
,
adName
=
map
[
'adName'
]
as
String
,
provinceCode
=
map
[
'provinceCode'
]
as
String
,
latitude
=
map
[
'latitude'
]
as
String
,
longitude
=
map
[
'longitude'
]
as
String
;
String
cityCode
;
String
cityName
;
String
provinceName
;
String
title
;
String
adName
;
String
provinceCode
;
String
latitude
;
String
longitude
;
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{};
data
[
'cityCode'
]
=
cityCode
;
data
[
'cityName'
]
=
cityName
;
data
[
'provinceName'
]
=
provinceName
;
data
[
'title'
]
=
title
;
data
[
'adName'
]
=
adName
;
data
[
'provinceCode'
]
=
provinceCode
;
data
[
'latitude'
]
=
latitude
;
data
[
'longitude'
]
=
longitude
;
return
data
;
}
}
lib/poem/page/poem_publish.dart
View file @
24c6e0d
import
'package:Parlando/models/nearby_response.dart'
;
import
'package:Parlando/models/upload_entity.dart'
;
import
'package:Parlando/net/dio_utils.dart'
;
import
'package:Parlando/net/http_api.dart'
;
...
...
@@ -109,12 +110,10 @@ class PoemPublishState extends State<PoemPublish> {
NavigatorUtils
.
pushResult
(
context
,
PoemRouter
.
addressSelectPage
,
(
result
)
{
setState
(()
{
// final BMFSuggestionInfo model =
// result as BMFSuggestionInfo;
// _longitude = model.location!.longitude.toString();
// _latitude = model.location!.latitude.toString();
// _address =
// '${model.city!} ${model.district!} ${model.address!}';
final
Results
model
=
result
as
Results
;
_longitude
=
model
.
geometry
!.
location
!.
lng
.
toString
();
_latitude
=
model
.
geometry
!.
location
!.
lat
.
toString
();
_address
=
'
${model.name}
${model.vicinity}
'
;
});
});
},
...
...
@@ -130,10 +129,20 @@ class PoemPublishState extends State<PoemPublish> {
size:
15
.
px
,
),
Gaps
.
hGap5
,
Text
(
_address
,
style:
const
TextStyle
(
color:
Colors
.
black45
),
),
Container
(
padding:
const
EdgeInsets
.
fromLTRB
(
0
,
0
,
10
,
10
),
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.8
,
alignment:
Alignment
.
centerLeft
,
child:
Column
(
children:
<
Widget
>[
Text
(
_address
,
style:
const
TextStyle
(
color:
Colors
.
black45
),
textAlign:
TextAlign
.
left
,
),
],
),
)
],
),
),
...
...
@@ -209,12 +218,12 @@ class PoemPublishState extends State<PoemPublish> {
Gaps
.
vGap10
,
isUploading
?
Padding
(
padding:
const
EdgeInsets
.
all
(
20
),
child:
ValueListenableBuilder
<
double
>(
builder:
_buildWithValue
,
valueListenable:
_counter
,
),
)
padding:
const
EdgeInsets
.
all
(
20
),
child:
ValueListenableBuilder
<
double
>(
builder:
_buildWithValue
,
valueListenable:
_counter
,
),
)
:
Container
(),
],
),
...
...
@@ -224,10 +233,10 @@ class PoemPublishState extends State<PoemPublish> {
),
isPublishing
?
const
Center
(
child:
CupertinoActivityIndicator
(
radius:
16.0
,
),
)
child:
CupertinoActivityIndicator
(
radius:
16.0
,
),
)
:
Container
(),
],
),
...
...
lib/poem/page/select_address_page.dart
View file @
24c6e0d
import
'dart:async'
;
import
'dart:convert'
;
import
'package:Parlando/models/nearby_response.dart'
as
nearby
;
import
'package:Parlando/routers/fluro_navigator.dart'
;
import
'package:Parlando/util/toast_utils.dart'
;
import
'package:flutter/material.dart'
;
import
'package:Parlando/widgets/my_button.dart'
;
import
'package:Parlando/widgets/search_bar.dart'
;
...
...
@@ -17,7 +19,7 @@ class AddressSelectPage extends StatefulWidget {
}
class
AddressSelectPageState
extends
State
<
AddressSelectPage
>
{
// List<BMFSuggestionInfo
> _list = [];
List
<
nearby
.
Results
>
_list
=
[];
int
_index
=
0
;
final
ScrollController
_controller
=
ScrollController
();
LatLng
_center
=
const
LatLng
(
45.521563
,
-
122.677433
);
...
...
@@ -26,8 +28,8 @@ class AddressSelectPageState extends State<AddressSelectPage> {
int
_markerIdCounter
=
1
;
Map
<
MarkerId
,
Marker
>
markers
=
<
MarkerId
,
Marker
>{};
late
StreamSubscription
_locationSubscription
;
String
radius
=
"
3
0"
;
String
apiKey
=
""
;
String
radius
=
"
100
0"
;
String
apiKey
=
"
AIzaSyDQZsMULyO-UtiSht4_MFi1uHT4BIqasjw
"
;
nearby
.
NearbyPlacesResponse
nearbyPlacesResponse
=
nearby
.
NearbyPlacesResponse
();
...
...
@@ -69,13 +71,17 @@ class AddressSelectPageState extends State<AddressSelectPage> {
});
}
void
getNearbyPlaces
()
async
{
var
url
=
Uri
.
parse
(
'
${'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${_center.latitude}
,
${_center.longitude}
&radius=
$radius
'
}&
key
=
$apiKey
');
void
getNearbyPlaces
(
String
keyword
)
async
{
String
uri
=
'
${'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${_center.latitude}
,
${_center.longitude}
&radius=
$radius
'
}&
key
=
$apiKey
&
keyword
=
$keyword
';
var url = Uri.parse(uri);
var response = await http.post(url);
nearbyPlacesResponse =
nearby.NearbyPlacesResponse.fromJson(jsonDecode(response.body));
setState(() {});
_list = nearbyPlacesResponse.results!;
setState(() {
isLoading = false;
});
}
void _onMapCreated(GoogleMapController controller) {
...
...
@@ -91,6 +97,7 @@ class AddressSelectPageState extends State<AddressSelectPage> {
setState(() {
markers[markerId] = marker;
});
getNearbyPlaces("");
}
@override
...
...
@@ -105,6 +112,7 @@ class AddressSelectPageState extends State<AddressSelectPage> {
duration: const Duration(milliseconds: 10), curve: Curves.ease);
_index = 0;
// 构造检索参数
getNearbyPlaces(text);
},
),
body: SafeArea(
...
...
@@ -126,12 +134,13 @@ class AddressSelectPageState extends State<AddressSelectPage> {
child: isLoading
? const GFLoader()
: ListView.separated(
controller: _controller,
itemCount:
1
,
controller: _controller,
itemCount:
_list.length
,
separatorBuilder: (_, index) => const Divider(),
itemBuilder: (_, index) {
return _AddressItem(
isSelected: _index == index,
date: _list[index],
onTap: () {
_index = index;
setState(() {});
...
...
@@ -142,11 +151,11 @@ class AddressSelectPageState extends State<AddressSelectPage> {
),
MyButton(
onPressed: () {
//
if (_list.isEmpty) {
//
Toast.show('
未选择地址!
');
//
return;
//
}
//
NavigatorUtils.goBackWithParams(context, _list[_index]);
if (_list.isEmpty) {
Toast.show('
未选择地址!
');
return;
}
NavigatorUtils.goBackWithParams(context, _list[_index]);
},
text: '
确认选择地址
',
)
...
...
@@ -160,11 +169,11 @@ class AddressSelectPageState extends State<AddressSelectPage> {
class _AddressItem extends StatelessWidget {
const _AddressItem({
Key? key,
required this.date,
this.isSelected = false,
this.onTap,
}) : super(key: key);
// final BMFSuggestionInfo poi;
final nearby.Results date;
final bool isSelected;
final GestureTapCallback? onTap;
...
...
@@ -178,9 +187,9 @@ class _AddressItem extends StatelessWidget {
height: 50.0,
child: Row(
children: <Widget>[
const
Expanded(
Expanded(
child: Text(
'
', // '
$
{
poi
.
city
}
$
{
poi
.
district
}
$
{
poi
.
address
}
',
'
$
{
date
.
name
}
$
{
date
.
vicinity
}
',
),
),
Visibility(
...
...
pubspec.yaml
View file @
24c6e0d
...
...
@@ -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
2
version
:
1.0.0+1
3
environment
:
sdk
:
"
>=2.16.2
<3.0.0"
...
...
Please
register
or
login
to post a comment