Future<BitmapDescriptor> _getCustomMarkerIcon(double size) async {
final icon = await BitmapDescriptor.fromAssetImage(
ImageConfiguration(size: Size(size, size)),
'assets/images/car.png',
);
return icon;
}
_getCustomMarkerIcon(2).then((icon) {
setState(() {
_customIcon = icon;
_markers = recommended_cars
.map((e) => _buildMarker(e, recommended_cars.indexOf(e).toString()))
.toSet();
});
});
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Stack(
children: [
GoogleMap(
zoomControlsEnabled: false,
myLocationEnabled: false,
initialCameraPosition: _initialCamPos,
markers: _markers,
)
],
),
),
);
}
}
这是我的小工具,我传递了值2到大小,我尝试了5或10,但图标大小根本没有改变。
当我编辑尺寸值时,我希望尺寸会改变,但什么也没有发生,我真的尝试了一切,我不知道问题到底在哪里。
我想是这里
_getCustomMarkerIcon(2).then((icon) {
setState(() {
_customIcon = icon;
_markers = recommended_cars
.map((e) => _buildMarker(e, recommended_cars.indexOf(e).toString()))
.toSet();
1条答案
按热度按时间pbwdgjma1#
根据我在评论中所说的:
更改以下代码:
致:
我已经测试过了,它很有效!注意,由于
targetWidth
只能接受整数,因此宽度类型从double
更改为int
。