hyzp_ybqx-Commit001:代码刚转换好,编译通过
This commit is contained in:
@@ -0,0 +1,514 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bmfbase/BaiduMap/bmfmap_base.dart';
|
||||
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 '../../../components/dioFun.dart';
|
||||
import 'dwInfoDialog.dart';
|
||||
import 'dwInfo_data.dart';
|
||||
|
||||
class BasicMap extends StatefulWidget {
|
||||
BasicMap({this.hyshlx = 'dwdt', this.title = "点位地图"});
|
||||
|
||||
String hyshlx;
|
||||
String title;
|
||||
|
||||
@override
|
||||
_BasicMapState createState() => _BasicMapState();
|
||||
}
|
||||
|
||||
class _BasicMapState extends State<BasicMap> {
|
||||
Size screenSize;
|
||||
BMFMapOptions mapOptions;
|
||||
BMFMapController myMapController;
|
||||
|
||||
try_setState() {
|
||||
try {
|
||||
setState(() {});
|
||||
} catch (e) {
|
||||
print('setState(() {})异常:${e}');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
mapOptions = BMFMapOptions(
|
||||
//center: BMFCoordinate(39.965, 116.404),//北京市
|
||||
//30 116.395645038,39.9299857781 北京-北京市
|
||||
//center: BMFCoordinate(34.263161, 108.948024), //西安市
|
||||
/// 设置地图显示中心点坐标,必须是百度官方发布的百度地图-城市中心点坐标
|
||||
/// 为宜宾市白塔山: BMFCoordinate(104.644079, 28.77914)
|
||||
//center: BMFCoordinate(104.644079, 28.77914), //宜宾市白塔山,无效,经纬度搞反了
|
||||
//52 104.633019062,28.7696747963 四川省-宜宾市
|
||||
|
||||
///Flutter百度地图采坑注意:
|
||||
// BMFCoordinate(this.latitude, this.longitude);
|
||||
// BMFCoordinate 构造方法参数是纬度在前、经度在后,latitude 纬度,longitude 经度
|
||||
// 百度官方发布的城市中心点坐标是经度在前、纬度在后,必须对调才行,否则无法正确显示指定城市的地图
|
||||
// 比如://52 104.633019062,28.7696747963 四川省-宜宾市
|
||||
// 必须将经纬度对调才行:center: BMFCoordinate(28.7696747963, 104.633019062), //四川省-宜宾市
|
||||
//center: BMFCoordinate(28.7696747963, 104.633019062), //四川省-宜宾市
|
||||
center: BMFCoordinate(28.77914, 104.644079),
|
||||
//宜宾市白塔山
|
||||
//宜宾市白塔山
|
||||
showMapPoi: _showMapPoi,
|
||||
//设定地图是否显示底图poi标注(不包含室内图标注),默认true
|
||||
zoomLevel: g_zoomLevel,
|
||||
maxZoomLevel: 16,
|
||||
minZoomLevel: 12,
|
||||
mapPadding: BMFEdgeInsets(left: 30, top: 0, right: 30, bottom: 0),
|
||||
//showMapScaleBar: true,
|
||||
);
|
||||
|
||||
iPage = 0;
|
||||
listDwspGetList2.clear();
|
||||
|
||||
///从接口 mapHyshlx[hyshlx]['api'] 获取第 iPage 页的列表数据,返回 list
|
||||
getPageList(theHyshlx: widget.hyshlx, bShowToast: false).then((value) async {
|
||||
//mapHyshlx[hyshlx]['api'];
|
||||
listDwspGetList2 = value;
|
||||
listDwinfoGetList2 = value;
|
||||
//try_setState();
|
||||
|
||||
//按照用户选择的_selectedValue、_descending对listDwspGetList2进行排序,并延时更新
|
||||
|
||||
// int len = listDwspGetList2.length;
|
||||
// for (int i = 0; i < len; i++) {
|
||||
// getDwspUrl(index: listDwspGetList2[i]['id']).then((value) {
|
||||
// listDwspGetList2[i]['dwsp_ok'] = true;
|
||||
// if (value == '' || value == null) {
|
||||
// listDwspGetList2[i]['dwsp_ok'] = false;
|
||||
// }
|
||||
// setState(() {});
|
||||
// });
|
||||
// }
|
||||
});
|
||||
//为播放点位视频读取数据
|
||||
//在 Page1_Works 页面,获取 startGetStatisData() 时,便已经获取了 listDwinfoGetList2
|
||||
|
||||
// ///从接口 mapHyshlx[hyshlx]['api'] 获取第 iPage 页的列表数据,返回 list
|
||||
// getPageList(theHyshlx: 'dwxx', bShowToast: false).then((value) async {
|
||||
// //mapHyshlx[hyshlx]['api'];
|
||||
// listDwspGetList2 = value;
|
||||
//
|
||||
// //按_selectedValue排序,升序
|
||||
// listDwspGetList2
|
||||
// .sort((a, b) => (a[mapWzxxDataText['点位编号']]).compareTo(b[mapWzxxDataText['点位编号']]));
|
||||
// });
|
||||
}
|
||||
|
||||
//设定地图是否显示底图poi标注(不包含室内图标注),默认true
|
||||
bool _showMapPoi = true;
|
||||
|
||||
/// 创建完成回调
|
||||
void onBMFMapCreated(BMFMapController controller) async {
|
||||
myMapController = controller;
|
||||
|
||||
/// 设置地图状态改变完成后回调接口
|
||||
myMapController?.setMapStatusDidChangedCallback(callback: () {
|
||||
myMapController.getZoomLevel().then((zoomLevel) {
|
||||
print('Current zoomLevel = $zoomLevel');
|
||||
g_zoomLevel = zoomLevel; //缩放倍数
|
||||
|
||||
getListBMFMarker().then((value) async {
|
||||
///先清除地图上的所有Marker
|
||||
await myMapController?.removeMarkers(g_listBMFMarker);
|
||||
|
||||
///批量添加定位标记
|
||||
await myMapController?.addMarkers(g_listBMFMarker);
|
||||
|
||||
///批量添加文字标记,作为定位标记的说明文字
|
||||
for (var text in g_listBMFText) {
|
||||
//text.setMethodChannel(MethodChannel());
|
||||
await myMapController?.addText(text);
|
||||
}
|
||||
|
||||
//加在此处无效
|
||||
//点击Marker时会回调BaiduMap.OnMarkerClickListener,监听器的实现方式示例如下:
|
||||
/// 地图marker点击回调
|
||||
//myMapController?.setMapClickedMarkerCallback(callback: _markerCallback);
|
||||
});
|
||||
setState(() {});
|
||||
});
|
||||
});
|
||||
|
||||
/// 地图加载回调
|
||||
myMapController?.setMapDidLoadCallback(callback: () {
|
||||
print('mapDidLoad-地图加载完成');
|
||||
});
|
||||
|
||||
///批量添加定位标记
|
||||
getListBMFMarker().then((value) {
|
||||
myMapController?.addMarkers(g_listBMFMarker);
|
||||
|
||||
///批量添加文字标记,作为定位标记的说明文字
|
||||
for (var text in g_listBMFText) {
|
||||
myMapController?.addText(text);
|
||||
}
|
||||
|
||||
///1、底图标注 点击回调:
|
||||
// 点中底图标注后会回调此接口
|
||||
myMapController?.setMapOnClickedMapPoiCallback(callback: (BMFMapPoi mapPoi) async {
|
||||
print('mapPoi = ${mapPoi.toMap().toString()}');
|
||||
myMapController.getZoomLevel().then((value) {
|
||||
g_zoomLevel = value;
|
||||
print('myMapController.getZoomLevel() = ${value.toString()}');
|
||||
});
|
||||
//I/flutter (11895): mapPoi = {text: 森林小区, pt: {latitude: 28.765632464539106, longitude: 104.60481101089357}, uid: ea4cae6307501c5f4d2fdfe9}
|
||||
onMarkerClicked(mapPoi.pt);
|
||||
});
|
||||
|
||||
///2、底图空白处 点击回调
|
||||
// 点中底图空白处会回调此接口
|
||||
/// coordinate 经纬度
|
||||
myMapController?.setMapOnClickedMapBlankCallback(callback: (BMFCoordinate coordinate) {
|
||||
print('点击底图空白处响应:coordinate = ${coordinate.toMap().toString()}');
|
||||
myMapController.getZoomLevel().then((value) {
|
||||
g_zoomLevel = value;
|
||||
print('myMapController.getZoomLevel() = ${value.toString()}');
|
||||
});
|
||||
onMarkerClicked(coordinate);
|
||||
});
|
||||
|
||||
//3、Marker 点击响应,点击文本标签没反应,加在此处有效
|
||||
//点击Marker时会回调BaiduMap.OnMarkerClickListener,监听器的实现方式示例如下:
|
||||
/// 地图marker点击回调
|
||||
myMapController?.setMapClickedMarkerCallback(callback: (String id, dynamic extra) async {
|
||||
myMapController.getZoomLevel().then((value) {
|
||||
g_zoomLevel = value;
|
||||
print('myMapController.getZoomLevel() = ${value.toString()}');
|
||||
});
|
||||
print('点击 Marker 标签响应:id = ${id}');
|
||||
//百度地图的脑残设计,需要在添加BMFMarker时自己保存ID
|
||||
//g_listBMFMarkerIDmap.add({marker.getId(): listDwinfo[i]["id"]});
|
||||
print('Marker的 标签响应:id = ${listDwinfoGetList2[g_map_BMFMarkerID_dwIndex[id]]["dwmc"]}');
|
||||
|
||||
_markerCallback(id, 'test'); //响应用户点击
|
||||
});
|
||||
});
|
||||
//批量添加定位标记
|
||||
}
|
||||
|
||||
Map mapBMFTextCoordinateList = {};
|
||||
|
||||
//1、江北振兴大道 估算坐标区域
|
||||
// 左上角 coordinate = {latitude: 28.807221307340154, longitude: 104.60667948635371}
|
||||
// 右下角 coordinate = {latitude: 28.805069070677582, longitude: 104.62110627283919}
|
||||
// listMarkerCoordinate是包含13个Map点位标记的List,每个Map元素包括4个子元素,
|
||||
// 分别是左上角坐标(纬度 latitude,经度 longitude)、右下角坐标(纬度 latitude,经度 longitude)
|
||||
List listMarkerCoordinate1 = [
|
||||
{
|
||||
'topLatitude': 28.807221307340154,
|
||||
'leftLongitude': 104.60667948635371,
|
||||
'bottomLatitude': 28.805069070677582,
|
||||
'rightLongitude': 104.62110627283919
|
||||
}
|
||||
];
|
||||
|
||||
//12、大麦坝
|
||||
//左上角 coordinate = coordinate = {latitude: 28.8044360513459, longitude: 104.63110441316194}
|
||||
//右下角 coordinate = coordinate = {latitude: 28.803415299489192, longitude: 104.63598221207951}
|
||||
// listMarkerCoordinate是包含13个Map点位标记的List,每个Map元素包括4个子元素,
|
||||
// 分别是左上角坐标(纬度 latitude,经度 longitude)、右下角坐标(纬度 latitude,经度 longitude)
|
||||
//15倍放大时设置,地图放到18倍时,点击没有问题,
|
||||
//缩小到13倍时,不行了
|
||||
//15倍放大
|
||||
//左下角coordinate = {latitude: 28.79913436190729, longitude: 104.66847392236468}
|
||||
//左上角coordinate = {latitude: 28.806612039019615, longitude: 104.62731356391107}
|
||||
List listMarkerCoordinate = [
|
||||
{
|
||||
'topLatitude': 28.80778309701711,
|
||||
'leftLongitude': 104.63028695514814,
|
||||
'bottomLatitude': 28.79801859852449,
|
||||
'rightLongitude': 104.66974951618843
|
||||
}
|
||||
];
|
||||
|
||||
//以13倍放大时的数据设置
|
||||
//左下角coordinate = {latitude: 28.80399293550177, longitude: 104.63028695514814}
|
||||
//左上角coordinate = {latitude: 28.79801859852449, longitude: 104.66974951618843}
|
||||
|
||||
// 中国在世界地图上的经纬度范围? // 2019-04-14 · 把复杂的事情简单说给你听
|
||||
|
||||
// top 北起黑龙江省漠河以北的黑龙江主航道的中心线 北纬 53°31′
|
||||
// bottom 南达南海南沙群岛的曾母内暗沙 北纬 4°15′
|
||||
// left 西起新容疆维吾尔自治区乌恰县以西的帕米尔高原 东经 73°
|
||||
// right 东至黑龙江省抚远县境内的黑龙江与乌苏里江汇合处 东经 135°。
|
||||
//
|
||||
// 中国位于地球的东半球北半部、亚欧大陆的东南部、亚洲的东部和中部、太平洋的西岸。
|
||||
|
||||
int i = 0;
|
||||
|
||||
//纬度 latitude,经度 longitude
|
||||
Future onMarkerClicked(BMFCoordinate coordinate) {
|
||||
//double scale = g_zoomLevel / 15;
|
||||
if (listMarkerCoordinate[i]['topLatitude'] > coordinate.latitude &&
|
||||
coordinate.latitude > listMarkerCoordinate[i]['bottomLatitude'] &&
|
||||
listMarkerCoordinate[i]['rightLongitude'] > coordinate.longitude &&
|
||||
coordinate.longitude > listMarkerCoordinate[i]['leftLongitude']) {
|
||||
_markerCallback('123', 'test');
|
||||
} //响应用户点击
|
||||
}
|
||||
|
||||
bool isDoing = false;
|
||||
|
||||
Future _markerCallback(String id, dynamic extra) async {
|
||||
if (isDoing) {
|
||||
print('正在处理中...,不能重复进入');
|
||||
return;
|
||||
}
|
||||
print('开始处理');
|
||||
print('mapClickedMarker--\n marker = $id');
|
||||
|
||||
//已经能够弹出Flutter对话框。但只有点击 Marker 标签有反应,点击文本标签没反应。
|
||||
|
||||
//百度地图的脑残设计,需要在添加BMFMarker时自己保存ID
|
||||
//g_listBMFMarkerIDmap.add({marker.getId(): listDwinfo[i]["id"]});
|
||||
int dwIndex = g_map_BMFMarkerID_dwIndex[id];
|
||||
print('Marker的 标签响应:id = ${listDwinfoGetList2[dwIndex]["dwmc"]}');
|
||||
|
||||
getStatisData(statisType: 'zptj', ip: listDwinfoGetList2[dwIndex]['dwip'])
|
||||
.then((mapStatisData) async {
|
||||
String title =
|
||||
listDwinfoGetList2[dwIndex]["id"].toString() + '、' + listDwinfoGetList2[dwIndex]["dwmc"];
|
||||
|
||||
List listCoordinate = listDwinfoGetList2[dwIndex]["dwzb"].trim().split('|');
|
||||
String content = listDwinfoGetList2[dwIndex]["dwms"] +
|
||||
'。\n经度:${listCoordinate[0]}\n纬度:${listCoordinate[1]}' +
|
||||
'\n今日抓拍:${mapStatisData['today']['total']}, 累计抓拍:${mapStatisData['all']}' +
|
||||
'\n运行状态:${listDwinfoGetList2[dwIndex]['dwzt']}';
|
||||
await Navigator.of(context)
|
||||
.push(
|
||||
PageRouteBuilder(
|
||||
opaque: false,
|
||||
pageBuilder: (context, animation, secondaryAnimation) =>
|
||||
dwInfoDialog(id: id, dwIndex: dwIndex, title: title, content: content),
|
||||
),
|
||||
)
|
||||
.then((value) async {
|
||||
print('value = $value');
|
||||
if (value) {
|
||||
print('用户已确认,开始处理推送交警!');
|
||||
//return;
|
||||
} else {
|
||||
print('用户取消了推送交警操作');
|
||||
}
|
||||
});
|
||||
|
||||
setState(() {
|
||||
// _markerID = id;
|
||||
// _action = "点击";
|
||||
});
|
||||
isDoing = false;
|
||||
});
|
||||
}
|
||||
|
||||
double _widthBtn = 45;
|
||||
double _heightBtn = 45;
|
||||
double _edge = 16;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
screenSize = MediaQuery.of(context).size;
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size.fromHeight(ScreenUtil().setHeight(173)), // 设置appBar高度
|
||||
// 设置appBar高度
|
||||
child: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
centerTitle: true,
|
||||
titleSpacing: 0.0,
|
||||
//设置title的左边距
|
||||
flexibleSpace: Container(
|
||||
//SizedBox(height: ScreenUtil().statusBarHeight), //显示顶部状态栏
|
||||
// SizedBox(height: ScreenUtil().setHeight(10)), //显示顶部状态栏
|
||||
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight), //留出顶部状态栏高度
|
||||
child: Container(
|
||||
//height: ScreenUtil().setHeight(173),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
Color.fromRGBO(12, 186, 156, 1),
|
||||
Color.fromRGBO(39, 127, 235, 1),
|
||||
],
|
||||
),
|
||||
),
|
||||
// decoration: BoxDecoration(
|
||||
// gradient: LinearGradient(colors: [
|
||||
// Color(0xFF0018EB),
|
||||
// Color(0xFF01C1D9),
|
||||
// ], begin: Alignment.bottomCenter, end: Alignment.topCenter),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
getIconAndTextButton(
|
||||
iconColor: Colors.white,
|
||||
iconData: Icons.chevron_left_outlined,
|
||||
onPress: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Text(widget.title + '(${g_zoomLevel}倍)',
|
||||
style: TextStyle(color: Colors.white, fontSize: 20),
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
//SizedBox(width: ScreenUtil().setWidth(45)),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
//Navigator.pushNamed(context, '/registerFirst');
|
||||
this.setState(() {
|
||||
_showMapPoi = !_showMapPoi;
|
||||
myMapController?.updateMapOptions(BMFMapOptions(showMapPoi: _showMapPoi));
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment(0, 0),
|
||||
//width: 150,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text('标注:', style: TextStyle(fontSize: 20, color: Colors.white)),
|
||||
Container(
|
||||
alignment: Alignment(0, 0),
|
||||
height: 25,
|
||||
width: 25,
|
||||
padding: EdgeInsets.only(top: ScreenUtil().setHeight(6)),
|
||||
child: _showMapPoi
|
||||
? Icon(Icons.check_box, color: Colors.white)
|
||||
: Icon(Icons.check_box_outline_blank, color: Colors.white),
|
||||
),
|
||||
SizedBox(width: ScreenUtil().setWidth(65)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Stack(
|
||||
children: <Widget>[
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
height: screenSize.height,
|
||||
width: screenSize.width,
|
||||
child: BMFMapWidget(
|
||||
onBMFMapCreated: (controller) {
|
||||
onBMFMapCreated(controller);
|
||||
},
|
||||
mapOptions: mapOptions,
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment(1, 1),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 5, right: _edge),
|
||||
child: Container(
|
||||
width: _widthBtn,
|
||||
height: _heightBtn * 2 + 3,
|
||||
decoration: new BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(2.0)),
|
||||
border: new Border.all(width: 1, color: Colors.blue),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: _widthBtn,
|
||||
height: _heightBtn,
|
||||
//color: Colors.white,
|
||||
child: InkWell(
|
||||
// child: Icon(Icons.my_location_outlined, color: Colors.black45),
|
||||
child: Icon(Icons.add, color: g_zoomLevel < 16 ? Colors.blue : Colors.grey),
|
||||
onTap: g_zoomLevel < 16
|
||||
? () {
|
||||
//放大按钮,缩放限制12-16
|
||||
if (g_zoomLevel < 16) {
|
||||
g_zoomLevel++;
|
||||
myMapController
|
||||
?.updateMapOptions(BMFMapOptions(zoomLevel: g_zoomLevel));
|
||||
}
|
||||
}
|
||||
: null,
|
||||
),
|
||||
),
|
||||
Divider(height: 1.0, color: Colors.blue),
|
||||
Container(
|
||||
width: _widthBtn,
|
||||
height: _heightBtn,
|
||||
//color: Colors.white,
|
||||
child: InkWell(
|
||||
// child: Icon(Icons.my_location_outlined, color: Colors.black45),
|
||||
child: Icon(Icons.horizontal_rule,
|
||||
color: g_zoomLevel > 12 ? Colors.blue : Colors.grey),
|
||||
onTap: g_zoomLevel > 12
|
||||
? () {
|
||||
//缩小按钮,缩放限制12-16
|
||||
g_zoomLevel--;
|
||||
myMapController
|
||||
?.updateMapOptions(BMFMapOptions(zoomLevel: g_zoomLevel));
|
||||
}
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment(-1, 1),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 50, left: _edge),
|
||||
child: Container(
|
||||
decoration: new BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(2.0)),
|
||||
border: new Border.all(width: 1, color: Colors.blue),
|
||||
),
|
||||
width: _widthBtn,
|
||||
height: _heightBtn,
|
||||
//color: Colors.white,
|
||||
child: InkWell(
|
||||
// child: Icon(Icons.my_location_outlined, color: Colors.black45),
|
||||
// 没有
|
||||
child: Icon(Icons.radio_button_checked_rounded,
|
||||
color: g_zoomLevel == 14 ? Colors.grey : Colors.blue),
|
||||
onTap: () {
|
||||
g_zoomLevel = 14;
|
||||
//还原按钮,重新设置中心位置、缩放级别
|
||||
//myMapController.setCenterCoordinate(coordinate, animated);
|
||||
//没有myMapController.getCenterCoordinate,无法简单地获取当前中心坐标;
|
||||
myMapController?.updateMapOptions(
|
||||
BMFMapOptions(center: BMFCoordinate(28.77914, 104.644079)));
|
||||
myMapController?.updateMapOptions(BMFMapOptions(zoomLevel: g_zoomLevel));
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hyzp_ybqx/components/dioFun.dart';
|
||||
|
||||
//import 'package:hyzp_ybqx/widget/player_pro.dart';
|
||||
import '../../../components/commonFun.dart';
|
||||
|
||||
//确认对话框
|
||||
class dwInfoDialog extends Dialog {
|
||||
dwInfoDialog({@required this.id, this.title = "", @required this.dwIndex, this.content});
|
||||
|
||||
int dwIndex;
|
||||
String id;
|
||||
String title;
|
||||
String content;
|
||||
bool ret = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size mediaSize = MediaQuery.of(context).size;
|
||||
return WillPopScope(
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(top: 116),
|
||||
alignment: Alignment(0, -1),
|
||||
color: Colors.black12,
|
||||
child: Container(
|
||||
// height: 260,
|
||||
// width: 300,
|
||||
height: mediaSize.height * 0.51,
|
||||
width: mediaSize.width * 0.95,
|
||||
//color: Colors.white, //Cannot provide both a color and a decoration
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: Colors.blue, width: 2.0),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
"${this.title}",
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: InkWell(
|
||||
child: Icon(Icons.close),
|
||||
onTap: () {
|
||||
getingDwVideo = false;
|
||||
Navigator.pop(context, ret);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(color: Colors.blue),
|
||||
Container(
|
||||
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
|
||||
width: double.infinity,
|
||||
height: mediaSize.height * 0.28,
|
||||
child: SingleChildScrollView(
|
||||
child: Text(content, style: TextStyle(fontSize: 18.0, color: Colors.blue)),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
onPressed: () {
|
||||
ret = true;
|
||||
//getDwspUrl(index: dwIndex, context: context);
|
||||
getDwspUrlNew(indexRecord: dwIndex, context: context);
|
||||
},
|
||||
child: Text("视频"),
|
||||
),
|
||||
RaisedButton(
|
||||
onPressed: () async {
|
||||
ret = true;
|
||||
getingDwVideo = false;
|
||||
Navigator.pop(context, ret); //关闭弹框,返回sRet
|
||||
},
|
||||
child: Text("确认"),
|
||||
),
|
||||
RaisedButton(
|
||||
child: Text("取消"),
|
||||
onPressed: () async {
|
||||
getingDwVideo = false;
|
||||
Navigator.pop(context, ret); //关闭弹框,返回sRet
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onWillPop: () {
|
||||
// 屏蔽点击返回键的操作
|
||||
getingDwVideo = false;
|
||||
Navigator.pop(context, ret);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bmfbase/BaiduMap/bmfmap_base.dart';
|
||||
import 'package:flutter_bmfmap/BaiduMap/bmfmap_map.dart';
|
||||
import 'package:hyzp_ybqx/components/hyxx_data_handle.dart';
|
||||
|
||||
///批量添加定位标记
|
||||
bool enable = true;
|
||||
bool dragable = true;
|
||||
int g_zoomLevel = 14; //缩放倍数
|
||||
///批量添加定位标记
|
||||
List<BMFMarker> g_listBMFMarker = [];
|
||||
Map g_map_BMFMarkerID_dwIndex = {};
|
||||
List<BMFText> g_listBMFText = [];
|
||||
|
||||
//https://www.cnblogs.com/ybmj/p/14408263.html
|
||||
//百度地图的脑残设计,附上代码,为后来的码农们...
|
||||
Future getListBMFMarker({List listDwinfo}) async {
|
||||
if (null == listDwinfo) {
|
||||
listDwinfo = listDwinfoGetList2;
|
||||
}
|
||||
|
||||
//double _scale = 9900 / 10000; //自己控制off_latitude、off_longitude效果不好
|
||||
|
||||
// BMFMarker marker1 = BMFMarker(
|
||||
// position: BMFCoordinate(28.807061, 104.607091),
|
||||
// title: '1、江北振兴大道',
|
||||
// subtitle: 'test',
|
||||
// identifier: 'flutter_marker',
|
||||
// icon: 'assets/images/location.png',
|
||||
// enabled: enable,
|
||||
// draggable: dragable);
|
||||
|
||||
int len = listDwinfo.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
BMFMarker marker = BMFMarker(
|
||||
position: getBMFCoordinate(listDwinfo[i]["dwzb"]),
|
||||
title: '${listDwinfo[i]["id"].toString()}、${listDwinfo[i]["dwmc"]}',
|
||||
subtitle: 'test',
|
||||
identifier: '${listDwinfo[i]["id"].toString()}、${listDwinfo[i]["dwmc"]}',
|
||||
icon: 'assets/images/location.png',
|
||||
|
||||
/// 默认情况下, annotation view的中心位于annotation的坐标位置,
|
||||
/// 可以设置centerOffset改变view的位置,正的偏移使view朝右下方移动,负的朝左上方,单位是像素
|
||||
/// 目前Android只支持Y轴设置偏移量对应SDK的 yOffset(int yOffset) 方法
|
||||
/// 添加标记 BMFMarker 百度官方有 centerOffset 偏移参数,
|
||||
/// 文本标签 BMFText 官方没有 centerOffset 偏移参数,我取消了 BMFMarker 的偏移。你看这样行吗?
|
||||
/// 按公司要求,为更准确定位,取消 BMFMarker 的偏移
|
||||
centerOffset: BMFPoint(0, 0),
|
||||
//标记中心偏移
|
||||
enabled: enable,
|
||||
draggable: dragable);
|
||||
// 百度地图的脑残设计,用Flutter添加多个BMFMarker时,必须在添加BMFMarker时自己保存ID,
|
||||
// 否则响应点击时无法确定用户点击的是哪个定位标注
|
||||
// 代码不会自动返回,也没有任何文档说明,是花了一天时间搜索网络无果,是自己翻江倒海摸索出来的
|
||||
// 下一句是关键代码,将添加的每个BMFMarker的id保存到一个map中,
|
||||
// 这样在用setMapClickedMarkerCallback添加BMFMarker的通用响应函数中,便可以根据id号来判断用户点击的是哪一个定位标注
|
||||
g_map_BMFMarkerID_dwIndex[marker.getId()] = i;
|
||||
g_listBMFMarker.add(marker);
|
||||
|
||||
g_listBMFText.add(BMFText(
|
||||
text: '${listDwinfo[i]["id"].toString()}、${listDwinfo[i]["dwmc"]}',
|
||||
//纬度偏移-上下 off_latitude, 经度偏移-左右 off_longitude
|
||||
//已经在zoomLevel = 15时调整好定位标记与文本标记的相对位置
|
||||
// ,当地图缩放时,会发生位置变化,必须使用 Provider 或者 EventBus 进行跟踪更新
|
||||
|
||||
//https://time.geekbang.org/column/article/131890
|
||||
//老师,provider、eventBus的用途有啥区别吗,都可以做状态的通知
|
||||
// 作者回复: Provider 主要是用来做数据读写共享;event_bus主要是用来做数据状态通知、实现组件间单向数据传递。
|
||||
//如果我们的应用足够简单,数据流动的方向和顺序是清晰的,我们只需要将数据映射成视图就可以了。
|
||||
// 作为声明式的框架,Flutter 可以自动处理数据到渲染的全过程,通常并不需要 Provider 状态管理。
|
||||
// position: getBMFCoordinate(listDwinfo[i]["dwzb"],
|
||||
// off_latitude: -0.0002 * g_zoomLevel * _scale,
|
||||
// off_longitude: -0.00009 * g_zoomLevel * _scale),
|
||||
position: getBMFCoordinate(listDwinfo[i]["dwzb"]),
|
||||
//自己控制off_latitude、off_longitude效果不好
|
||||
bgColor: Colors.yellow,
|
||||
fontColor: Colors.black,
|
||||
fontSize: 35,
|
||||
// typeFace:
|
||||
// BMFTypeFace(familyName: BMFFamilyName.sMonospace, textStype: BMFTextStyle.BOLD_ITALIC),
|
||||
typeFace: BMFTypeFace(familyName: BMFFamilyName.sMonospace, textStype: BMFTextStyle.BOLD),
|
||||
alignY: BMFVerticalAlign.ALIGN_TOP,
|
||||
alignX: BMFHorizontalAlign.ALIGN_LEFT,
|
||||
rotate: 0.0,
|
||||
zIndex: 99));
|
||||
}
|
||||
}
|
||||
|
||||
//文字覆盖物
|
||||
// 文字(Text)在地图上也是一种覆盖物,由BMFText类定义,示例代码如下:
|
||||
//
|
||||
// /// text经纬度信息
|
||||
// BMFCoordinate position = new BMFCoordinate(39.73235, 116.350338);
|
||||
//
|
||||
// /// 构造text
|
||||
// BMFText bmfText = BMFText(
|
||||
// text: 'hello world',
|
||||
// position: position,
|
||||
// bgColor: Colors.blue,
|
||||
// fontColor: Colors.red,
|
||||
// fontSize: 40,
|
||||
// typeFace: BMFTypeFace( familyName: BMFFamilyName.sMonospace,
|
||||
// textStype: BMFTextStyle.BOLD_ITALIC),
|
||||
// alignY: BMFVerticalAlign.ALIGN_TOP,
|
||||
// alignX: BMFHorizontalAlign.ALIGN_LEFT,
|
||||
// rotate: 30.0);
|
||||
//
|
||||
// /// 添加text
|
||||
// myMapController.addText(bmfText);
|
||||
|
||||
//从"dwzb": "104.607091|28.807061",得到BMFCoordinate(28.807061, 104.607091)
|
||||
//纬度偏移-上下 off_latitude, 经度偏移-左右 off_longitude
|
||||
//自己控制off_latitude、off_longitude效果不好
|
||||
BMFCoordinate getBMFCoordinate(String dwzb, {double off_latitude = 0, double off_longitude = 0}) {
|
||||
off_latitude = 0; //取消偏移
|
||||
off_longitude = 0; //取消偏移
|
||||
List _listCoordinateItem = dwzb.trim().split('|');
|
||||
return BMFCoordinate(double.parse(_listCoordinateItem[1]) - off_latitude,
|
||||
double.parse(_listCoordinateItem[0]) - off_longitude);
|
||||
}
|
||||
Reference in New Issue
Block a user