本文介绍了Flutter Network Image作为Google Map Marker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在屏幕上显示的Google地图上添加网络图像作为标记。该API支持功能 Bitmapdescriptor.fromBytes()
。但是,我不知道如何在网络映像中使用它。
I would like to add a network image as a marker on the google map I have on screen. The API does support a function Bitmapdescriptor.fromBytes()
. However, I do not know how to use it with network images.
BitmapDescriptor.fromBytes(byteData);
推荐答案
import 'package:http/http.dart' as http;
var iconurl ="your url";
var dataBytes;
var request = await http.get(iconurl);
var bytes = await request.bodyBytes;
setState(() {
dataBytes = bytes;
});
LatLng _lastMapPositionPoints = LatLng(
double.parse("22.7339"),
double.parse("75.8499"));
_markers.add(Marker(
icon: BitmapDescriptor.fromBytes(dataBytes.buffer.asUint8List()),
markerId: MarkerId(_lastMapPositionPoints.toString()),
position: _lastMapPositionPoints,
infoWindow: InfoWindow(
title: "Delivery Point",
snippet:
"My Position",
),
));
这篇关于Flutter Network Image作为Google Map Marker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!