Merge remote-tracking branch 'patton99/master' into iOS
# Conflicts: # ios/Runner.xcodeproj/project.pbxproj # lib/widget/my_superplayer.dart # pubspec.yaml
This commit is contained in:
@@ -4,8 +4,10 @@ import 'package:flutter_bmfmap/BaiduMap/bmfmap_map.dart';
|
||||
import 'package:flutter_screenutil/screen_util.dart';
|
||||
import 'package:hyzp_ybqx/components/commonFun.dart';
|
||||
import 'package:hyzp_ybqx/components/hyxx_data_handle.dart';
|
||||
import 'package:map_launcher/map_launcher.dart';
|
||||
|
||||
import '../../../components/dioFun.dart';
|
||||
import '../../../services/Storage.dart';
|
||||
import 'dwInfoDialog.dart';
|
||||
import 'dwInfo_data.dart';
|
||||
|
||||
@@ -20,6 +22,11 @@ class BasicMap extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _BasicMapState extends State<BasicMap> {
|
||||
// 导航相关代码
|
||||
double destinationLatitude = 28.45382237207785;
|
||||
double destinationLongitude = 104.7506958256658;
|
||||
String destinationTitle = '珙县大坪上';
|
||||
|
||||
Size screenSize;
|
||||
BMFMapOptions mapOptions;
|
||||
BMFMapController myMapController;
|
||||
@@ -32,9 +39,18 @@ class _BasicMapState extends State<BasicMap> {
|
||||
}
|
||||
}
|
||||
|
||||
List<AvailableMap> availableMaps;
|
||||
|
||||
void init() async {
|
||||
// 获取用户选择的默认地图
|
||||
availableMaps = await MapLauncher.installedMaps;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
init();
|
||||
|
||||
mapOptions = BMFMapOptions(
|
||||
//center: BMFCoordinate(39.965, 116.404),//北京市
|
||||
//30 116.395645038,39.9299857781 北京-北京市
|
||||
@@ -291,8 +307,17 @@ class _BasicMapState extends State<BasicMap> {
|
||||
.push(
|
||||
PageRouteBuilder(
|
||||
opaque: false,
|
||||
pageBuilder: (context, animation, secondaryAnimation) =>
|
||||
dwInfoDialog(id: id, dwIndex: dwIndex, title: title, content: content),
|
||||
pageBuilder: (context, animation, secondaryAnimation) => dwInfoDialog(
|
||||
id: id,
|
||||
dwIndex: dwIndex,
|
||||
title: title,
|
||||
content: content,
|
||||
parentContext: context,
|
||||
destinationLatitude: double.parse(listCoordinate[1]),
|
||||
destinationLongitude: double.parse(listCoordinate[0]),
|
||||
destinationTitle: listDwinfoGetList2[dwIndex]["dwmc"],
|
||||
availableMaps: availableMaps,
|
||||
),
|
||||
),
|
||||
)
|
||||
.then((value) async {
|
||||
|
||||
@@ -1,21 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:hyzp_ybqx/components/dioFun.dart';
|
||||
import 'package:map_launcher/map_launcher.dart';
|
||||
|
||||
//import 'package:hyzp_ybqx/widget/player_pro.dart';
|
||||
import '../../../components/commonFun.dart';
|
||||
import '../../../services/Storage.dart';
|
||||
import 'maps_sheet.dart';
|
||||
|
||||
//确认对话框
|
||||
class dwInfoDialog extends Dialog {
|
||||
dwInfoDialog({@required this.id, this.title = "", @required this.dwIndex, this.content});
|
||||
dwInfoDialog({
|
||||
@required this.id,
|
||||
this.title = "",
|
||||
@required this.dwIndex,
|
||||
this.content,
|
||||
// 导航相关参数
|
||||
this.parentContext,
|
||||
this.destinationLatitude,
|
||||
this.destinationLongitude,
|
||||
this.destinationTitle,
|
||||
this.availableMaps,
|
||||
});
|
||||
|
||||
int dwIndex;
|
||||
String id;
|
||||
String title;
|
||||
String content;
|
||||
bool ret = false;
|
||||
BuildContext parentContext;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
getCurrentPosition();
|
||||
Size mediaSize = MediaQuery.of(context).size;
|
||||
return WillPopScope(
|
||||
child: Material(
|
||||
@@ -90,9 +107,9 @@ class dwInfoDialog extends Dialog {
|
||||
onPressed: () async {
|
||||
ret = true;
|
||||
getingDwVideo = false;
|
||||
Navigator.pop(context, ret); //关闭弹框,返回sRet
|
||||
navigationMap(context);
|
||||
},
|
||||
child: Text("确认"),
|
||||
child: Text("导航"),
|
||||
),
|
||||
RaisedButton(
|
||||
child: Text("取消"),
|
||||
@@ -115,4 +132,102 @@ class dwInfoDialog extends Dialog {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// 导航相关代码
|
||||
double destinationLatitude = 28.45382237207785;
|
||||
double destinationLongitude = 104.7506958256658;
|
||||
String destinationTitle = '珙县大坪上';
|
||||
|
||||
double originLatitude;
|
||||
double originLongitude;
|
||||
String originTitle = '我的位置';
|
||||
|
||||
List<Coords> waypoints = [
|
||||
// Coords(37.7705112, -122.4108267),
|
||||
// Coords(37.6988984, -122.4830961),
|
||||
// Coords(37.7935754, -122.483654),
|
||||
];
|
||||
|
||||
DirectionsMode directionsMode = DirectionsMode.driving;
|
||||
|
||||
List<AvailableMap> availableMaps;
|
||||
|
||||
// String defaultMapName = 'Amap';
|
||||
String defaultMapName = g_defaultMapName;
|
||||
AvailableMap defalutMap;
|
||||
|
||||
void getCurrentPosition() async {
|
||||
print('getCurrentPosition begin');
|
||||
|
||||
// 是否保存默认地图
|
||||
g_bSaveDefaultMap = await Storage.getBool('bSaveDefaultMap');
|
||||
g_bSaveDefaultMap = (null == g_bSaveDefaultMap) ? false : g_bSaveDefaultMap; // 默认不保存
|
||||
// 用户选择的默认地图名称
|
||||
g_defaultMapName = await Storage.getString('defaultMapName');
|
||||
g_defaultMapName = (null == g_defaultMapName) ? '' : g_defaultMapName; // 默认为空字符串
|
||||
defaultMapName = g_defaultMapName;
|
||||
|
||||
// 获取用户选择的默认地图
|
||||
// availableMaps = await MapLauncher.installedMaps; // 为避免延迟错乱,该变量由父组件传入
|
||||
if (defaultMapName != null && defaultMapName.length > 0) {
|
||||
for (var map in availableMaps) {
|
||||
if (defaultMapName.toLowerCase() == map.mapName.toLowerCase()) {
|
||||
defalutMap = map;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await Geolocator.getCurrentPosition().then((Position value) {
|
||||
originLatitude = value.latitude;
|
||||
originLongitude = value.longitude;
|
||||
print('value = ${value.toString()}');
|
||||
// value = Latitude: 28.796201, Longitude: 104.607751
|
||||
print('getCurrentPosition end');
|
||||
});
|
||||
}
|
||||
|
||||
navigationMap(BuildContext context) {
|
||||
print('this.defalutMap = ${defalutMap}');
|
||||
if (defalutMap != null) {
|
||||
defalutMap.showDirections(
|
||||
destination: Coords(
|
||||
destinationLatitude,
|
||||
destinationLongitude,
|
||||
),
|
||||
destinationTitle: destinationTitle,
|
||||
origin: originLatitude == null || originLongitude == null
|
||||
? null
|
||||
: Coords(originLatitude, originLongitude),
|
||||
originTitle: originTitle,
|
||||
waypoints: waypoints,
|
||||
directionsMode: directionsMode,
|
||||
);
|
||||
} else {
|
||||
MapsSheet.show(
|
||||
context: parentContext,
|
||||
onMapTap: (map) {
|
||||
if (g_bSaveDefaultMap) {
|
||||
g_defaultMapName = map.mapName;
|
||||
Storage.setString('defaultMapName', g_defaultMapName);
|
||||
}
|
||||
|
||||
map.showDirections(
|
||||
destination: Coords(
|
||||
destinationLatitude,
|
||||
destinationLongitude,
|
||||
),
|
||||
destinationTitle: destinationTitle,
|
||||
origin: originLatitude == null || originLongitude == null
|
||||
? null
|
||||
: Coords(originLatitude, originLongitude),
|
||||
originTitle: originTitle,
|
||||
waypoints: waypoints,
|
||||
directionsMode: directionsMode,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Navigator.pop(context, ret); //关闭弹框,返回sRet
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:map_launcher/map_launcher.dart';
|
||||
|
||||
class MapsSheet {
|
||||
static show({
|
||||
@required BuildContext context,
|
||||
@required Function(AvailableMap map) onMapTap,
|
||||
}) async {
|
||||
final availableMaps = await MapLauncher.installedMaps;
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Container(
|
||||
child: Wrap(
|
||||
children: <Widget>[
|
||||
for (var map in availableMaps)
|
||||
ListTile(
|
||||
onTap: () {
|
||||
print('map.mapName = ${map.mapName}');
|
||||
// map.mapName = Amap
|
||||
Navigator.pop(context);
|
||||
onMapTap(map);
|
||||
},
|
||||
title: Text(map.mapName),
|
||||
leading: SvgPicture.asset(
|
||||
map.icon,
|
||||
height: 30.0,
|
||||
width: 30.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user