hyzp_ybqx-Commit136:已经通过修改 flutter_bmfmap_1.0.2,实现加载外部存储中的.png带文本的标识图标

This commit is contained in:
WinUser01
2022-05-02 14:55:24 +08:00
parent c4b9c508e0
commit eb03a6085d
6 changed files with 81 additions and 62 deletions
Binary file not shown.
+2 -1
View File
@@ -446,7 +446,8 @@ class _BasicMapState extends State<BasicMap> {
//color: Colors.white, //color: Colors.white,
child: InkWell( child: InkWell(
// child: Icon(Icons.my_location_outlined, color: Colors.black45), // child: Icon(Icons.my_location_outlined, color: Colors.black45),
child: Icon(Icons.add, color: g_zoomLevel < g_zoomMax ? Colors.blue : Colors.grey), child: Icon(Icons.add,
color: g_zoomLevel < g_zoomMax ? Colors.blue : Colors.grey),
onTap: g_zoomLevel < g_zoomMax onTap: g_zoomLevel < g_zoomMax
? () { ? () {
//放大按钮,缩放限制g_zoomMin-g_zoomMax //放大按钮,缩放限制g_zoomMin-g_zoomMax
+39 -28
View File
@@ -10,6 +10,12 @@ int g_zoomLevel_default = 14; //地图默认缩放倍数
int g_zoomLevel = 14; //地图缩放倍数 int g_zoomLevel = 14; //地图缩放倍数
int g_zoomMin = 10; int g_zoomMin = 10;
int g_zoomMax = 18; int g_zoomMax = 18;
String g_myIconPathPre = "";
// g_myIconPathPre = /data/user/0/com.example.hyzp_yibin_bmfmap/app_flutter/myIcons
String g_myIconDir = "myIcons";
String g_myIconPre = "myIcon";
///批量添加定位标记 ///批量添加定位标记
List<BMFMarker> g_listBMFMarker = []; List<BMFMarker> g_listBMFMarker = [];
Map g_map_BMFMarkerID_dwIndex = {}; Map g_map_BMFMarkerID_dwIndex = {};
@@ -42,7 +48,11 @@ Future getListBMFMarker({List listDwinfo}) async {
subtitle: 'test', subtitle: 'test',
// identifier: '${listDwinfo[i]["id"].toString()}、${listDwinfo[i]["dwmc"]}', // identifier: '${listDwinfo[i]["id"].toString()}、${listDwinfo[i]["dwmc"]}',
identifier: '${(i + 1).toString()}、${listDwinfo[i]["dwmc"]}', identifier: '${(i + 1).toString()}、${listDwinfo[i]["dwmc"]}',
icon: 'assets/images/location.png', // icon: 'assets/images/location.png',
// 为IOS在百度地图中显示文本图标
icon: "$g_myIconPathPre/${g_myIconPre}${i + 1}.png",
// icon: '/data/user/0/com.example.hyzp_yibin_bmfmap/app_flutter/myIcons/myIcon01.png',
/// 默认情况下, annotation view的中心位于annotation的坐标位置, /// 默认情况下, annotation view的中心位于annotation的坐标位置,
/// 可以设置centerOffset改变view的位置,正的偏移使view朝右下方移动,负的朝左上方,单位是像素 /// 可以设置centerOffset改变view的位置,正的偏移使view朝右下方移动,负的朝左上方,单位是像素
@@ -62,33 +72,34 @@ Future getListBMFMarker({List listDwinfo}) async {
g_map_BMFMarkerID_dwIndex[marker.getId()] = i; g_map_BMFMarkerID_dwIndex[marker.getId()] = i;
g_listBMFMarker.add(marker); g_listBMFMarker.add(marker);
g_listBMFText.add(BMFText( // android专有
// text: '${listDwinfo[i]["id"].toString()}、${listDwinfo[i]["dwmc"]}', // g_listBMFText.add(BMFText(
text: '${(i + 1).toString()}、${listDwinfo[i]["dwmc"]}', // // text: '${listDwinfo[i]["id"].toString()}、${listDwinfo[i]["dwmc"]}',
//纬度偏移-上下 off_latitude, 经度偏移-左右 off_longitude // text: '${(i + 1).toString()}、${listDwinfo[i]["dwmc"]}',
//已经在zoomLevel = 15时调整好定位标记与文本标记的相对位置 // //纬度偏移-上下 off_latitude, 经度偏移-左右 off_longitude
// ,当地图缩放时,会发生位置变化,必须使用 Provider 或者 EventBus 进行跟踪更新 // //已经在zoomLevel = 15时调整好定位标记与文本标记的相对位置
// // ,当地图缩放时,会发生位置变化,必须使用 Provider 或者 EventBus 进行跟踪更新
//https://time.geekbang.org/column/article/131890 //
//老师,provider、eventBus的用途有啥区别吗,都可以做状态的通知 // //https://time.geekbang.org/column/article/131890
// 作者回复: Provider 主要是用来做数据读写共享;event_bus主要是用来做数据状态通知、实现组件间单向数据传递。 // //老师,provider、eventBus的用途有啥区别吗,都可以做状态的通知
//如果我们的应用足够简单,数据流动的方向和顺序是清晰的,我们只需要将数据映射成视图就可以了。 // // 作者回复: Provider 主要是用来做数据读写共享;event_bus主要是用来做数据状态通知、实现组件间单向数据传递。
// 作为声明式的框架,Flutter 可以自动处理数据到渲染的全过程,通常并不需要 Provider 状态管理。 // //如果我们的应用足够简单,数据流动的方向和顺序是清晰的,我们只需要将数据映射成视图就可以了。
// position: getBMFCoordinate(listDwinfo[i]["dwzb"], // // 作为声明式的框架,Flutter 可以自动处理数据到渲染的全过程,通常并不需要 Provider 状态管理。
// off_latitude: -0.0002 * g_zoomLevel * _scale, // // position: getBMFCoordinate(listDwinfo[i]["dwzb"],
// off_longitude: -0.00009 * g_zoomLevel * _scale), // // off_latitude: -0.0002 * g_zoomLevel * _scale,
position: getBMFCoordinate(listDwinfo[i]["dwzb"]), // // off_longitude: -0.00009 * g_zoomLevel * _scale),
//自己控制off_latitude、off_longitude效果不好 // position: getBMFCoordinate(listDwinfo[i]["dwzb"]),
bgColor: Colors.yellow, // //自己控制off_latitude、off_longitude效果不好
fontColor: Colors.black, // bgColor: Colors.yellow,
fontSize: 35, // fontColor: Colors.black,
// typeFace: // fontSize: 35,
// BMFTypeFace(familyName: BMFFamilyName.sMonospace, textStype: BMFTextStyle.BOLD_ITALIC), // // typeFace:
typeFace: BMFTypeFace(familyName: BMFFamilyName.sMonospace, textStype: BMFTextStyle.BOLD), // // BMFTypeFace(familyName: BMFFamilyName.sMonospace, textStype: BMFTextStyle.BOLD_ITALIC),
alignY: BMFVerticalAlign.ALIGN_TOP, // typeFace: BMFTypeFace(familyName: BMFFamilyName.sMonospace, textStype: BMFTextStyle.BOLD),
alignX: BMFHorizontalAlign.ALIGN_LEFT, // alignY: BMFVerticalAlign.ALIGN_TOP,
rotate: 0.0, // alignX: BMFHorizontalAlign.ALIGN_LEFT,
zIndex: 99)); // rotate: 0.0,
// zIndex: 99));
} }
} }
+33 -1
View File
@@ -1,6 +1,11 @@
import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:hyzp_ybqx/components/commonFun.dart'; import 'package:hyzp_ybqx/components/commonFun.dart';
import 'package:hyzp_ybqx/components/dioFun.dart'; import 'package:hyzp_ybqx/components/dioFun.dart';
import 'package:hyzp_ybqx/components/hyxx_data_handle.dart'; import 'package:hyzp_ybqx/components/hyxx_data_handle.dart';
import 'package:hyzp_ybqx/pages/Works/DWDT/dwInfo_data.dart';
import 'package:hyzp_ybqx/pages/Works/DWDT/widget_to_image.dart';
import 'package:hyzp_ybqx/services/EventBus.dart'; import 'package:hyzp_ybqx/services/EventBus.dart';
///获取车流量日统计数据 ///获取车流量日统计数据
@@ -481,10 +486,14 @@ Future startGetStatisDataNew() async {
if (listDwinfoGetList2.isEmpty) { if (listDwinfoGetList2.isEmpty) {
//若没有读取点位数据,便需要先读取 //若没有读取点位数据,便需要先读取
getThePageList(theHyshlx: 'dwxx').then((value) { getThePageList(theHyshlx: 'dwxx').then((value) async {
listDwinfoGetList2 = value; listDwinfoGetList2 = value;
print('listDwinfoGetList2 = \n$listDwinfoGetList2'); print('listDwinfoGetList2 = \n$listDwinfoGetList2');
dwSum = listDwinfoGetList2.length; dwSum = listDwinfoGetList2.length;
// 百度地图初始化
await bmfInit();
//获取记录数据 //获取记录数据
getZptjStatisAlone(); getZptjStatisAlone();
getTodayShtj(); getTodayShtj();
@@ -504,6 +513,9 @@ Future startGetStatisDataNew() async {
// } // }
}); });
} else { } else {
// 百度地图初始化
await bmfInit();
if (mapStatisInfo['今日抓拍'] < 0) { if (mapStatisInfo['今日抓拍'] < 0) {
//获取记录数据 //获取记录数据
getZptjStatisAlone(); getZptjStatisAlone();
@@ -680,3 +692,23 @@ Future getAllSumCll(String field, List listStatis) async {
} }
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// 百度地图初始化
Future bmfInit() async {
g_myIconPathPre = await createDir(g_myIconDir);
print("g_myIconPathPre = $g_myIconPathPre");
// g_myIconPathPre = /data/user/0/com.example.hyzp_yibin_bmfmap/app_flutter/myIcons
int len = listDwinfoGetList2.length;
for (int i = 0; i < len; i++) {
Widget iconWidget = await getIconWidget("${i + 1}、" + listDwinfoGetList2[i]["dwmc"]);
ByteData byteData = await widgetToImage(iconWidget);
await saveImage(g_myIconDir, "${g_myIconPre}${i + 1}.png", byteData);
print("i = $i");
if (i == len - 1) {
// setState(() {});
// runApp(MyApp());
}
}
}
//////////////////////////////////////////////////////////////////
+7 -32
View File
@@ -221,40 +221,10 @@ flutter:
# - images/a_dot_ham.jpeg # - images/a_dot_ham.jpeg
assets: assets:
- assets/images/
- assets/fun_icons/
- assets/files_icons/ - assets/files_icons/
- assets/fun_icons/
- assets/images/
- assets/audio/ - assets/audio/
- assets/images/背景图.png
- assets/images/形状 811.png
- assets/images/形状 810.png
- assets/images/形状 809.png
- assets/images/图层 5.png
- assets/images/矢量智能对象.png
- assets/images/矢量智能对象(1).png
- assets/images/矩形 1 拷贝 39.png
- assets/images/我的.png
- assets/images/形状 2.png
- assets/images/装饰图片10.png
- assets/images/聚焦.png
- assets/images/盾 密码 安全.png
- assets/images/警察.png
- assets/images/1 (104).png
- assets/images/1 (177).png
- assets/images/LED.png
- assets/images/monitor.png
- assets/images/播放 (1).png
- assets/images/图层 11.png
- assets/images/1 (15).png
- assets/images/1 (84).png
- assets/images/1 (194).png
- assets/images/1 (219).png
- assets/images/个人资料.png
- assets/images/意见反馈.png
- assets/images/版本更新.png
- assets/images/清除缓存.png
- assets/images/关于.png
- assets/images/刷新.png
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware. # https://flutter.dev/assets-and-images/#resolution-aware.
@@ -281,3 +251,8 @@ flutter:
# #
# For details regarding fonts from package dependencies, # For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages # see https://flutter.dev/custom-fonts/#from-packages
fonts:
- family: myfont
fonts:
- asset: assets/font/iconfont.ttf