I created an application, which shows a custom marker in Google Maps when you tap in the map, but I don't find a way to change the size of the marker... Does anybody know how I can do this?
This are parts of m code:
createMarker(context) {
if (customIcon == null) {
ImageConfiguration configuration = createLocalImageConfiguration(context);
BitmapDescriptor.fromAssetImage(configuration, 'assets/Boot-Pfeil2.png')
.then((icon) {
setState(() {
customIcon = icon;
});
});
}
}
Marker m = Marker(
markerId: MarkerId('1'),
icon: customIcon,
position: cordinate);
setState(() {
markers.add(m);
});
Based on this question:
import 'dart:ui' as ui;
Future<Uint8List> getBytesFromAsset(String path, int width) async {
ByteData data = await rootBundle.load(path);
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width);
ui.FrameInfo fi = await codec.getNextFrame();
return (await fi.image.toByteData(format: ui.ImageByteFormat.png)).buffer.asUint8List();
}
and then:
final Uint8List markerIcon = await getBytesFromAsset('assets/Boot-Pfeil2.png', 100);
final Marker marker = Marker(icon: BitmapDescriptor.fromBytes(markerIcon));