0

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);
 });
MrUpsidown
  • 21,592
  • 15
  • 77
  • 131
SOS video
  • 436
  • 9
  • 21
  • 1
    Does this answer your question? [How to change the icon size of Google Maps marker in Flutter?](https://stackoverflow.com/questions/53633404/how-to-change-the-icon-size-of-google-maps-marker-in-flutter) – Gowtham Sooryaraj May 31 '21 at 05:31

1 Answers1

8

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));
Payam Asefi
  • 2,677
  • 2
  • 15
  • 26