|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
|
|
...
|
...
|
@@ -6,13 +5,20 @@ import 'package:flutter/cupertino.dart'; |
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:amap_search_fluttify/amap_search_fluttify.dart';
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/misc.dart';
|
|
|
|
import 'package:one_key/route/navigator_util.dart';
|
|
|
|
import 'package:one_key/utils/screen_util.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
|
|
|
import '../../utils/common_utils.dart';
|
|
|
|
// import 'package:demo/resources/custom_text_style.dart';
|
|
|
|
// import 'package:demo/utils/misc.dart';
|
|
|
|
|
|
...
|
...
|
@@ -40,23 +46,36 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { |
|
|
|
double latitude = 39.684670899;
|
|
|
|
double longitude = 118.17630045;
|
|
|
|
|
|
|
|
double latitudeLocation = 39.684670899;
|
|
|
|
double longitudeLocation = 118.17630045;
|
|
|
|
|
|
|
|
List<InputTip> inputTipDatas = [];
|
|
|
|
int page = 1;
|
|
|
|
EasyRefreshController refreshController = EasyRefreshController();
|
|
|
|
bool flag = true;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
if (widget.long != null && widget.long != ''&&widget.long != 'null') {
|
|
|
|
if (widget.long != null && widget.long != '' && widget.long != 'null') {
|
|
|
|
longitude = double.parse(widget.long!);
|
|
|
|
}
|
|
|
|
if (widget.lat != null && widget.lat != ''&&widget.lat != 'null') {
|
|
|
|
if (widget.lat != null && widget.lat != '' && widget.lat != 'null') {
|
|
|
|
latitude = double.parse(widget.lat!);
|
|
|
|
}
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
_requestLocationPermission();
|
|
|
|
|
|
|
|
// ama
|
|
|
|
// let marker = new AMap.Marker({//添加标记点
|
|
|
|
// position: this.position,
|
|
|
|
// map: map
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<bool> checkLocationPermission() async {
|
|
|
|
Future<bool> checkLocationPermission() async {
|
|
|
|
PermissionStatus permissionStatus = await Permission.location.status;
|
|
|
|
if (permissionStatus == PermissionStatus.granted) {
|
|
|
|
return true;
|
|
...
|
...
|
@@ -108,23 +127,30 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { |
|
|
|
{
|
|
|
|
// App.sp.setString("lat", "39.684670899");
|
|
|
|
// App.sp.setString("lng", "118.17630045");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (widget.long == null || widget.long == ''||widget.long == 'null') {
|
|
|
|
if (widget.long == null ||
|
|
|
|
widget.long == '' ||
|
|
|
|
widget.long == 'null') {
|
|
|
|
latitude = location.latLng!.latitude;
|
|
|
|
longitude = location.latLng!.longitude;
|
|
|
|
if (_controller != null) {
|
|
|
|
_controller!.setCenterCoordinate(
|
|
|
|
LatLng(location.latLng!.latitude, location.latLng!.longitude));
|
|
|
|
_controller!.setCenterCoordinate(LatLng(
|
|
|
|
location.latLng!.latitude, location.latLng!.longitude));
|
|
|
|
}
|
|
|
|
|
|
|
|
page = 1;
|
|
|
|
|
|
|
|
_loadData(
|
|
|
|
LatLng(location.latLng!.latitude, location.latLng!.longitude));
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
latitudeLocation = location.latLng!.latitude;
|
|
|
|
longitudeLocation = location.latLng!.longitude;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
//无权限
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -136,279 +162,485 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { |
|
|
|
'选择位置信息',
|
|
|
|
onTap: () {
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
|
|
|
|
body: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Theme(
|
|
|
|
data: new ThemeData(
|
|
|
|
primaryColor: Color(0xFFFFCA28), hintColor: Color(0xFFFFCA28)),
|
|
|
|
child: Container(
|
|
|
|
color: Color(0xFFFFCA28),
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
child: Container(
|
|
|
|
height: 36,
|
|
|
|
margin: EdgeInsets.only(left: 5, right: 5, bottom: 5),
|
|
|
|
child: TextField(
|
|
|
|
style: TextStyle(fontSize: 16, letterSpacing: 1.0),
|
|
|
|
controller: TextEditingController.fromValue(TextEditingValue(
|
|
|
|
// 设置内容
|
|
|
|
text: keyword,
|
|
|
|
selection: TextSelection.fromPosition(TextPosition(
|
|
|
|
affinity: TextAffinity.downstream,
|
|
|
|
offset: keyword.length)),
|
|
|
|
// 保持光标在最后
|
|
|
|
)),
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(40)),
|
|
|
|
// Theme(
|
|
|
|
// data: new
|
|
|
|
// ThemeData(
|
|
|
|
// // primaryColor: MyColours.color_438E93,
|
|
|
|
// // hintColor: MyColours.color_438E93),
|
|
|
|
// child:
|
|
|
|
// Container(
|
|
|
|
// color: MyColours.color_438E93,
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
// color: MyColours.color_438E93,
|
|
|
|
// boxShadow: [
|
|
|
|
// BoxShadow(color: Colors.white, spreadRadius: 1),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// padding: EdgeInsets.all(5),
|
|
|
|
// child:
|
|
|
|
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ListView.builder(
|
|
|
|
// shrinkWrap: true,
|
|
|
|
// itemCount: inputTipDatas.length,
|
|
|
|
// itemBuilder: (context, index) {
|
|
|
|
// InputTip inputTip = inputTipDatas[index];
|
|
|
|
// return InkWell(
|
|
|
|
// onTap: () {
|
|
|
|
// // searchAroundAddress(inputTip.name ?? '');
|
|
|
|
// // searchPoiId(inputTip.poiId ?? '');
|
|
|
|
// // _loadData(inputTip.coordinate ??
|
|
|
|
// // LatLng(latitude, longitude));
|
|
|
|
// },
|
|
|
|
// child: Container(
|
|
|
|
// child: Row(
|
|
|
|
// children: [
|
|
|
|
// Text(
|
|
|
|
// inputTip.name ?? '',
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: font(15),
|
|
|
|
// color: MyColours.color_515151),
|
|
|
|
// ),
|
|
|
|
// HEmptyView(10),
|
|
|
|
// Expanded(
|
|
|
|
// child: Text(
|
|
|
|
// (inputTip.district ?? '') +
|
|
|
|
// (inputTip.address ?? ''),
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: font(13),
|
|
|
|
// color: MyColours.color_999999),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// )));
|
|
|
|
// })
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
|
|
|
|
Stack(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
height: w(300),
|
|
|
|
child: Stack(
|
|
|
|
children: <Widget>[
|
|
|
|
AmapView(
|
|
|
|
showZoomControl: false,
|
|
|
|
|
|
|
|
/// 是否显示指南针控件
|
|
|
|
showCompass: true,
|
|
|
|
|
|
|
|
/// 是否显示比例尺控件
|
|
|
|
showScaleControl: true,
|
|
|
|
|
|
|
|
/// 是否使能缩放手势
|
|
|
|
zoomGesturesEnabled: true,
|
|
|
|
|
|
|
|
/// 是否使能滚动手势
|
|
|
|
scrollGesturesEnabled: true,
|
|
|
|
|
|
|
|
/// 是否使能旋转手势
|
|
|
|
rotateGestureEnabled: false,
|
|
|
|
centerCoordinate: LatLng(latitude, longitude),
|
|
|
|
maskDelay: Duration(milliseconds: 500),
|
|
|
|
zoomLevel: 19,
|
|
|
|
onMapCreated: (controller) async {
|
|
|
|
_controller = controller;
|
|
|
|
_controller!
|
|
|
|
.setCenterCoordinate(LatLng(latitude, longitude));
|
|
|
|
// if (await requestPermission(PermissionGroup.location)) {
|
|
|
|
// await controller.showMyLocation(true);
|
|
|
|
// await controller?.showLocateControl(true);
|
|
|
|
// final latLng = await _controller?.getLocation(
|
|
|
|
// delay: Duration(seconds: 2));
|
|
|
|
// await enableFluttifyLog(false); // 关闭log
|
|
|
|
// _loadData(latLng);
|
|
|
|
// } else {
|
|
|
|
// //无权限
|
|
|
|
// _showLocPemWidget();
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
// markers: [],
|
|
|
|
onMapMoveEnd: (MapMove move) async {
|
|
|
|
latitude = move.coordinate!.latitude;
|
|
|
|
longitude = move.coordinate!.longitude;
|
|
|
|
page = 1;
|
|
|
|
_loadData(move.coordinate!);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
Center(
|
|
|
|
child: Icon(
|
|
|
|
Icons.place,
|
|
|
|
size: w(32),
|
|
|
|
color: Color(0xFFFF0000),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
hintText: '输入关键字',
|
|
|
|
hintStyle:
|
|
|
|
TextStyle(color: Color(0xFFBEBEBE), fontSize: 14),
|
|
|
|
contentPadding:
|
|
|
|
const EdgeInsets.symmetric(vertical: 8, horizontal: 1),
|
|
|
|
prefixIcon: Icon(
|
|
|
|
Icons.search,
|
|
|
|
color: Colors.grey,
|
|
|
|
size: 20,
|
|
|
|
Positioned(
|
|
|
|
right: w(10),
|
|
|
|
bottom: w(10),
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
_controller!.setCenterCoordinate(
|
|
|
|
LatLng(latitudeLocation, longitudeLocation));
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
borderRadius: BorderRadius.circular(r(5))),
|
|
|
|
padding: EdgeInsets.all(w(5)),
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath('location_map'),
|
|
|
|
width: w(25),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
top: w(10),
|
|
|
|
left: w(20),
|
|
|
|
right: w(20),
|
|
|
|
child: Container(
|
|
|
|
// height: w(45),
|
|
|
|
padding: EdgeInsets.symmetric(vertical: w(10)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius: BorderRadius.circular(r(10))),
|
|
|
|
child: TextField(
|
|
|
|
textAlignVertical: TextAlignVertical.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: font(15),
|
|
|
|
),
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
icon: Icon(
|
|
|
|
Icons.clear,
|
|
|
|
color: Colors.grey,
|
|
|
|
size: 20,
|
|
|
|
controller:
|
|
|
|
TextEditingController.fromValue(TextEditingValue(
|
|
|
|
// 设置内容
|
|
|
|
text: keyword,
|
|
|
|
selection: TextSelection.fromPosition(TextPosition(
|
|
|
|
affinity: TextAffinity.downstream,
|
|
|
|
offset: keyword.length)),
|
|
|
|
// 保持光标在最后
|
|
|
|
)),
|
|
|
|
decoration: InputDecoration(
|
|
|
|
// border: b,
|
|
|
|
// border: OutlineInputBorder(
|
|
|
|
// borderRadius: BorderRadius.all(Radius.circular(40)),
|
|
|
|
// ),
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: '输入关键字',
|
|
|
|
isCollapsed: true,
|
|
|
|
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: MyColours.color_999999, fontSize: font(15)),
|
|
|
|
// contentPadding: const EdgeInsets.symmetric(
|
|
|
|
// vertical: 8, horizontal: 1),
|
|
|
|
prefixIconConstraints: BoxConstraints(maxWidth: w(40)),
|
|
|
|
prefixIcon: Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(10), right: w(10)),
|
|
|
|
child: SizedBox(
|
|
|
|
width: w(30),
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath('search_black'),
|
|
|
|
))),
|
|
|
|
suffixIconConstraints: BoxConstraints(maxWidth: w(32)),
|
|
|
|
suffixIcon: InkWell(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(10), right: w(10)),
|
|
|
|
child: SizedBox(
|
|
|
|
width: w(22),
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath('delete_black'),
|
|
|
|
))),
|
|
|
|
onTap: () {
|
|
|
|
keyword = "";
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
keyword = "";
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
fillColor: Colors.white,
|
|
|
|
filled: true,
|
|
|
|
),
|
|
|
|
fillColor: Colors.white,
|
|
|
|
filled: true,
|
|
|
|
),
|
|
|
|
|
|
|
|
inputFormatters: [],
|
|
|
|
//内容改变的回调
|
|
|
|
onChanged: (text) {
|
|
|
|
print('change $text');
|
|
|
|
keyword = text;
|
|
|
|
},
|
|
|
|
//内容提交(按回车)的回调
|
|
|
|
onSubmitted: (text) {
|
|
|
|
print('submit $text');
|
|
|
|
// 触发关闭弹出来的键盘。
|
|
|
|
keyword = text;
|
|
|
|
setState(() {
|
|
|
|
isloading = true;
|
|
|
|
inputFormatters: [],
|
|
|
|
//内容改变的回调
|
|
|
|
onChanged: (text) {
|
|
|
|
print('change $text');
|
|
|
|
keyword = text;
|
|
|
|
|
|
|
|
//搜索
|
|
|
|
|
|
|
|
JhCommonUtils.debounce(
|
|
|
|
() => _fetchInputTips(text.toString()));
|
|
|
|
},
|
|
|
|
//内容提交(按回车)的回调
|
|
|
|
onSubmitted: (text) {
|
|
|
|
print('submit $text');
|
|
|
|
// 触发关闭弹出来的键盘。
|
|
|
|
keyword = text;
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
});
|
|
|
|
|
|
|
|
searchAroundAddress(text.toString());
|
|
|
|
},
|
|
|
|
//按回车时调用
|
|
|
|
onEditingComplete: () {
|
|
|
|
print('onEditingComplete');
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 300,
|
|
|
|
child: Stack(
|
|
|
|
children: <Widget>[
|
|
|
|
AmapView(
|
|
|
|
showZoomControl: false,
|
|
|
|
centerCoordinate: LatLng(latitude, longitude),
|
|
|
|
maskDelay: Duration(milliseconds: 500),
|
|
|
|
zoomLevel: 16,
|
|
|
|
onMapCreated: (controller) async {
|
|
|
|
_controller = controller;
|
|
|
|
_controller!
|
|
|
|
.setCenterCoordinate(LatLng(latitude, longitude));
|
|
|
|
// if (await requestPermission(PermissionGroup.location)) {
|
|
|
|
// await controller.showMyLocation(true);
|
|
|
|
// await controller?.showLocateControl(true);
|
|
|
|
// final latLng = await _controller?.getLocation(
|
|
|
|
// delay: Duration(seconds: 2));
|
|
|
|
// await enableFluttifyLog(false); // 关闭log
|
|
|
|
// _loadData(latLng);
|
|
|
|
// } else {
|
|
|
|
// //无权限
|
|
|
|
// _showLocPemWidget();
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
onMapMoveEnd: (MapMove move) async {
|
|
|
|
_loadData(move.coordinate!);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
Center(
|
|
|
|
child: Icon(
|
|
|
|
Icons.place,
|
|
|
|
size: 36.0,
|
|
|
|
color: Color(0xFFFF0000),
|
|
|
|
setState(() {
|
|
|
|
// isloading = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
// _fetchInputTips(text.toString());
|
|
|
|
|
|
|
|
// searchAroundAddress(text.toString());
|
|
|
|
},
|
|
|
|
//按回车时调用
|
|
|
|
onEditingComplete: () {
|
|
|
|
print('onEditingComplete');
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
flex: 1,
|
|
|
|
child: Visibility(
|
|
|
|
visible: !isloading,
|
|
|
|
maintainSize: false,
|
|
|
|
maintainSemantics: false,
|
|
|
|
maintainInteractivity: false,
|
|
|
|
replacement: Center(
|
|
|
|
child: CupertinoActivityIndicator(),
|
|
|
|
),
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: list.length,
|
|
|
|
itemBuilder: (BuildContext context, int position) {
|
|
|
|
print("itemBuilder" + list.length.toString());
|
|
|
|
PoiModel item = list[position]!;
|
|
|
|
return InkWell(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
margin:
|
|
|
|
EdgeInsets.only(top: 8, bottom: 5, left: 10),
|
|
|
|
child: Row(
|
|
|
|
visible: !isloading,
|
|
|
|
maintainSize: false,
|
|
|
|
maintainSemantics: false,
|
|
|
|
maintainInteractivity: false,
|
|
|
|
replacement: Center(
|
|
|
|
child: CupertinoActivityIndicator(),
|
|
|
|
),
|
|
|
|
child: EasyRefresh.custom(
|
|
|
|
controller: refreshController,
|
|
|
|
slivers: [
|
|
|
|
SliverList(
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
(BuildContext context, int position) {
|
|
|
|
print("itemBuilder" + list.length.toString());
|
|
|
|
PoiModel item = list[position]!;
|
|
|
|
return InkWell(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Icons.place,
|
|
|
|
size: 20.0,
|
|
|
|
color: position == 0
|
|
|
|
? Colors.green
|
|
|
|
: Colors.grey,
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
top: 8, bottom: 5, left: 10),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Icons.place,
|
|
|
|
size: 20.0,
|
|
|
|
color: position == 0
|
|
|
|
? Colors.green
|
|
|
|
: Colors.grey,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Text(item.title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
color: position == 0
|
|
|
|
? Colors.green
|
|
|
|
: Color(0xFF787878))))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
top: 5, bottom: 5, left: 18),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
item.address!,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Color(0xFF646464),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Text(item.title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
color: position == 0
|
|
|
|
? Colors.green
|
|
|
|
: Color(0xFF787878))))
|
|
|
|
Divider(
|
|
|
|
height: 1,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
margin:
|
|
|
|
EdgeInsets.only(top: 5, bottom: 5, left: 18),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
item.address!,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Color(0xFF646464),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Divider(
|
|
|
|
height: 1,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
onTap: () async {
|
|
|
|
// await _controller.setCenterCoordinate(
|
|
|
|
// LatLng(item.latLng.latitude, item.latLng.longitude),
|
|
|
|
// zoomLevel: 16);
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context, {
|
|
|
|
'address': item.address,
|
|
|
|
'lat': item.latLng!.latitude.toString(),
|
|
|
|
'lng': item.latLng!.longitude.toString()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
childCount: list.length,
|
|
|
|
),
|
|
|
|
onTap: () async {
|
|
|
|
// await _controller.setCenterCoordinate(
|
|
|
|
// LatLng(item.latLng.latitude, item.latLng.longitude),
|
|
|
|
// zoomLevel: 16);
|
|
|
|
if (Navigator.canPop(context)) {
|
|
|
|
Navigator.pop(context, {
|
|
|
|
'address': item.address,
|
|
|
|
'lat': item.latLng!.latitude.toString(),
|
|
|
|
'lng': item.latLng!.longitude.toString()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
onRefresh: () async {
|
|
|
|
if (flag) {
|
|
|
|
page = 1;
|
|
|
|
_loadData(LatLng(latitude, longitude));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onLoad: () async {
|
|
|
|
if (flag) {
|
|
|
|
page++;
|
|
|
|
_loadData(LatLng(latitude, longitude),
|
|
|
|
showloading: false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _loadData(LatLng latLng) async {
|
|
|
|
setState(() {
|
|
|
|
isloading = true;
|
|
|
|
});
|
|
|
|
_fetchInputTips(String text) async {
|
|
|
|
flag = false;
|
|
|
|
page = 1;
|
|
|
|
// setState(() {
|
|
|
|
// isloading = true;
|
|
|
|
// });
|
|
|
|
|
|
|
|
/// 逆地理编码(坐标转地址)
|
|
|
|
///
|
|
|
|
///
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
ReGeocode reGeocodeList = await AmapSearch.instance.searchReGeocode(
|
|
|
|
latLng,
|
|
|
|
);
|
|
|
|
|
|
|
|
LatLng latLng = LatLng(latitude, longitude);
|
|
|
|
ReGeocode reGeocodeList = await AmapSearch.instance.searchReGeocode(latLng);
|
|
|
|
|
|
|
|
// print(await reGeocodeList.toFutureString());
|
|
|
|
address = reGeocodeList.formatAddress;
|
|
|
|
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
final poiList = await AmapSearch.instance.searchAround(
|
|
|
|
latLng,
|
|
|
|
inputTipDatas = await AmapSearch.instance.fetchInputTips(
|
|
|
|
text,
|
|
|
|
city: "",
|
|
|
|
);
|
|
|
|
print(inputTipDatas);
|
|
|
|
|
|
|
|
poiModel = new PoiModel("当前位置", address, latLng);
|
|
|
|
list.clear();
|
|
|
|
list.add(poiModel);
|
|
|
|
for (var poi in poiList) {
|
|
|
|
String? title = await poi.title;
|
|
|
|
String? cityName = await poi.cityName;
|
|
|
|
String? provinceName = await poi.provinceName;
|
|
|
|
String? address = await poi.address;
|
|
|
|
LatLng? latLng = await poi.latLng;
|
|
|
|
String? bussniss = poi.businessArea;
|
|
|
|
for (var inputTip in inputTipDatas) {
|
|
|
|
String? title = await inputTip.name ?? '';
|
|
|
|
String? cityStr =
|
|
|
|
await (inputTip.district ?? '') + (inputTip.address ?? '');
|
|
|
|
|
|
|
|
list.add(new PoiModel(
|
|
|
|
title.toString(),
|
|
|
|
provinceName.toString() +
|
|
|
|
cityName.toString() +
|
|
|
|
address.toString() +
|
|
|
|
bussniss.toString(),
|
|
|
|
latLng));
|
|
|
|
LatLng? latLng = await inputTip.coordinate;
|
|
|
|
|
|
|
|
list.add(new PoiModel(title.toString(), cityStr, latLng));
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
isloading = false;
|
|
|
|
// isloading = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void searchAroundAddress(String text) async {
|
|
|
|
void _loadData(LatLng latLng, {showloading = true}) async {
|
|
|
|
flag = true;
|
|
|
|
setState(() {
|
|
|
|
if (showloading) {
|
|
|
|
isloading = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/// 逆地理编码(坐标转地址)
|
|
|
|
///
|
|
|
|
///
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
final poiList = await AmapSearch.instance.searchKeyword(
|
|
|
|
text,
|
|
|
|
city: "",
|
|
|
|
);
|
|
|
|
|
|
|
|
list.clear();
|
|
|
|
list.add(poiModel);
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
if (page == 1) {
|
|
|
|
ReGeocode reGeocodeList = await AmapSearch.instance.searchReGeocode(
|
|
|
|
latLng,
|
|
|
|
);
|
|
|
|
// print(await reGeocodeList.toFutureString());
|
|
|
|
address = reGeocodeList.formatAddress;
|
|
|
|
poiModel = new PoiModel("当前位置", address, latLng);
|
|
|
|
list.clear();
|
|
|
|
list.add(poiModel);
|
|
|
|
}
|
|
|
|
final poiList =
|
|
|
|
await AmapSearch.instance.searchAround(latLng, city: "", page: page);
|
|
|
|
|
|
|
|
for (var poi in poiList) {
|
|
|
|
String? title = await poi.title;
|
|
|
|
LatLng? latLng = await poi.latLng;
|
|
|
|
String? cityName = await poi.cityName;
|
|
|
|
String? provinceName = await poi.provinceName;
|
|
|
|
String? address = await poi.address;
|
|
|
|
LatLng? latLng = await poi.latLng;
|
|
|
|
String? bussniss = poi.businessArea;
|
|
|
|
|
|
|
|
list.add(new PoiModel(
|
|
|
|
title.toString(),
|
|
|
|
provinceName.toString() + cityName.toString() + address.toString(),
|
|
|
|
provinceName.toString() +
|
|
|
|
cityName.toString() +
|
|
|
|
address.toString() +
|
|
|
|
bussniss.toString(),
|
|
|
|
latLng));
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
isloading = false;
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
if (showloading) {
|
|
|
|
isloading = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// void searchPoiId(String text) async {
|
|
|
|
// await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
// await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
// Poi? poi = await AmapSearch.instance.searchPoiId(
|
|
|
|
// text,
|
|
|
|
// );
|
|
|
|
// print(poi);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// void searchAroundAddress(String text) async {
|
|
|
|
// await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
// await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
// final poiList = await AmapSearch.instance.searchKeyword(
|
|
|
|
// text,
|
|
|
|
// city: "",
|
|
|
|
// );
|
|
|
|
// // final poiList = await AmapSearch.instance.searchAround(
|
|
|
|
// // LatLng(latitude, longitude),
|
|
|
|
// // city: "",
|
|
|
|
// // radius: 100000000000000
|
|
|
|
|
|
|
|
// // );
|
|
|
|
|
|
|
|
// list.clear();
|
|
|
|
// list.add(poiModel);
|
|
|
|
// for (var poi in poiList) {
|
|
|
|
// String? title = await poi.title;
|
|
|
|
// LatLng? latLng = await poi.latLng;
|
|
|
|
// String? cityName = await poi.cityName;
|
|
|
|
// String? provinceName = await poi.provinceName;
|
|
|
|
// String? address = await poi.address;
|
|
|
|
// list.add(new PoiModel(
|
|
|
|
// title.toString(),
|
|
|
|
// provinceName.toString() + cityName.toString() + address.toString(),
|
|
|
|
// latLng));
|
|
|
|
// }
|
|
|
|
// setState(() {
|
|
|
|
// isloading = false;
|
|
|
|
// FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
class PoiModel {
|
...
|
...
|
|