我想将如图所示的标记作为图标放置在地图上,而位置标记内的图像来自互联网,我该怎么做? 我想要一个简单快捷的方法,因为我是初学者
return Scaffold(
appBar: AppBar(
title: Text("Explore"),
),
body: Container(
child: GetBuilder<ExpoloreController>(
builder: (controllerpage) => HandlingDataView(
statusRequest: controllerpage.statusRequest,
widget: controllerpage.kGooglePlex != null
? Container(
width: double.infinity,
height: double.infinity,
child: GoogleMap(
myLocationButtonEnabled: true,
myLocationEnabled: true,
circles: controllerpage.circles,
markers: {
...List.generate(
doctorsController.doctors.length,
(index) => Marker(
markerId: MarkerId(index.toString()),
position: LatLng(
double.tryParse(doctorsController.doctors[index]
["latitude"]) ??
33.31524,
double.tryParse(doctorsController.doctors[index]
["longitude"]) ??
44.3660667,
),
infoWindow: InfoWindow(
title: doctorsController.doctors[index]["name"],
),
icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueBlue),
onTap: () {},
),
),
},
mapType: MapType.normal,
initialCameraPosition: controllerpage.kGooglePlex!,
onMapCreated: (GoogleMapController controllermap) {
controllerpage.completercontroller!
.complete(controllermap);
},
),
)
: Container(),
),
),
),
);
你可以尝试这样的功能:
Set<Marker> _createMarkers() {
Set<Marker> markers = Set<Marker>();
for (ShipLocation shipLocation in shipLocations) {
BitmapDescriptor.fromAssetImage(
ImageConfiguration(size: Size(48, 48)), // Adjust the size as needed
'lib/assets/images/bg13.png',
).then((bitmapDescriptor) {
markers.add(
Marker(
markerId: MarkerId(shipLocation.shipCode),
icon: bitmapDescriptor,
position: LatLng(shipLocation.location.latitude, shipLocation.location.longitude),
onTap: () => _onMarkerTapped(
shipLocation.shipCode,
shipLocation.captain,
shipLocation.location,
shipLocation.time,
),
),
);
});
}
return markers;
}