问题描述
我尝试将BitmapDescriptor.fromBytes用于Google地图标记的图标。该用法在Android上运行良好,并在地图标记中显示了该图标。这是我的逻辑功能代码:
void convertToImg({BuildContext context,List<DataEvent> data}) async{
for(int i=0;i<data.length;i++) {
final http.Response res = await http.get(data[i].category.icon);
DrawableRoot root = await svg.fromSvgBytes(res.bodyBytes,null);
ui.Picture picture = root.toPicture(size: Size(16,16));
ui.Image image = await picture.toImage(16,16);
ByteData byteData = await image.toByteData(format: ui
.ImageByteFormat.png);
listImg.add(byteData.buffer.asUint8List());
}
}
void addMarker({List<DataEvent> data}) {
markers = Iterable.generate(data.length,(index) {
return Marker(
markerId: MarkerId("${data[index].id}"),position: LatLng(
double.parse(data[index].location.split(',')[0]),double.parse(data[index].location.split(',')[1])
),infoWindow: InfoWindow(
title: data[index].name,snippet: data[index].description,anchor: Offset(1.5,1.5)
),icon: BitmapDescriptor.fromBytes(listImg[index])
);
});
}
有人知道为什么吗?
Here is for both result. The icon just like a small white cuttlefish
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)